Method: Tapout::Reporters::Abstract#parse_source_location

Defined in:
lib/tapout/reporters/abstract.rb

#parse_source_location(caller) ⇒ Object

Parse source location from caller, caller or an Exception object.



448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/tapout/reporters/abstract.rb', line 448

def parse_source_location(caller)
  case caller
  when Exception
    trace  = caller.backtrace.reject{ |bt| bt =~ INTERNALS }
    caller = trace.first
  when Array
    caller = caller.first
  end
  caller =~ /(.+?):(\d+(?=:|\z))/ or return ""
  source_file, source_line = $1, $2.to_i
  returnf source_file, source_line
end