Files

Class Index [+]

Quicksearch

CodeRay::Plugin

Plugin

 Plugins have to include this module.

 IMPORTANT: use extend for this module.

 Example: see PluginHost.

Public Instance Methods

helper(*helpers) click to toggle source

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.

You can also load a helper from a different plugin:

 helper 'other_plugin/helper_name'
     # File lib/coderay/helpers/plugin.rb, line 318
318:   def helper *helpers
319:     for helper in helpers
320:       if helper.is_a?(String) && helper[/\//]
321:         self::PLUGIN_HOST.require_helper $`, $'
322:       else
323:         self::PLUGIN_HOST.require_helper plugin_id, helper.to_s
324:       end
325:     end
326:   end
included(mod) click to toggle source
     # File lib/coderay/helpers/plugin.rb, line 268
268:   def included mod
269:     warn "#{name} should not be included. Use extend."
270:   end
plugin_host(host = nil) click to toggle source

The host for this Plugin class.

     # File lib/coderay/helpers/plugin.rb, line 295
295:   def plugin_host host = nil
296:     if host and not host.is_a? PluginHost
297:       raise ArgumentError,
298:         "PluginHost expected, but #{host.class} given."
299:     end
300:     self.const_set :PLUGIN_HOST, host if host
301:     self::PLUGIN_HOST
302:   end
plugin_id() click to toggle source

Returns the pulgin id used by the engine.

     # File lib/coderay/helpers/plugin.rb, line 329
329:   def plugin_id
330:     name[/\w+$/].downcase
331:   end
register_for(*ids) click to toggle source

Register this class for the given langs. Example:

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

See PluginHost.register.

     # File lib/coderay/helpers/plugin.rb, line 280
280:   def register_for *ids
281:     plugin_host.register self, *ids
282:   end
title(title = nil) click to toggle source

Returns the title of the plugin, or sets it to the optional argument title.

     # File lib/coderay/helpers/plugin.rb, line 286
286:   def title title = nil
287:     if title
288:       @title = title.to_s
289:     else
290:       @title ||= name[/([^:]+)$/, 1]
291:     end
292:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.