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"
# File lib/rails/plugin.rb, line 56 def <=>(other_plugin) name <=> other_plugin.name end
# File lib/rails/plugin.rb, line 60 def about @about ||= load_about_information end
# File lib/rails/plugin.rb, line 83 def controller_path File.join(directory, 'app', 'controllers') end
Engines are plugins with an app/ directory.
# File lib/rails/plugin.rb, line 65 def engine? has_app_directory? end
Evaluates a plugin's init.rb file.
# File 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
Returns a list of paths this plugin wishes to make available in $LOAD_PATH.
# File 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
# File lib/rails/plugin.rb, line 99 def locale_files Dir[ File.join(locale_path, '*.{rb,yml}') ] end
# File lib/rails/plugin.rb, line 95 def locale_path File.join(directory, 'config', 'locales') end
Returns true if there is any localization file in locale_path
# File lib/rails/plugin.rb, line 75 def localized? locale_files.any? end
# File lib/rails/plugin.rb, line 87 def metal_path File.join(directory, 'app', 'metal') end
Returns true if the engine ships with a routing file
# File lib/rails/plugin.rb, line 70 def routed? File.exist?(routing_file) end
# File lib/rails/plugin.rb, line 91 def routing_file File.join(directory, 'config', 'routes.rb') end
Generated with the Darkfish Rdoc Generator 2.