Class: Sentry::Backtrace::Line
Overview
Handles backtrace parsing line by line
Constant Summary collapse
- RB_EXTENSION =
".rb"- RUBY_INPUT_FORMAT =
regexp (optional leading X: on windows, or JRuby9000 class-prefix)
/ ^ \s* (?: [a-zA-Z]: | uri:classloader: )? ([^:]+ | <.*>): (\d+) (?: :in \s `([^']+)')?$ /x.freeze
- JAVA_INPUT_FORMAT =
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
/^(.+)\.([^\.]+)\(([^\:]+)\:(\d+)\)$/.freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
The file portion of the line (such as app/models/user.rb).
-
#in_app_pattern ⇒ Object
readonly
Returns the value of attribute in_app_pattern.
-
#method ⇒ Object
readonly
The method of the line (such as index).
-
#module_name ⇒ Object
readonly
The module name (JRuby).
-
#number ⇒ Object
readonly
The line number portion of the line.
Class Method Summary collapse
-
.parse(unparsed_line, in_app_pattern) ⇒ Line
Parses a single line of a given backtrace.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #in_app ⇒ Object
-
#initialize(file, number, method, module_name, in_app_pattern) ⇒ Line
constructor
A new instance of Line.
- #inspect ⇒ Object
-
#to_s ⇒ Object
Reconstructs the line in a readable fashion.
Constructor Details
#initialize(file, number, method, module_name, in_app_pattern) ⇒ Line
Returns a new instance of Line.
51 52 53 54 55 56 57 |
# File 'lib/sentry/backtrace.rb', line 51 def initialize(file, number, method, module_name, in_app_pattern) @file = file @module_name = module_name @number = number.to_i @method = method @in_app_pattern = in_app_pattern end |
Instance Attribute Details
#file ⇒ Object (readonly)
The file portion of the line (such as app/models/user.rb)
22 23 24 |
# File 'lib/sentry/backtrace.rb', line 22 def file @file end |
#in_app_pattern ⇒ Object (readonly)
Returns the value of attribute in_app_pattern.
33 34 35 |
# File 'lib/sentry/backtrace.rb', line 33 def in_app_pattern @in_app_pattern end |
#method ⇒ Object (readonly)
The method of the line (such as index)
28 29 30 |
# File 'lib/sentry/backtrace.rb', line 28 def method @method end |
#module_name ⇒ Object (readonly)
The module name (JRuby)
31 32 33 |
# File 'lib/sentry/backtrace.rb', line 31 def module_name @module_name end |
#number ⇒ Object (readonly)
The line number portion of the line
25 26 27 |
# File 'lib/sentry/backtrace.rb', line 25 def number @number end |
Class Method Details
.parse(unparsed_line, in_app_pattern) ⇒ Line
Parses a single line of a given backtrace
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sentry/backtrace.rb', line 38 def self.parse(unparsed_line, in_app_pattern) ruby_match = unparsed_line.match(RUBY_INPUT_FORMAT) if ruby_match _, file, number, method = ruby_match.to_a file.sub!(/\.class$/, RB_EXTENSION) module_name = nil else java_match = unparsed_line.match(JAVA_INPUT_FORMAT) _, module_name, method, file, number = java_match.to_a end new(file, number, method, module_name, in_app_pattern) end |
Instance Method Details
#==(other) ⇒ Object
72 73 74 |
# File 'lib/sentry/backtrace.rb', line 72 def ==(other) to_s == other.to_s end |
#in_app ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/sentry/backtrace.rb', line 59 def in_app if file =~ in_app_pattern true else false end end |
#inspect ⇒ Object
76 77 78 |
# File 'lib/sentry/backtrace.rb', line 76 def inspect "<Line:#{self}>" end |
#to_s ⇒ Object
Reconstructs the line in a readable fashion
68 69 70 |
# File 'lib/sentry/backtrace.rb', line 68 def to_s "#{file}:#{number}:in `#{method}'" end |