From 45e8cf59dfd6a66f996db1dc02c122bbc66b97aa Mon Sep 17 00:00:00 2001 From: wycats Date: Tue, 23 Mar 2010 16:34:02 -0700 Subject: init.rb in plugins is here to stay --- railties/lib/rails/engine.rb | 7 ------ railties/lib/rails/engine/configuration.rb | 36 ++++++++++++++---------------- railties/lib/rails/plugin.rb | 10 ++++----- 3 files changed, 22 insertions(+), 31 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 987573ea03..85b4ff8470 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -109,13 +109,6 @@ module Rails config.generators.templates.unshift(*paths.lib.templates.to_a) end - initializer :load_lib_initializers do |app| - paths.lib.rails.initializers.to_a.sort.each do |initializer| - config = app.config - eval(File.read(initializer), binding, initializer) - end - end - initializer :load_application_initializers do paths.config.initializers.to_a.sort.each do |initializer| load(initializer) diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 1996b2fb90..b8f1f1009c 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -14,25 +14,23 @@ module Rails def paths @paths ||= begin paths = Rails::Paths::Root.new(@root) - paths.app "app", :eager_load => true, :glob => "*" - paths.app.controllers "app/controllers", :eager_load => true - paths.app.helpers "app/helpers", :eager_load => true - paths.app.models "app/models", :eager_load => true - paths.app.mailers "app/mailers", :eager_load => true - paths.app.metals "app/metal", :eager_load => true - paths.app.views "app/views", :eager_load => true - paths.lib "lib", :load_path => true - paths.lib.rails "lib/rails", :glob => "**/*.rake" - paths.lib.rails.initializers "lib/rails/initializers", :glob => "**/*.rb" - paths.lib.tasks "lib/tasks", :glob => "**/*.rake" - paths.lib.templates "lib/templates" - paths.config "config" - paths.config.initializers "config/initializers", :glob => "**/*.rb" - paths.config.locales "config/locales", :glob => "*.{rb,yml}" - paths.config.routes "config/routes.rb" - paths.public "public" - paths.public.javascripts "public/javascripts" - paths.public.stylesheets "public/stylesheets" + paths.app "app", :eager_load => true, :glob => "*" + paths.app.controllers "app/controllers", :eager_load => true + paths.app.helpers "app/helpers", :eager_load => true + paths.app.models "app/models", :eager_load => true + paths.app.mailers "app/mailers", :eager_load => true + paths.app.metals "app/metal", :eager_load => true + paths.app.views "app/views", :eager_load => true + paths.lib "lib", :load_path => true + paths.lib.tasks "lib/tasks", :glob => "**/*.rake" + paths.lib.templates "lib/templates" + paths.config "config" + paths.config.initializers "config/initializers", :glob => "**/*.rb" + paths.config.locales "config/locales", :glob => "*.{rb,yml}" + paths.config.routes "config/routes.rb" + paths.public "public" + paths.public.javascripts "public/javascripts" + paths.public.stylesheets "public/stylesheets" paths end end diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index a08c5b9143..98f329cc17 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -47,11 +47,11 @@ module Rails end initializer :load_init_rb, :before => :load_application_initializers do |app| - lib_initializers = paths.lib.rails.initializers.to_a - files = %w(rails/init.rb init.rb).map { |path| File.expand_path(path, root) } - - if lib_initializers.empty? && initrb = files.find { |path| File.file?(path) } - ActiveSupport::Deprecation.warn "init.rb is deprecated: #{initrb}. Use lib/rails/initializers/#{name}.rb" + files = %w(rails/init.rb init.rb).map { |path| File.expand_path path, root } + if initrb = files.find { |path| File.file? path } + if initrb == files.first + ActiveSupport::Deprecation.warn "Use toplevel init.rb; rails/init.rb is deprecated: #{initrb}" + end config = app.config eval(File.read(initrb), binding, initrb) end -- cgit v1.2.3