Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move responsibility for ensuring that all registered gems were loaded…

… from the FileSystemLocator into the Initializer once all locators have had a chance to load the gems they located. [Marcel Molina Jr.]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6292 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 9f53e09eb9b4eb2e1711a8e92b7244a1f1301bbc 1 parent 3d2c232
Marcel Molina authored
11 railties/lib/initializer.rb
View
@@ -192,6 +192,7 @@ def load_plugins
plugin.load
end
end
+ ensure_all_registered_plugins_are_loaded!
$LOAD_PATH.uniq!
end
@@ -339,6 +340,16 @@ def load_application_initializers
load(initializer)
end
end
+
+ private
+ def ensure_all_registered_plugins_are_loaded!
+ unless configuration.plugins.nil?
+ unless loaded_plugins == configuration.plugins
+ missing_plugins = configuration.plugins - loaded_plugins
+ raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence}"
+ end
+ end
+ end
end
# The Configuration class holds all the parameters for the Initializer and
16 railties/lib/plugin/locator.rb
View
@@ -29,27 +29,11 @@ def located_plugins
class FileSystemLocator < Locator
private
def located_plugins
- returning locate_plugins do |loaders|
- ensure_all_registered_plugins_are_loaded!(loaders)
- end
- end
-
- def locate_plugins
initializer.configuration.plugin_paths.flatten.inject([]) do |plugins, path|
plugins.concat locate_plugins_under(path)
plugins
end.flatten
end
-
- def ensure_all_registered_plugins_are_loaded!(loaders)
- registered_plugins = initializer.configuration.plugins
- unless registered_plugins.nil? || registered_plugins.empty?
- missing_plugins = registered_plugins - loaders.map(&:name)
- unless missing_plugins.empty?
- raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence}"
- end
- end
- end
# This starts at the base path looking for directories that pass the plugin_path? test of the Plugin::Loader.
# Since plugins can be nested arbitrarily deep within an unspecified number of intermediary directories,
16 railties/test/plugin_locator_test.rb
View
@@ -21,21 +21,21 @@ def test_only_the_specified_plugins_are_located_in_the_order_listed
assert_equal plugin_names, @locator.plugin_names
end
+ def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
+ failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+ assert_equal %w(a acts_as_chunky_bacon plugin_with_no_lib_dir stubby), @locator.plugin_names, failure_tip
+ end
+
+
def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error
only_load_the_following_plugins! %w(stubby acts_as_a_non_existant_plugin)
assert_raises(LoadError) do
- @locator.plugins
+ @initializer.load_plugins
end
end
- def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_equal %w(a acts_as_chunky_bacon plugin_with_no_lib_dir stubby), @locator.plugin_names, failure_tip
- end
-
private
def new_locator(initializer = @initializer)
Rails::Plugin::FileSystemLocator.new(initializer)
- end
-
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.