Module: Ripl::Rc::StripBacktrace::Imp

Included in:
U
Defined in:
lib/ripl/rc/strip_backtrace.rb

Instance Method Summary collapse

Instance Method Details

#cwd(b) ⇒ Object



28
29
30
# File 'lib/ripl/rc/strip_backtrace.rb', line 28

def cwd b
  b.map{ |p| p.sub(Dir.pwd, '.') }
end

#home(b) ⇒ Object



24
25
26
# File 'lib/ripl/rc/strip_backtrace.rb', line 24

def home b
  b.map{ |p| p.sub(ENV['HOME'], '~') }
end

#snip(e, name) ⇒ Object



32
33
34
35
36
37
# File 'lib/ripl/rc/strip_backtrace.rb', line 32

def snip e, name
  return [] if e.kind_of?(SyntaxError)
  e.backtrace[
    0..
    e.backtrace.rindex{ |l| l =~ /\(#{name}\):\d+:in `.+?'/ } || -1]
end

#strip_backtrace(e, name) ⇒ Object



20
21
22
# File 'lib/ripl/rc/strip_backtrace.rb', line 20

def strip_backtrace e, name
  home(cwd(snip(e, name)))
end