From 1a275730b290c1f06d4e8df680d22ae1b41ab585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 12 Jan 2010 14:11:47 +0100 Subject: Set deprecation warnings for RAILS_ENV and RAILS_DEFAULT_LOGGER. --- railties/lib/rails/bootstrap.rb | 8 -------- railties/lib/rails/deprecation.rb | 34 ++++++++++++++++++++++++++++++++-- railties/lib/rails/tasks/misc.rake | 1 + 3 files changed, 33 insertions(+), 10 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/bootstrap.rb b/railties/lib/rails/bootstrap.rb index 99a5ddeb8a..5d9165bf9a 100644 --- a/railties/lib/rails/bootstrap.rb +++ b/railties/lib/rails/bootstrap.rb @@ -38,11 +38,6 @@ module Rails config.load_once_paths.freeze end - # TODO: Wrap in deprecation warning, everyone should be using Rails.env now - initializer :set_rails_env do - silence_warnings { Object.const_set "RAILS_ENV", Rails.env } - end - # Create tmp directories initializer :ensure_tmp_directories_exist do %w(cache pids sessions sockets).each do |dir_to_make| @@ -83,9 +78,6 @@ module Rails ) logger end - - # TODO: Wrap it in a deprecation proxy - silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", Rails.logger } end # Sets the logger for Active Record, Action Controller, and Action Mailer diff --git a/railties/lib/rails/deprecation.rb b/railties/lib/rails/deprecation.rb index 155166a113..43f08d13df 100644 --- a/railties/lib/rails/deprecation.rb +++ b/railties/lib/rails/deprecation.rb @@ -6,8 +6,8 @@ RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do Rails.root end - def replace(val) - puts OMG + def replace(*args) + warn(caller, :replace, *args) end def warn(callstack, called, args) @@ -15,3 +15,33 @@ RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do ActiveSupport::Deprecation.warn(msg, callstack) end end).new + +RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do + def target + Rails.env + end + + def replace(*args) + warn(caller, :replace, *args) + end + + def warn(callstack, called, args) + msg = "RAILS_ENV is deprecated! Use Rails.env instead." + ActiveSupport::Deprecation.warn(msg, callstack) + end +end).new + +RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do + def target + Rails.logger + end + + def replace(*args) + warn(caller, :replace, *args) + end + + def warn(callstack, called, args) + msg = "RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead." + ActiveSupport::Deprecation.warn(msg, callstack) + end +end).new diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake index 9433b3556a..4696f02a98 100644 --- a/railties/lib/rails/tasks/misc.rake +++ b/railties/lib/rails/tasks/misc.rake @@ -1,6 +1,7 @@ task :default => :test task :rails_env do + # TODO Do we really need this? unless defined? RAILS_ENV RAILS_ENV = ENV['RAILS_ENV'] ||= 'development' end -- cgit v1.2.3