The Plugin class should be an object which provides the following methods:

  • name - Used during initialisation to order the plugin (based on name and
                   the contents of <tt>config.plugins</tt>).
    
  • +valid?+ - Returns true if this plugin can be loaded.
  • load_paths - Each path within the returned array will be added to the $LOAD_PATH.
  • load - Finally ‘load’ the plugin.

These methods are expected by the Rails::Plugin::Locator and Rails::Plugin::Loader classes. The default implementation returns the lib directory as its load_paths, and evaluates init.rb when load is called.

You can also inspect the about.yml data programmatically:

  plugin = Rails::Plugin.new(path_to_my_plugin)
  plugin.about["author"] # => "James Adam"
  plugin.about["url"] # => "http://interblah.net"
Methods
Included Modules
Attributes
[R] directory
[R] name
Public Class methods
new(directory)
    # File railties/lib/rails/plugin.rb, line 24
24:     def initialize(directory)
25:       @directory = directory
26:       @name      = File.basename(@directory) rescue nil
27:       @loaded    = false
28:     end
Public Instance methods
<=>(other_plugin)
    # File railties/lib/rails/plugin.rb, line 56
56:     def <=>(other_plugin)
57:       name <=> other_plugin.name
58:     end
about()
    # File railties/lib/rails/plugin.rb, line 60
60:     def about
61:       @about ||= load_about_information
62:     end
controller_path()
    # File railties/lib/rails/plugin.rb, line 83
83:     def controller_path
84:       File.join(directory, 'app', 'controllers')
85:     end
engine?()

Engines are plugins with an app/ directory.

    # File railties/lib/rails/plugin.rb, line 65
65:     def engine?
66:       has_app_directory?
67:     end
load(initializer)

Evaluates a plugin‘s init.rb file.

    # File railties/lib/rails/plugin.rb, line 45
45:     def load(initializer)
46:       return if loaded?
47:       report_nonexistant_or_empty_plugin! unless valid?
48:       evaluate_init_rb(initializer)
49:       @loaded = true
50:     end
load_paths()

Returns a list of paths this plugin wishes to make available in $LOAD_PATH.

    # File railties/lib/rails/plugin.rb, line 35
35:     def load_paths
36:       report_nonexistant_or_empty_plugin! unless valid?
37:       
38:       [].tap do |load_paths|
39:         load_paths << lib_path  if has_lib_directory?
40:         load_paths << app_paths if has_app_directory?
41:       end.flatten
42:     end
loaded?()
    # File railties/lib/rails/plugin.rb, line 52
52:     def loaded?
53:       @loaded
54:     end
locale_files()
     # File railties/lib/rails/plugin.rb, line 99
 99:     def locale_files
100:       Dir[ File.join(locale_path, '*.{rb,yml}') ]
101:     end
locale_path()
    # File railties/lib/rails/plugin.rb, line 95
95:     def locale_path
96:       File.join(directory, 'config', 'locales')
97:     end
localized?()

Returns true if there is any localization file in locale_path

    # File railties/lib/rails/plugin.rb, line 75
75:     def localized?
76:       locale_files.any?
77:     end
metal_path()
    # File railties/lib/rails/plugin.rb, line 87
87:     def metal_path
88:       File.join(directory, 'app', 'metal')
89:     end
routed?()

Returns true if the engine ships with a routing file

    # File railties/lib/rails/plugin.rb, line 70
70:     def routed?
71:       File.exist?(routing_file)
72:     end
routing_file()
    # File railties/lib/rails/plugin.rb, line 91
91:     def routing_file
92:       File.join(directory, 'config', 'routes.rb')
93:     end
valid?()
    # File railties/lib/rails/plugin.rb, line 30
30:     def valid?
31:       File.directory?(directory) && (has_app_directory? || has_lib_directory? || has_init_file?)
32:     end
view_path()
    # File railties/lib/rails/plugin.rb, line 79
79:     def view_path
80:       File.join(directory, 'app', 'views')
81:     end