lib/deprecation/reporting.rb in deprecation-0.0.3 vs lib/deprecation/reporting.rb in deprecation-0.0.5

- old
+ new

@@ -1,7 +1,8 @@ module Deprecation class << self + attr_accessor :show_full_callstack # Outputs a deprecation warning to the output configured by <tt>ActiveSupport::Deprecation.behavior</tt> # # Deprecation.warn("something broke!") # # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)" def warn(context, message = nil, callstack = caller) @@ -54,9 +55,12 @@ message += '.' unless message =~ /\.$/ "DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}" end def deprecation_caller_message(callstack) + if Deprecation.show_full_callstack + return "(Callstack: #{callstack.join "\n\t"})" + end file, line, method = extract_callstack(callstack) if file if line && method "(called from #{method} at #{file}:#{line})" else