Module: Peck::Notifiers::Base::BacktraceCleaning

Included in:
Peck::Notifiers::Base
Defined in:
lib/peck/notifiers/base.rb

Constant Summary collapse

PECK_PATH =

When a file starts with this path, it’s in the Peck library

File.expand_path('../../../../', __FILE__)
ANONYMOUS_BLOCK_RE =

Matches: ‘block (2 levels) in <top (required)>’

/`block/

Instance Method Summary collapse

Instance Method Details

#clean_backtrace(backtrace) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/peck/notifiers/base.rb', line 13

def clean_backtrace(backtrace)
  stripped = []
  backtrace.each do |line|
    if line.start_with?(PECK_PATH) || line.start_with?("<")
    elsif line =~ ANONYMOUS_BLOCK_RE
      stripped << line.split(':')[0,2].join(':')
    else
      stripped << line
    end
  end
  stripped.empty? ? backtrace : stripped
end