diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-02-24 10:01:52 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-02-24 10:02:45 -0300 |
commit | ba004484cd3456fc8cb6391e7927f3ddc8e32dad (patch) | |
tree | d6028757654a34eda83052b7bc19e8c04c43703f /activesupport | |
parent | ef06afe29a4e25109c7959d57dcdf55983ec7c23 (diff) | |
download | rails-ba004484cd3456fc8cb6391e7927f3ddc8e32dad.tar.gz rails-ba004484cd3456fc8cb6391e7927f3ddc8e32dad.tar.bz2 rails-ba004484cd3456fc8cb6391e7927f3ddc8e32dad.zip |
Ignore callstacks from Ruby stdlib in deprecation
Fixes #22982.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/deprecation/reporting.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb index f89fc0fe14..e25b2b02e4 100644 --- a/activesupport/lib/active_support/deprecation/reporting.rb +++ b/activesupport/lib/active_support/deprecation/reporting.rb @@ -1,3 +1,5 @@ +require 'rbconfig' + module ActiveSupport class Deprecation module Reporting @@ -81,17 +83,17 @@ module ActiveSupport def extract_callstack(callstack) return _extract_callstack(callstack) if callstack.first.is_a? String - rails_gem_root = File.expand_path("../../../../..", __FILE__) + "/" offending_line = callstack.find { |frame| - frame.absolute_path && !frame.absolute_path.start_with?(rails_gem_root) + frame.absolute_path && !ignored_callstack(frame.absolute_path) } || callstack.first + [offending_line.path, offending_line.lineno, offending_line.label] end def _extract_callstack(callstack) warn "Please pass `caller_locations` to the deprecation API" if $VERBOSE - rails_gem_root = File.expand_path("../../../../..", __FILE__) + "/" - offending_line = callstack.find { |line| !line.start_with?(rails_gem_root) } || callstack.first + offending_line = callstack.find { |line| !ignored_callstack(path) } || callstack.first + if offending_line if md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/) md.captures @@ -100,6 +102,12 @@ module ActiveSupport end end end + + RAILS_GEM_ROOT = File.expand_path("../../../../..", __FILE__) + "/" + + def ignored_callstack(path) + path.start_with?(RAILS_GEM_ROOT) || path.start_with?(RbConfig::CONFIG['rubylibdir']) + end end end end |