Introducing reverse_require 0.0.9

For those who want a plug-in system for their RubyGem (so that others could easily extend it’s functionality) there’s not a lot of options out there. The obvious candidate for plug-in loading is gem_plugin, which was designed for and primarily used by Mongrel. Those who don’t quite feel that gem_plugin is flexible enough usually roll their own (Rails for example).

Now there’s another option between the extremes of gem_plugin and designing yet another custom plug-in system, reverse_require.

reverse_require requires specific files from the gems which depend on a
certain RubyGem and contain the specified path. Using reverse_require one
can allow others to easily extend the functionality of a RubyGem. Simply add
reverse_require into the code of your RubyGem:

reverse_require 'my_gem', 'some/path'

Then other gems which depend upon my_gem merely have to provide
some/path within their lib/ directory, and
reverse_require will load them all at run-time. The rest of the plug-in rigging is left up to the developer.


About this entry