aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/initializer.rb
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2007-03-02 23:39:29 +0000
committerMarcel Molina <marcel@vernix.org>2007-03-02 23:39:29 +0000
commit15c466dd729e744379380d08b8c25b9860fd836d (patch)
tree1adf48f88b4cb7d7d98e939584f6c3c7a304bba5 /railties/lib/initializer.rb
parentb0e1430c523cf09155f72d5996be2cc2bf8e2eb7 (diff)
downloadrails-15c466dd729e744379380d08b8c25b9860fd836d.tar.gz
rails-15c466dd729e744379380d08b8c25b9860fd836d.tar.bz2
rails-15c466dd729e744379380d08b8c25b9860fd836d.zip
Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6290 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/initializer.rb')
-rw-r--r--railties/lib/initializer.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index b2b7b3b545..36797026c4 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -2,7 +2,7 @@ require 'logger'
require 'set'
require File.join(File.dirname(__FILE__), 'railties_path')
require File.join(File.dirname(__FILE__), 'rails/version')
-require File.join(File.dirname(__FILE__), 'plugin/locater')
+require File.join(File.dirname(__FILE__), 'plugin/locator')
require File.join(File.dirname(__FILE__), 'plugin/loader')
@@ -183,12 +183,14 @@ module Rails
# * evaluate <tt>init.rb</tt> if present
#
# After all plugins are loaded, duplicates are removed from the load path.
- # If an array of plugin names is specified in config.plugins, the plugins
- # will be loaded in that order. Otherwise, plugins are loaded in alphabetical
+ # If an array of plugin names is specified in config.plugins, only those plugins will be loaded
+ # and they plugins will be loaded in that order. Otherwise, plugins are loaded in alphabetical
# order.
def load_plugins
- Plugin::Locater.new(self).each do |plugin|
- plugin.load
+ configuration.plugin_locators.each do |locator|
+ locator.new(self).each do |plugin|
+ plugin.load
+ end
end
$LOAD_PATH.uniq!
end
@@ -429,6 +431,12 @@ module Rails
# <tt>vendor/plugins</tt>.
attr_accessor :plugin_paths
+ # The classes that handle finding the desired plugins that you'd like to load for
+ # your application. By default it is the Rails::Plugin::FileSystemLocator which finds
+ # plugins to load in <tt>vendor/plugins</tt>. You can hook into gem location by subclassing
+ # Rails::Plugin::Locator and adding it onto the list of <tt>plugin_locators</tt>.
+ attr_accessor :plugin_locators
+
# The class that handles loading each plugin. Defaults to Rails::Plugin::Loader, but
# a sub class would have access to fine grained modification of the loading behavior. See
# the implementation of Rails::Plugin::Loader for more details.
@@ -449,6 +457,7 @@ module Rails
self.whiny_nils = default_whiny_nils
self.plugins = default_plugins
self.plugin_paths = default_plugin_paths
+ self.plugin_locators = default_plugin_locators
self.plugin_loader = default_plugin_loader
self.database_configuration_file = default_database_configuration_file
@@ -605,6 +614,10 @@ module Rails
["#{root_path}/vendor/plugins"]
end
+ def default_plugin_locators
+ [Plugin::FileSystemLocator]
+ end
+
def default_plugin_loader
Plugin::Loader
end