tags:

views:

43

answers:

1

I have to develop a plugin based software in ruby. What's the best architeture tu use?

I am thinking about plugin like this, each in a separate .rb file:

class MyPlugin < Plugin

def info
 infos
end

def run
 # run
end
end

How i can write a plugin manager to call these plugins?

+1  A: 

You'd have to clearly define what "calling the plugins" exactly mean.

For start, you can check out here how to require all the files from a directory, put your plugins into a single directory and require them all.

Then you need to somehow pick which one to use, whether it be:

  • passing its classname as a string through a command line argument or a config file parameter, and looking for a class by that name using const_get, or
  • presenting a user a list of all plugins (all descendants of your Plugin class) - check out here how to do it

Finally, you instantiate your plugin and do whatever you need to do with it.

Mladen Jablanović