Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5535

Show
Ignore:
Timestamp:
11/16/06 06:40:05 (2 years ago)
Author:
bitsweat
Message:

Handle failed caller parsing, factor out deprecation caller message.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/deprecation.rb

    r5356 r5535  
    5252      private 
    5353        def deprecation_message(callstack, message = nil) 
     54          message ||= "You are using deprecated behavior which will be removed from Rails 2.0." 
     55          "DEPRECATION WARNING: #{message}  See http://www.rubyonrails.org/deprecation for details. #{deprecation_caller_message(callstack)}" 
     56        end 
     57 
     58        def deprecation_caller_message(callstack) 
    5459          file, line, method = extract_callstack(callstack) 
    55           message ||= "You are using deprecated behavior which will be removed from Rails 2.0." 
    56           "DEPRECATION WARNING: #{message}  See http://www.rubyonrails.org/deprecation for details. (called from #{method} at #{file}:#{line})" 
     60          if file 
     61            if line && method 
     62              "(called from #{method} at #{file}:#{line})" 
     63            else 
     64              "(called from #{file}:#{line})" 
     65            end 
     66          end 
    5767        end 
    5868 
    5969        def extract_callstack(callstack) 
    60           callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures 
     70          if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/) 
     71            md.captures 
     72          else 
     73            callstack.first 
     74          end 
    6175        end 
    6276    end