From 82b9b151ffde44305d67744c0bfd9bb5505f6fbe Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 6 Nov 2009 17:21:39 -0800 Subject: Refactor plugins --- railties/lib/rails/application.rb | 50 ++++++++++----------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) (limited to 'railties/lib/rails/application.rb') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index b43dcb0041..10cba8ab6c 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -23,10 +23,6 @@ module Rails @config = config end - def plugin_loader - @plugin_loader ||= config.plugin_loader.new(self) - end - def root config.root end @@ -37,7 +33,7 @@ module Rails end def initialize - run_initializers + run_initializers(self) end def config @@ -46,10 +42,6 @@ module Rails alias configuration config - def plugin_loader - self.class.plugin_loader - end - def middleware config.middleware end @@ -58,6 +50,18 @@ module Rails ActionController::Routing::Routes end + def initializers + initializers = super + plugins.each { |p| initializers += p.initializers } + initializers + end + + def plugins + @plugins ||= begin + Plugin::Vendored.all(config.plugins || [:all], config.paths.vendor.plugins) + end + end + def call(env) @app ||= middleware.build(routes) @app.call(env) @@ -111,13 +115,6 @@ module Rails config.load_once_paths.freeze end - # Adds all load paths from plugins to the global set of load paths, so that - # code from plugins can be required (explicitly or automatically via ActiveSupport::Dependencies). - initializer :add_plugin_load_paths do - require 'active_support/dependencies' - plugin_loader.add_plugin_load_paths - end - # Create tmp directories initializer :ensure_tmp_directories_exist do %w(cache pids sessions sockets).each do |dir_to_make| @@ -321,7 +318,6 @@ module Rails # TODO: Make Rails and metal work without ActionController if config.frameworks.include?(:action_controller) Rails::Rack::Metal.requested_metals = config.metals - Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths config.middleware.insert_before( :"ActionDispatch::ParamsParser", @@ -329,26 +325,6 @@ module Rails end end - # Loads all plugins in config.plugin_paths. plugin_paths - # defaults to vendor/plugins but may also be set to a list of - # paths, such as - # config.plugin_paths = ["#{config.root}/lib/plugins", "#{config.root}/vendor/plugins"] - # - # In the default implementation, as each plugin discovered in plugin_paths is initialized: - # * its +lib+ directory, if present, is added to the load path (immediately after the applications lib directory) - # * init.rb is evaluated, 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, only those plugins will be loaded - # and they plugins will be loaded in that order. Otherwise, plugins are loaded in alphabetical - # order. - # - # if config.plugins ends contains :all then the named plugins will be loaded in the given order and all other - # plugins will be loaded in alphabetical order - initializer :load_plugins do - plugin_loader.load_plugins - end - # # bail out if gems are missing - note that check_gem_dependencies will have # # already called abort() unless $gems_rake_task is set # return unless gems_dependencies_loaded -- cgit v1.2.3