Module CodeRay::Plugin
In: lib/coderay/helpers/plugin.rb

Plugin

 Plugins have to include this module.

 IMPORTANT: use extend for this module.

 Example: see PluginHost.

Methods

Public Instance methods

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.

[Source]

     # File lib/coderay/helpers/plugin.rb, line 304
304:   def helper *helpers
305:     for helper in helpers
306:       self::PLUGIN_HOST.require_helper plugin_id, helper.to_s
307:     end
308:   end

[Source]

     # File lib/coderay/helpers/plugin.rb, line 268
268:   def included mod
269:     warn "#{name} should not be included. Use extend."
270:   end

The host for this Plugin class.

[Source]

     # File lib/coderay/helpers/plugin.rb, line 285
285:   def plugin_host host = nil
286:     if host and not host.is_a? PluginHost
287:       raise ArgumentError,
288:         "PluginHost expected, but #{host.class} given."
289:     end
290:     self.const_set :PLUGIN_HOST, host if host
291:     self::PLUGIN_HOST
292:   end

Returns the pulgin id used by the engine.

[Source]

     # File lib/coderay/helpers/plugin.rb, line 311
311:   def plugin_id
312:     name[/[\w_]+$/].downcase
313:   end

Register this class for the given langs. Example:

  class MyPlugin < PluginHost::BaseClass
    register_for :my_id
    ...
  end

See PluginHost.register.

[Source]

     # File lib/coderay/helpers/plugin.rb, line 280
280:   def register_for *ids
281:     plugin_host.register self, *ids
282:   end

[Validate]