Class: Failbot::Backtrace::Frame
- Inherits:
-
Object
- Object
- Failbot::Backtrace::Frame
- Defined in:
- lib/failbot/backtrace.rb
Overview
A parsed stack frame.
Constant Summary collapse
- FRAME_FORMAT =
Regex adapted from sentry’s parser: github.com/getsentry/raven-ruby/blob/2e4378d95dae95a31e3386b2b94c8520649c6876/lib/raven/backtrace.rb#L10-L14
/ \A \s* ([^:]+ | <.*>): # abs_path (\d+) # line_number (?: :in \s `([^']+)')? # method \z /x
Instance Attribute Summary collapse
-
#abs_path ⇒ Object
readonly
Returns the value of attribute abs_path.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Class Method Summary collapse
-
.parse(unparsed_line) ⇒ Object
Returns a Frame given backtrace component string or raises ParseError if it’s malformed.
Instance Method Summary collapse
-
#initialize(abs_path, file_name, line_number, method) ⇒ Frame
constructor
A new instance of Frame.
- #to_s ⇒ Object
Constructor Details
#initialize(abs_path, file_name, line_number, method) ⇒ Frame
Returns a new instance of Frame.
80 81 82 83 84 85 |
# File 'lib/failbot/backtrace.rb', line 80 def initialize(abs_path, file_name, line_number, method) @abs_path = abs_path @file_name = file_name @line_number = line_number @method = method end |
Instance Attribute Details
#abs_path ⇒ Object (readonly)
Returns the value of attribute abs_path.
41 42 43 |
# File 'lib/failbot/backtrace.rb', line 41 def abs_path @abs_path end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
41 42 43 |
# File 'lib/failbot/backtrace.rb', line 41 def file_name @file_name end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
41 42 43 |
# File 'lib/failbot/backtrace.rb', line 41 def line_number @line_number end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
41 42 43 |
# File 'lib/failbot/backtrace.rb', line 41 def method @method end |
Class Method Details
.parse(unparsed_line) ⇒ Object
Returns a Frame given backtrace component string or raises ParseError if it’s malformed.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/failbot/backtrace.rb', line 45 def self.parse(unparsed_line) match = unparsed_line.match(FRAME_FORMAT) if match abs_path, line_number, method = match.captures file_name = extract_file_name(abs_path) new(abs_path, file_name, line_number, method) else raise ParseError, "unable to parse #{unparsed_line.inspect}" end end |
Instance Method Details
#to_s ⇒ Object
87 88 89 |
# File 'lib/failbot/backtrace.rb', line 87 def to_s "#{file_name}:#{line_number}:in `#{method}'" end |