./lib/coderay/helpers/plugin.rb in coderay-0.5.0.100 vs ./lib/coderay/helpers/plugin.rb in coderay-0.5.0.115

- old
+ new

@@ -1,8 +1,8 @@ # = PluginHost # -# $Id: plugin.rb 100 2005-12-10 04:20:30Z murphy $ +# $Id: plugin.rb 105 2006-02-20 01:41:40Z murphy $ # # A simple subclass plugin system. # # Example: # class Generators < PluginHost @@ -176,16 +176,17 @@ map.inspect end # Loads the map file (see map). # - # This is done automatically when plaugin_path is called. + # This is done automatically when plugin_path is called. def load_map - begin - require path_to('_map') - rescue LoadError - warn 'no _map.rb found for %s' % name if $DEBUG + mapfile = path_to '_map' + if File.exist? mapfile + require mapfile + elsif $DEBUG + warn 'no _map.rb found for %s' % name end end # Returns an array of all .rb files in the plugin path. # @@ -268,15 +269,26 @@ end self.const_set :PLUGIN_HOST, host if host self::PLUGIN_HOST end + # Require some helper files. + # + # Example: + # + # class MyPlugin < PluginHost::BaseClass + # register_for :my_id + # helper :my_helper + # + # The above example loads the file myplugin/my_helper.rb relative to the + # file in which MyPlugin was defined. def helper *helpers for helper in helpers self::PLUGIN_HOST.require_helper plugin_id, helper.to_s end end + # Returns the pulgin id used by the engine. def plugin_id name[/[\w_]+$/].downcase end end