Permalink
Browse files

init.rb in plugins is here to stay

  • Loading branch information...
wycats committed Mar 23, 2010
1 parent b92963f commit 45e8cf59dfd6a66f996db1dc02c122bbc66b97aa
@@ -109,13 +109,6 @@ def load_tasks
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)
@@ -14,25 +14,23 @@ def initialize(root=nil)
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
@@ -47,11 +47,11 @@ def config
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
@@ -94,19 +94,6 @@ class Engine < Rails::Engine
assert rescued, "Expected boot rails to fail"
end
- test "skips init.rb if initializer is present" do
- @plugin.write "lib/rails/initializers/foo.rb", <<-RUBY
- $loaded = true
- RUBY
-
- @plugin.write "init.rb", <<-RUBY
- raise "b00m"
- RUBY
-
- boot_rails
- assert $loaded
- end
-
test "loads deprecated rails/init.rb" do
@plugin.write "rails/init.rb", <<-RUBY
$loaded = true
@@ -297,16 +297,6 @@ def test_plugin_initializers
assert $plugin_initializer
end
- def test_rails_plugin_initializers
- $plugin_initializer = false
- @plugin.write "lib/rails/initializers/foo.rb", <<-RUBY
- $plugin_initializer = true
- RUBY
-
- boot_rails
- assert $plugin_initializer
- end
-
def test_plugin_midleware_referenced_in_configuration
@plugin.write "lib/bukkits.rb", <<-RUBY
class Bukkits

0 comments on commit 45e8cf5

Please sign in to comment.