From: Michael Granger on 23 Mar 2010 17:05 Version 1.0.6 of pluginfactory has been released. PluginFactory is a mixin for adding plugin classes to your application. It adds a 'create' method to your base plugin class that can be used to search for/and load them later. For example, if you want pluggable 'driver' classes for your library, you can define the base class like so: require 'pluginfactory' class Driver include PluginFactory # Set one or more paths to use when searching for # 'Driver' plugins def self::derivative_dirs ["drivers"] end end Now, if someone wants to provide their own plugin, they just inherit from 'Driver' like so: require 'driver' class SpecialDriver < Driver # ...do special driver-ish things end saves it as `drivers/special.rb' (or one of several other variants) in their library, and then load it by name via the superclass: special = Driver.create( 'special' ) PluginFactory will search for the correct require, require your library, and create a new instance of the appropriate subclass. Any additional arguments to 'create' will be passed to the subclass's constructor. == Project Page http://deveiate.org/projects/PluginFactory/ == Installation Via gems: $ sudo gem install pluginfactory or from source: $ wget http://deveiate.org/code/pluginfactory-1.0.6.tar.gz $ tar -xzvf pluginfactory-1.0.6.tar.gz $ cd pluginfactory-1.0.6 $ sudo rake install == Changes Repackaging for newer Rubygems. This release contains no major code changes. -- Michael Granger <ged(a)FaerieMUD.org> Rubymage, Architect, Believer The FaerieMUD Consortium <http://faeriemud.org/>
|
Pages: 1 Prev: logging, rolling file, permission denied Next: SQLite3 Exception |