Parent

Included Modules

Class/Module Index [+]

Quicksearch

Rails::Plugin

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

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"

Attributes

directory[R]
name[R]

Public Class Methods

new(directory) click to toggle source
# File lib/rails/plugin.rb, line 24
def initialize(directory)
  @directory = directory
  @name      = File.basename(@directory) rescue nil
  @loaded    = false
end

Public Instance Methods

<=>(other_plugin) click to toggle source
# File lib/rails/plugin.rb, line 56
def <=>(other_plugin)
  name <=> other_plugin.name
end
about() click to toggle source
# File lib/rails/plugin.rb, line 60
def about
  @about ||= load_about_information
end
controller_path() click to toggle source
# File lib/rails/plugin.rb, line 83
def controller_path
  File.join(directory, 'app', 'controllers')
end
engine?() click to toggle source

Engines are plugins with an app/ directory.

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

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
load_paths() click to toggle source

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
loaded?() click to toggle source
# File lib/rails/plugin.rb, line 52
def loaded?
  @loaded
end
locale_files() click to toggle source
# File lib/rails/plugin.rb, line 99
def locale_files
  Dir[ File.join(locale_path, '*.{rb,yml}') ]
end
locale_path() click to toggle source
# File lib/rails/plugin.rb, line 95
def locale_path
  File.join(directory, 'config', 'locales')
end
localized?() click to toggle source

Returns true if there is any localization file in locale_path

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

Returns true if the engine ships with a routing file

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.