diff options
Diffstat (limited to 'railties/lib/initializer.rb')
-rw-r--r-- | railties/lib/initializer.rb | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index f4e7a7ceb5..908dde71c2 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -48,7 +48,7 @@ module Rails # instance. def initialize(configuration) @configuration = configuration - @loaded_plugins = [] + @loaded_plugins = Set.new end # Sequentially step through all of the available initialization routines, @@ -176,21 +176,9 @@ 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 - # order. + # Plugins are loaded in alphabetical order. def load_plugins - if configuration.plugins.nil? - # a nil value implies we don't care about plugins; load 'em all in a reliable order - find_plugins(configuration.plugin_paths).sort.each { |path| load_plugin path } - elsif !configuration.plugins.empty? - # we've specified a config.plugins array, so respect that order - plugin_paths = find_plugins(configuration.plugin_paths) - configuration.plugins.each do |name| - path = plugin_paths.find { |p| File.basename(p) == name } - load_plugin path - end - end + find_plugins(configuration.plugin_paths).sort.each { |path| load_plugin path } $LOAD_PATH.uniq! end @@ -357,7 +345,7 @@ module Rails end def plugin_enabled?(path) - configuration.plugins.nil? || configuration.plugins.include?(File.basename(path)) + configuration.plugins.empty? || configuration.plugins.include?(File.basename(path)) end # Load the plugin at <tt>path</tt> unless already loaded. @@ -376,7 +364,7 @@ module Rails # Catch nonexistent and empty plugins. raise LoadError, "No such plugin: #{directory}" unless plugin_path?(directory) - lib_path = File.join(directory, 'lib', '') + lib_path = File.join(directory, 'lib') init_path = File.join(directory, 'init.rb') has_lib = File.directory?(lib_path) has_init = File.file?(init_path) @@ -482,9 +470,7 @@ module Rails # any method of +nil+. Set to +false+ for the standard Ruby behavior. attr_accessor :whiny_nils - # The list of plugins to load. If this is set to <tt>nil</tt>, all plugins will - # be loaded. If this is set to <tt>[]</tt>, no plugins will be loaded. Otherwise, - # plugins will be loaded in the order specified. + # The list of plugins to load. If this is set to <tt>[]</tt>, all plugins will be loaded. attr_accessor :plugins # The path to the root of the plugins directory. By default, it is in @@ -606,6 +592,7 @@ module Rails vendor ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } + paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] paths.concat builtin_directories end @@ -655,7 +642,7 @@ module Rails end def default_plugins - nil + [] end def default_plugin_paths |