Class: Raven::Backtrace::Line
- Inherits:
-
Object
- Object
- Raven::Backtrace::Line
- Defined in:
- lib/raven/backtrace.rb
Overview
Handles backtrace parsing line by line
Constant Summary collapse
- RB_EXTENSION =
".rb".freeze
- RUBY_INPUT_FORMAT =
regexp (optional leading X: on windows, or JRuby9000 class-prefix)
/ ^ \s* (?: [a-zA-Z]: | uri:classloader: )? ([^:]+ | <.*>): (\d+) (?: :in \s `([^']+)')?$ /x
- JAVA_INPUT_FORMAT =
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
/^(.+)\.([^\.]+)\(([^\:]+)\:(\d+)\)$/
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).
-
#module_name ⇒ Object
readonly
The module name (JRuby).
-
#number ⇒ Object
readonly
The line number portion of the line.
Class Method Summary collapse
- .in_app_pattern ⇒ Object
-
.parse(unparsed_line) ⇒ Line
Parses a single line of a given backtrace.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #in_app ⇒ Object
-
#initialize(file, number, method, module_name) ⇒ 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) ⇒ Line
Returns a new instance of Line.
47 48 49 50 51 52 |
# File 'lib/raven/backtrace.rb', line 47 def initialize(file, number, method, module_name) self.file = file self.module_name = module_name self.number = number.to_i self.method = method end |
Instance Attribute Details
#file ⇒ Object
The file portion of the line (such as app/models/user.rb)
20 21 22 |
# File 'lib/raven/backtrace.rb', line 20 def file @file end |
#method ⇒ Object
The method of the line (such as index)
26 27 28 |
# File 'lib/raven/backtrace.rb', line 26 def method @method end |
#module_name ⇒ Object
The module name (JRuby)
29 30 31 |
# File 'lib/raven/backtrace.rb', line 29 def module_name @module_name end |
#number ⇒ Object
The line number portion of the line
23 24 25 |
# File 'lib/raven/backtrace.rb', line 23 def number @number end |
Class Method Details
.in_app_pattern ⇒ Object
75 76 77 78 79 80 |
# File 'lib/raven/backtrace.rb', line 75 def self.in_app_pattern @in_app_pattern ||= begin project_root = Raven.configuration.project_root && Raven.configuration.project_root.to_s Regexp.new("^(#{project_root}/)?#{Raven.configuration.app_dirs_pattern || APP_DIRS_PATTERN}") end end |
.parse(unparsed_line) ⇒ Line
Parses a single line of a given backtrace
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/raven/backtrace.rb', line 34 def self.parse(unparsed_line) 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) end |
Instance Method Details
#==(other) ⇒ Object
67 68 69 |
# File 'lib/raven/backtrace.rb', line 67 def ==(other) to_s == other.to_s end |
#in_app ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/raven/backtrace.rb', line 54 def in_app if file =~ self.class.in_app_pattern true else false end end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/raven/backtrace.rb', line 71 def inspect "<Line:#{self}>" end |
#to_s ⇒ Object
Reconstructs the line in a readable fashion
63 64 65 |
# File 'lib/raven/backtrace.rb', line 63 def to_s "#{file}:#{number}:in `#{method}'" end |