Class: DaemonKit::ErrorHandlers::Hoptoad::Backtrace::Line
- Defined in:
- lib/daemon_kit/error_handlers/hoptoad.rb
Overview
Handles backtrace parsing line by line (Graciously borrowed from github.com/thoughtbot/hoptoad_notifier)
Constant Summary collapse
- INPUT_FORMAT =
%r{^([^:]+):(\d+)(?::in `([^']+)')?$}.freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
The file portion of the line (such as app/models/user.rb).
-
#method ⇒ Object
readonly
The method of the line (such as index).
-
#number ⇒ Object
readonly
The line number portion of the line.
Class Method Summary collapse
-
.parse(unparsed_line) ⇒ Line
Parses a single line of a given backtrace.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(file, number, method) ⇒ Line
constructor
A new instance of Line.
- #inspect ⇒ Object
-
#to_s ⇒ Object
Reconstructs the line in a readable fashion.
- #to_xml ⇒ Object
Constructor Details
#initialize(file, number, method) ⇒ Line
Returns a new instance of Line.
35 36 37 38 39 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 35 def initialize(file, number, method) self.file = file self.number = number self.method = method end |
Instance Attribute Details
#file ⇒ Object
The file portion of the line (such as app/models/user.rb)
19 20 21 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 19 def file @file end |
#method ⇒ Object
The method of the line (such as index)
25 26 27 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 25 def method @method end |
#number ⇒ Object
The line number portion of the line
22 23 24 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 22 def number @number end |
Class Method Details
.parse(unparsed_line) ⇒ Line
Parses a single line of a given backtrace
30 31 32 33 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 30 def self.parse(unparsed_line) _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a new(file, number, method) end |
Instance Method Details
#==(other) ⇒ Object
46 47 48 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 46 def ==(other) to_s == other.to_s end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 50 def inspect "<Line:#{to_s}>" end |
#to_s ⇒ Object
Reconstructs the line in a readable fashion
42 43 44 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 42 def to_s "#{file}:#{number}:in `#{method}'" end |
#to_xml ⇒ Object
54 55 56 57 |
# File 'lib/daemon_kit/error_handlers/hoptoad.rb', line 54 def to_xml data = [ method, file, number ].map { |s| URI.escape( s || 'unknown', %q{"'<>&} ) } %q{<line method="%s" file="%s" number="%s" />} % data end |