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 libdirectory as its load_paths, and evaluates init.rbwhen loadis 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
#
A
C
E
L
M
N
R
V
Included Modules
Attributes
[R] directory
[R] name
Class Public methods
new(directory)
# File railties/lib/rails/plugin.rb, line 24
def initialize(directory)
  @directory = directory
  @name      = File.basename(@directory) rescue nil
  @loaded    = false
end
Instance Public methods
<=>(other_plugin)
# File railties/lib/rails/plugin.rb, line 56
def <=>(other_plugin)
  name <=> other_plugin.name
end
about()
# File railties/lib/rails/plugin.rb, line 60
def about
  @about ||= load_about_information
end
controller_path()
# File railties/lib/rails/plugin.rb, line 83
def controller_path
  File.join(directory, 'app', 'controllers')
end
engine?()

Engines are plugins with an app/ directory.

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

Evaluates a plugin's init.rb file.

# File railties/lib/rails/plugin.rb, line 45
def load(initializer)
  return if loaded?
  report_nonexistant_or_empty_plugin! unless valid?
  evaluate_init_rb(initializer)
  @loaded = true
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
def load_paths
  report_nonexistant_or_empty_plugin! unless valid?
  [].tap do |load_paths|
    load_paths << lib_path  if has_lib_directory?
    load_paths << app_paths if has_app_directory?
  end.flatten
end
loaded?()
# File railties/lib/rails/plugin.rb, line 52
def loaded?
  @loaded
end
locale_files()
# File railties/lib/rails/plugin.rb, line 99
def locale_files
  Dir[ File.join(locale_path, '*.{rb,yml}') ]
end
locale_path()
# File railties/lib/rails/plugin.rb, line 95
def locale_path
  File.join(directory, 'config', 'locales')
end
localized?()

Returns true if there is any localization file in #locale_path

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

Returns true if the engine ships with a routing file

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