From 64ea3dfd9f14b09b65905a10379050ba2f42d8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 27 Jan 2010 18:56:31 +0100 Subject: [PATCH] Add reloadable specific for engines and move environment to application paths. Signed-off-by: Carl Lerche --- railties/lib/rails/application/configuration.rb | 9 ++++----- railties/lib/rails/engine.rb | 2 +- railties/lib/rails/engine/configuration.rb | 1 - railties/lib/rails/plugin.rb | 6 ++++++ railties/test/railties/configuration_test.rb | 6 +++--- railties/test/railties/engine_test.rb | 4 ++++ railties/test/railties/plugin_test.rb | 4 ++++ railties/test/railties/shared_tests.rb | 2 +- 8 files changed, 23 insertions(+), 11 deletions(-) diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index aaf18b5f51..31787b5cc9 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -8,14 +8,16 @@ module Rails attr_accessor :cache_classes, :cache_store, :colorize_logging, :consider_all_requests_local, :dependency_loading, :filter_parameters, :log_level, :logger, :metals, - :plugins, :preload_frameworks, :reload_plugins, + :plugins, :preload_frameworks, :reload_engines, :reload_plugins, :serve_static_assets, :time_zone, :whiny_nils def initialize(*) super + @colorize_logging = true @filter_parameters = [] @dependency_loading = true @serve_static_assets = true + @time_zone = "UTC" end def paths @@ -23,6 +25,7 @@ module Rails paths = super paths.app.controllers << builtin_controller if builtin_controller paths.config.database "config/database.yml" + paths.config.environment "config/environments", :glob => "#{Rails.env}.rb" paths.log "log/#{Rails.env}.log" paths.tmp "tmp" paths.tmp.cache "tmp/cache" @@ -76,10 +79,6 @@ module Rails def log_level @log_level ||= Rails.env.production? ? :info : :debug end - - def time_zone - @time_zone ||= "UTC" - end end end end \ No newline at end of file diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index b98393c01a..33d62c8155 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -124,7 +124,7 @@ module Rails protected def reloadable?(app) - app.config.reload_plugins + app.config.reload_engines end end end \ No newline at end of file diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index c4e34b11b8..7d6de91430 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -22,7 +22,6 @@ module Rails paths.lib "lib", :load_path => true paths.lib.tasks "lib/tasks", :glob => "**/*.rake" paths.config "config" - paths.config.environment "config/environments", :glob => "#{Rails.env}.rb" paths.config.initializers "config/initializers", :glob => "**/*.rb" paths.config.locales "config/locales", :glob => "*.{rb,yml}" paths.config.routes "config/routes.rb" diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 4c73809177..881c97f02d 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -54,5 +54,11 @@ module Rails raise "\"#{name}\" is a Railtie/Engine and cannot be installed as plugin" end end + + protected + + def reloadable?(app) + app.config.reload_plugins + end end end diff --git a/railties/test/railties/configuration_test.rb b/railties/test/railties/configuration_test.rb index c5ff6dad9c..17ea526bbf 100644 --- a/railties/test/railties/configuration_test.rb +++ b/railties/test/railties/configuration_test.rb @@ -18,13 +18,13 @@ module RailtiesTest assert_equal "hello", Foo.config.foo.greetings end - test "plugin configurations are available in the application" do + test "railtie configurations are available in the application" do class Foo < Rails::Railtie ; config.foo.greetings = "hello" ; end require "#{app_path}/config/application" assert_equal "hello", AppTemplate::Application.config.foo.greetings end - test "plugin config merges are deep" do + test "railtie config merges are deep" do class Foo < Rails::Railtie ; config.foo.greetings = 'hello' ; end class Bar < Rails::Railtie config.foo.bar = "bar" @@ -33,7 +33,7 @@ module RailtiesTest assert_equal "bar", Bar.config.foo.bar end - test "plugin can add subscribers" do + test "railtie can add subscribers" do begin class Foo < Rails::Railtie; subscriber(Rails::Subscriber.new); end assert_kind_of Rails::Subscriber, Rails::Subscriber.subscribers[:foo] diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 374f5ea93c..6f49ebcf1b 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -19,5 +19,9 @@ module RailtiesTest plugin.write "lib/another.rb", "class Another; end" end end + + def reload_config + :reload_engines + end end end diff --git a/railties/test/railties/plugin_test.rb b/railties/test/railties/plugin_test.rb index 0adc31e3ed..a29186f14a 100644 --- a/railties/test/railties/plugin_test.rb +++ b/railties/test/railties/plugin_test.rb @@ -15,6 +15,10 @@ module RailtiesTest end end + def reload_config + :reload_plugins + end + test "plugin can load the file with the same name in lib" do boot_rails require "bukkits" diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb index fc4a19e7e7..2483fa47fd 100644 --- a/railties/test/railties/shared_tests.rb +++ b/railties/test/railties/shared_tests.rb @@ -31,7 +31,7 @@ module RailtiesTest def test_plugin_constants_get_reloaded_if_config_reload_plugins add_to_config <<-RUBY - config.reload_plugins = true + config.#{reload_config} = true RUBY boot_rails