2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:15:47 -04:00
|
|
|
require "active_support/backtrace_cleaner"
|
2019-12-29 00:11:33 -05:00
|
|
|
require "active_support/core_ext/string/access"
|
2009-04-28 21:21:03 -04:00
|
|
|
|
2008-11-22 12:06:08 -05:00
|
|
|
module Rails
|
|
|
|
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
|
2019-10-03 16:58:08 -04:00
|
|
|
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/
|
2018-08-06 23:17:01 -04:00
|
|
|
RENDER_TEMPLATE_PATTERN = /:in `.*_\w+_{2,3}\d+_\d+'/
|
2008-11-22 12:06:08 -05:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super
|
2018-02-27 23:33:37 -05:00
|
|
|
@root = "#{Rails.root}/"
|
2019-04-15 18:01:12 -04:00
|
|
|
add_filter do |line|
|
|
|
|
line.start_with?(@root) ? line.from(@root.size) : line
|
|
|
|
end
|
|
|
|
add_filter do |line|
|
|
|
|
if RENDER_TEMPLATE_PATTERN.match?(line)
|
|
|
|
line.sub(RENDER_TEMPLATE_PATTERN, "")
|
|
|
|
else
|
|
|
|
line
|
|
|
|
end
|
|
|
|
end
|
2017-02-13 09:25:08 -05:00
|
|
|
add_silencer { |line| !APP_DIRS_PATTERN.match?(line) }
|
2008-11-22 12:06:08 -05:00
|
|
|
end
|
|
|
|
end
|
2008-12-05 12:24:28 -05:00
|
|
|
end
|