diff options
author | Carl Lerche & Yehuda Katz <wycats@gmail.com> | 2009-04-13 15:18:45 -0700 |
---|---|---|
committer | Carl Lerche & Yehuda Katz <wycats@gmail.com> | 2009-04-13 15:18:45 -0700 |
commit | 906aebceedb95d8caa6db6314bc90f605bdfaf2b (patch) | |
tree | 5abc86bb6709b20df7cb5f4d1750b27c641dca4b /railties/lib/rails/plugin | |
parent | 2036d3ba75da1a0f3061bf5a33c89e2b2eaff420 (diff) | |
parent | c877857d59554d78dbf45f5f9fcaafb8badec4e2 (diff) | |
download | rails-906aebceedb95d8caa6db6314bc90f605bdfaf2b.tar.gz rails-906aebceedb95d8caa6db6314bc90f605bdfaf2b.tar.bz2 rails-906aebceedb95d8caa6db6314bc90f605bdfaf2b.zip |
Bring abstract_controller up to date with rails/master
Resolved all the conflicts since 2.3.0 -> HEAD. Following is a list
of commits that could not be applied cleanly or are obviated with the
abstract_controller refactor. They all need to be revisited to ensure
that fixes made in 2.3 do not reappear in 3.0:
2259ecf368e6a6715966f69216e3ee86bf1a82a7
AR not available
* This will be reimplemented with ActionORM or equivalent
06182ea02e92afad579998aa80144588e8865ac3
implicitly rendering a js response should not use the default layout
[#1844 state:resolved]
* This will be handled generically
893e9eb99504705419ad6edac14d00e71cef5f12
Improve view rendering performance in development mode and reinstate
template recompiling in production [#1909 state:resolved]
* We will need to reimplement rails-dev-boost on top of the refactor;
the changes here are very implementation specific and cannot be
cleanly applied. The following commits are implicated:
199e750d46c04970b5e7684998d09405648ecbd4
3942cb406e1d5db0ac00e03153809cc8dc4cc4db
f8ea9f85d4f1e3e6f3b5d895bef6b013aa4b0690
e3b166aab37ddc2fbab030b146eb61713b91bf55
ae9f258e03c9fd5088da12c1c6cd216cc89a01f7
44423126c6f6133a1d9cf1d0832b527e8711d40f
0cb020b4d6d838025859bd60fb8151c8e21b8e84
workaround for picking layouts based on wrong view_paths
[#1974 state:resolved]
* The specifics of this commit no longer apply. Since it is a two-line
commit, we will reimplement this change.
8c5cc66a831aadb159f3daaffa4208064c30af0e
make action_controller/layouts pick templates from the current instance's
view_paths instead of the class view_paths [#1974 state:resolved]
* This does not apply at all. It should be trivial to apply the feature
to the reimplemented ActionController::Base.
87e8b162463f13bd50d27398f020769460a770e3
fix HTML fallback for explicit templates [#2052 state:resolved]
* There were a number of patches related to this that simply compounded
each other. Basically none of them apply cleanly, and the underlying
issue needs to be revisited. After discussing the underlying problem
with Koz, we will defer these fixes for further discussion.
Diffstat (limited to 'railties/lib/rails/plugin')
-rw-r--r-- | railties/lib/rails/plugin/loader.rb | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/railties/lib/rails/plugin/loader.rb b/railties/lib/rails/plugin/loader.rb index be81bdf4fa..66e01d70da 100644 --- a/railties/lib/rails/plugin/loader.rb +++ b/railties/lib/rails/plugin/loader.rb @@ -16,7 +16,7 @@ module Rails def initialize(initializer) @initializer = initializer end - + # Returns the plugins to be loaded, in the order they should be loaded. def plugins @plugins ||= all_plugins.select { |plugin| should_load?(plugin) }.sort { |p1, p2| order_plugins(p1, p2) } @@ -32,9 +32,9 @@ module Rails @all_plugins ||= locate_plugins @all_plugins end - + def load_plugins - plugins.each do |plugin| + plugins.each do |plugin| plugin.load(initializer) register_plugin_as_loaded(plugin) end @@ -43,12 +43,12 @@ module Rails ensure_all_registered_plugins_are_loaded! end - + # Adds the load paths for every plugin into the $LOAD_PATH. Plugin load paths are # added *after* the application's <tt>lib</tt> directory, to ensure that an application # can always override code within a plugin. # - # Plugin load paths are also added to Dependencies.load_paths, and Dependencies.load_once_paths. + # Plugin load paths are also added to Dependencies.load_paths, and Dependencies.load_once_paths. def add_plugin_load_paths plugins.each do |plugin| plugin.load_paths.each do |path| @@ -56,7 +56,7 @@ module Rails ActiveSupport::Dependencies.load_paths << path - unless Rails.configuration.reload_plugins? + unless configuration.reload_plugins? ActiveSupport::Dependencies.load_once_paths << path end end @@ -64,8 +64,11 @@ module Rails $LOAD_PATH.uniq! end - - + + def engine_metal_paths + engines.collect(&:metal_path) + end + protected def configure_engines if engines.any? @@ -74,20 +77,22 @@ module Rails add_engine_view_paths end end - + def add_engine_routing_configurations engines.select(&:routed?).collect(&:routing_file).each do |routing_file| ActionController::Routing::Routes.add_configuration_file(routing_file) end end - + def add_engine_controller_paths ActionController::Routing.controller_paths += engines.collect(&:controller_path) end - + def add_engine_view_paths # reverse it such that the last engine can overwrite view paths from the first, like with routes - ActionController::Base.view_paths += ActionView::PathSet.new(engines.collect(&:view_path).reverse) + paths = ActionView::PathSet.new(engines.collect(&:view_path).reverse) + ActionController::Base.view_paths.concat(paths) + ActionMailer::Base.view_paths.concat(paths) if configuration.frameworks.include?(:action_mailer) end # The locate_plugins method uses each class in config.plugin_locators to @@ -106,7 +111,7 @@ module Rails def configuration initializer.configuration end - + def should_load?(plugin) # uses Plugin#name and Plugin#valid? enabled?(plugin) && plugin.valid? @@ -120,21 +125,21 @@ module Rails plugin_a <=> plugin_b else effective_order_of(plugin_a) <=> effective_order_of(plugin_b) - end + end end end - + def effective_order_of(plugin) if explicitly_enabled?(plugin) - registered_plugin_names.index(plugin.name) + registered_plugin_names.index(plugin.name) else registered_plugin_names.index('all') - end + end end def application_lib_index $LOAD_PATH.index(File.join(RAILS_ROOT, 'lib')) || 0 - end + end def enabled?(plugin) !explicit_plugin_loading_order? || registered?(plugin) @@ -155,32 +160,32 @@ module Rails def explicitly_registered?(plugin) explicit_plugin_loading_order? && registered_plugin_names.include?(plugin.name) end - + def registered_plugins_names_plugin?(plugin) registered_plugin_names.include?(plugin.name) || registered_plugin_names.include?('all') end - + # The plugins that have been explicitly listed with config.plugins. If this list is nil - # then it means the client does not care which plugins or in what order they are loaded, + # then it means the client does not care which plugins or in what order they are loaded, # so we load all in alphabetical order. If it is an empty array, we load no plugins, if it is # non empty, we load the named plugins in the order specified. def registered_plugin_names configuration.plugins ? configuration.plugins.map(&:to_s) : nil end - + def loaded?(plugin_name) initializer.loaded_plugins.detect { |plugin| plugin.name == plugin_name.to_s } end - + def ensure_all_registered_plugins_are_loaded! if explicit_plugin_loading_order? if configuration.plugins.detect {|plugin| plugin != :all && !loaded?(plugin) } - missing_plugins = configuration.plugins - (plugins + [:all]) - raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence}" + missing_plugins = configuration.plugins - (plugins.map{|p| p.name.to_sym} + [:all]) + raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence(:locale => :en)}" end end end - + end end -end
\ No newline at end of file +end |