Z
Zed Shaw
Hello folks,
Well I spent the weekend working on the Mongrel
(http://mongrel.rubyforge.org) plugin system, and actually ended up cracking
it out into a separate sub-project and releasing it under Ruby or LGPL.
The GemPlugin project is a dynamic plugin system that uses RubyGems to
create, manage, and load plugins. It's used in Mongrel to allow others to
create commands for people to use without having to be a part of the Mongrel
project. Other systems could use it no problem and it doesn't depend on any
Mongrel code.
The stuff is kind of funky, but take a look at:
http://mongrel.rubyforge.org/gem_plugin_rdoc/
For more information.
== Quick Usage
Plugin Authors do this:
class Snazzy < GemPlugin:lugin "/commands"
...
end
Then place this code in a file they will have RubyGems autorequire (I use
lib/init.rb).
Next they need to add the following to whatever Rakefile code you use to
create your gem:
spec.add_dependency('gem_plugin', '>= 0.1')
spec.add_dependency('theapp', '>= 0.1')
spec.autorequire = 'init.rb'
Plugin Users do this:
$ gem install snazzy_plugin
System Implementers then setup their system to do this:
GemPlugin::Manager.instance.load "theapp" => GemPlugin::INCLUDE
plug = GemPlugin::Manager.instance.create("/commands/snazzy")
And everyone is happy. Read the docs for more information.
== Future Directions
There is already a sample plugin available named mongrel_status which people
can check out as an example:
http://rubyforge.org/frs/download.php/9029/mongrel_status-0.1.tgz
Or just:
$ gem install mongrel_status
Enjoy! And feedback is welcome.
Zed A. Shaw
http://www.zedshaw.com/
Well I spent the weekend working on the Mongrel
(http://mongrel.rubyforge.org) plugin system, and actually ended up cracking
it out into a separate sub-project and releasing it under Ruby or LGPL.
The GemPlugin project is a dynamic plugin system that uses RubyGems to
create, manage, and load plugins. It's used in Mongrel to allow others to
create commands for people to use without having to be a part of the Mongrel
project. Other systems could use it no problem and it doesn't depend on any
Mongrel code.
The stuff is kind of funky, but take a look at:
http://mongrel.rubyforge.org/gem_plugin_rdoc/
For more information.
== Quick Usage
Plugin Authors do this:
class Snazzy < GemPlugin:lugin "/commands"
...
end
Then place this code in a file they will have RubyGems autorequire (I use
lib/init.rb).
Next they need to add the following to whatever Rakefile code you use to
create your gem:
spec.add_dependency('gem_plugin', '>= 0.1')
spec.add_dependency('theapp', '>= 0.1')
spec.autorequire = 'init.rb'
Plugin Users do this:
$ gem install snazzy_plugin
System Implementers then setup their system to do this:
GemPlugin::Manager.instance.load "theapp" => GemPlugin::INCLUDE
plug = GemPlugin::Manager.instance.create("/commands/snazzy")
And everyone is happy. Read the docs for more information.
== Future Directions
There is already a sample plugin available named mongrel_status which people
can check out as an example:
http://rubyforge.org/frs/download.php/9029/mongrel_status-0.1.tgz
Or just:
$ gem install mongrel_status
Enjoy! And feedback is welcome.
Zed A. Shaw
http://www.zedshaw.com/