From c8cc8a987213bf90fe6922517d52befb7c0587a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 22 Jan 2010 20:44:29 +0100 Subject: Moved more configuration away from bootstrap. --- activesupport/lib/active_support/railtie.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 activesupport/lib/active_support/railtie.rb (limited to 'activesupport') diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb new file mode 100644 index 0000000000..18e404f002 --- /dev/null +++ b/activesupport/lib/active_support/railtie.rb @@ -0,0 +1,29 @@ +require "active_support" +require "rails" + +module ActiveSupport + class Railtie < Rails::Railtie + plugin_name :active_support + + # Loads support for "whiny nil" (noisy warnings when methods are invoked + # on +nil+ values) if Configuration#whiny_nils is true. + initializer :initialize_whiny_nils do |app| + require 'active_support/whiny_nil' if app.config.whiny_nils + end + + # Sets the default value for Time.zone + # If assigned value cannot be matched to a TimeZone, an exception will be raised. + initializer :initialize_time_zone do |app| + require 'active_support/core_ext/time/zones' + zone_default = Time.__send__(:get_zone, app.config.time_zone) + + unless zone_default + raise \ + 'Value assigned to config.time_zone not recognized.' + + 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.' + end + + Time.zone_default = zone_default + end + end +end \ No newline at end of file -- cgit v1.2.3 From 98240c49b05093d6d14b9384a9bd695b58eefb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 23 Jan 2010 01:29:29 +0100 Subject: Get rid of initializers global and create i18n railtie. --- activesupport/lib/active_support/railtie.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index 18e404f002..d443e0e997 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -1,6 +1,35 @@ require "active_support" require "rails" +module I18n + class Railtie < Rails::Railtie + plugin_name :i18n + + # Initialize I18n load paths to an array + config.i18n.load_path = [] + + initializer :initialize_i18n do + require 'active_support/i18n' + + ActionDispatch::Callbacks.to_prepare do + I18n.reload! + end + end + + # Set the i18n configuration from config.i18n but special-case for + # the load_path which should be appended to what's already set instead of overwritten. + config.after_initialize do |app| + app.config.i18n.each do |setting, value| + if setting == :load_path + I18n.load_path += value + else + I18n.send("#{setting}=", value) + end + end + end + end +end + module ActiveSupport class Railtie < Rails::Railtie plugin_name :active_support -- cgit v1.2.3 From 5cd9aad4fdf55c591fe8e12657008e83315251d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 24 Jan 2010 10:27:42 +0100 Subject: Add I18n tests to engines. --- activesupport/lib/active_support/railtie.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index d443e0e997..74cc72eff1 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -26,6 +26,8 @@ module I18n I18n.send("#{setting}=", value) end end + + I18n.reload! end end end -- cgit v1.2.3 From e548f96b1d5cb6529dd6fbc6544f03a3a840b48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 24 Jan 2010 12:23:21 +0100 Subject: Rename plugin_name to railtie_name and engine_name. --- activesupport/lib/active_support/railtie.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index 74cc72eff1..55608ac1c5 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -3,7 +3,7 @@ require "rails" module I18n class Railtie < Rails::Railtie - plugin_name :i18n + railtie_name :i18n # Initialize I18n load paths to an array config.i18n.load_path = [] @@ -34,7 +34,7 @@ end module ActiveSupport class Railtie < Rails::Railtie - plugin_name :active_support + railtie_name :active_support # Loads support for "whiny nil" (noisy warnings when methods are invoked # on +nil+ values) if Configuration#whiny_nils is true. -- cgit v1.2.3