diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-16 06:40:05 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-16 06:40:05 +0000 |
commit | 072985bc2841d627e631c7c5ed7b620fb15fae65 (patch) | |
tree | bf088764cefad9a893a1522c5793a515d6d50370 | |
parent | be3a4c3daae637bf7285025e3bb10fa118e94728 (diff) | |
download | rails-072985bc2841d627e631c7c5ed7b620fb15fae65.tar.gz rails-072985bc2841d627e631c7c5ed7b620fb15fae65.tar.bz2 rails-072985bc2841d627e631c7c5ed7b620fb15fae65.zip |
Handle failed caller parsing, factor out deprecation caller message.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5535 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activesupport/lib/active_support/deprecation.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 621cc14cea..8960a03e66 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -51,13 +51,27 @@ module ActiveSupport private def deprecation_message(callstack, message = nil) - file, line, method = extract_callstack(callstack) message ||= "You are using deprecated behavior which will be removed from Rails 2.0." - "DEPRECATION WARNING: #{message} See http://www.rubyonrails.org/deprecation for details. (called from #{method} at #{file}:#{line})" + "DEPRECATION WARNING: #{message} See http://www.rubyonrails.org/deprecation for details. #{deprecation_caller_message(callstack)}" + end + + def deprecation_caller_message(callstack) + file, line, method = extract_callstack(callstack) + if file + if line && method + "(called from #{method} at #{file}:#{line})" + else + "(called from #{file}:#{line})" + end + end end def extract_callstack(callstack) - callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures + if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/) + md.captures + else + callstack.first + end end end |