I’m writing an application in Ruby which should be easy to extend. One
should be able to write a plugin for this application and should be able
to load it with an entry in the config file, e.g.
Load ContentFilter
Perl I would use eval statements like
eval “use $modname”;
die $@ if $@;
to load the plugin. In Perl the plugin would look like the following:
I’m writing an application in Ruby which should be easy to extend. One
should be able to write a plugin for this application and should be able
to load it with an entry in the config file, e.g.
[snip]
What’s the “ruby way” to do this?
Greetings,
CK
Maybe you can have a look at the rbot source code
(http://www.linuxbrit.co.uk) which has a quite good system of plugin
auto discovery (and reload too)
HTH,
Pierre Baillet
It is a good viewpoint to see the world as a dream. When you have something
like a nightmare, you will wake up and tell yourself that it was only a dream.
It is said that the world we live in is not a bit different from this.
Ghost Dog - The Way of the Samouraï
I’m writing an application in Ruby which should be easy to extend. One
should be able to write a plugin for this application and should be able
to load it with an entry in the config file, e.g.
Load ContentFilter
Perl I would use eval statements like
eval “use $modname”;
die $@ if $@;
to load the plugin. In Perl the plugin would look like the following:
push @{$main::Plugins->{state}},new Module;
package Module;
sub new() {
}
…
1;
What’s the “ruby way” to do this?
Assuming the config file is evaluated as ruby code you can do:
15:33:28 [temp]: for file in PluginBase.rb SomePlugin.rb config.rb
application.rb ; do echo “---- $file ----” ; cat “$file” ; done
---- PluginBase.rb ----
class PluginBase
end