2010-01-22 14:44:29 -05:00
|
|
|
require "active_support"
|
|
|
|
require "rails"
|
2010-06-20 08:44:38 -04:00
|
|
|
require "active_support/i18n_railtie"
|
2010-01-22 14:44:29 -05:00
|
|
|
|
2010-01-24 19:06:12 -05:00
|
|
|
module ActiveSupport
|
|
|
|
class Railtie < Rails::Railtie
|
2010-03-26 13:47:55 -04:00
|
|
|
config.active_support = ActiveSupport::OrderedOptions.new
|
2010-01-24 19:06:12 -05:00
|
|
|
|
|
|
|
# Loads support for "whiny nil" (noisy warnings when methods are invoked
|
|
|
|
# on +nil+ values) if Configuration#whiny_nils is true.
|
2010-01-26 15:05:50 -05:00
|
|
|
initializer "active_support.initialize_whiny_nils" do |app|
|
2010-01-24 19:06:12 -05:00
|
|
|
require 'active_support/whiny_nil' if app.config.whiny_nils
|
|
|
|
end
|
|
|
|
|
2010-06-29 15:18:17 -04:00
|
|
|
initializer "active_support.deprecation_behavior" do |app|
|
|
|
|
if deprecation = app.config.active_support.deprecation
|
|
|
|
ActiveSupport::Deprecation.behavior = deprecation
|
|
|
|
else
|
|
|
|
defaults = {"development" => :log,
|
|
|
|
"production" => :notify,
|
|
|
|
"test" => :stderr}
|
|
|
|
|
|
|
|
env = Rails.env
|
|
|
|
|
|
|
|
if defaults.key?(env)
|
|
|
|
msg = "You did not specify how you would like Rails to report " \
|
|
|
|
"deprecation notices for your #{env} environment, please " \
|
2010-06-29 22:50:41 -04:00
|
|
|
"set config.active_support.deprecation to :#{defaults[env]} " \
|
|
|
|
"at config/environments/#{env}.rb"
|
2010-06-29 15:18:17 -04:00
|
|
|
|
|
|
|
warn msg
|
|
|
|
ActiveSupport::Deprecation.behavior = defaults[env]
|
|
|
|
else
|
|
|
|
msg = "You did not specify how you would like Rails to report " \
|
|
|
|
"deprecation notices for your #{env} environment, please " \
|
2010-06-29 22:50:41 -04:00
|
|
|
"set config.active_support.deprecation to :log, :notify or " \
|
|
|
|
":stderr at config/environments/#{env}.rb"
|
2010-06-29 15:18:17 -04:00
|
|
|
|
|
|
|
warn msg
|
|
|
|
ActiveSupport::Deprecation.behavior = :stderr
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-01-24 19:06:12 -05:00
|
|
|
# Sets the default value for Time.zone
|
|
|
|
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
|
2010-01-26 15:05:50 -05:00
|
|
|
initializer "active_support.initialize_time_zone" do |app|
|
2010-01-24 19:06:12 -05:00
|
|
|
require 'active_support/core_ext/time/zones'
|
2011-04-04 18:33:29 -04:00
|
|
|
zone_default = Time.find_zone!(app.config.time_zone)
|
2010-01-24 19:06:12 -05:00
|
|
|
|
|
|
|
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
|
2010-06-29 22:50:41 -04:00
|
|
|
end
|