Class: Batbugger::Backtrace::Line
- Inherits:
-
Object
- Object
- Batbugger::Backtrace::Line
- Defined in:
- lib/batbugger/backtrace.rb
Constant Summary collapse
- INPUT_FORMAT =
%r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#filtered_file ⇒ Object
readonly
Returns the value of attribute filtered_file.
-
#filtered_method ⇒ Object
readonly
Returns the value of attribute filtered_method.
-
#filtered_number ⇒ Object
readonly
Returns the value of attribute filtered_number.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #application? ⇒ Boolean
-
#initialize(file, number, method, filtered_file = file, filtered_number = number, filtered_method = method) ⇒ Line
constructor
A new instance of Line.
- #inspect ⇒ Object
- #source(radius = 2) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file, number, method, filtered_file = file, filtered_number = number, filtered_method = method) ⇒ Line
Returns a new instance of Line.
30 31 32 33 34 35 36 37 38 |
# File 'lib/batbugger/backtrace.rb', line 30 def initialize(file, number, method, filtered_file = file, filtered_number = number, filtered_method = method) self.filtered_file = filtered_file self.filtered_number = filtered_number self.filtered_method = filtered_method self.file = file self.number = number self.method = method end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/batbugger/backtrace.rb', line 7 def file @file end |
#filtered_file ⇒ Object
Returns the value of attribute filtered_file.
13 14 15 |
# File 'lib/batbugger/backtrace.rb', line 13 def filtered_file @filtered_file end |
#filtered_method ⇒ Object
Returns the value of attribute filtered_method.
13 14 15 |
# File 'lib/batbugger/backtrace.rb', line 13 def filtered_method @filtered_method end |
#filtered_number ⇒ Object
Returns the value of attribute filtered_number.
13 14 15 |
# File 'lib/batbugger/backtrace.rb', line 13 def filtered_number @filtered_number end |
#method ⇒ Object
Returns the value of attribute method.
11 12 13 |
# File 'lib/batbugger/backtrace.rb', line 11 def method @method end |
#number ⇒ Object
Returns the value of attribute number.
9 10 11 |
# File 'lib/batbugger/backtrace.rb', line 9 def number @number end |
Class Method Details
.parse(unparsed_line, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/batbugger/backtrace.rb', line 15 def self.parse(unparsed_line, opts = {}) filters = opts[:filters] || [] filtered_line = filters.inject(unparsed_line) do |line, proc| proc.call(line) end if filtered_line _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a _, *filtered_args = filtered_line.match(INPUT_FORMAT).to_a new(file, number, method, *filtered_args) else nil end end |
Instance Method Details
#==(other) ⇒ Object
44 45 46 |
# File 'lib/batbugger/backtrace.rb', line 44 def ==(other) to_s == other.to_s end |
#application? ⇒ Boolean
52 53 54 |
# File 'lib/batbugger/backtrace.rb', line 52 def application? (filtered_file =~ /^\[PROJECT_ROOT\]/i) && !(filtered_file =~ /^\[PROJECT_ROOT\]\/vendor/i) end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/batbugger/backtrace.rb', line 48 def inspect "<Line:#{to_s}>" end |
#source(radius = 2) ⇒ Object
56 57 58 |
# File 'lib/batbugger/backtrace.rb', line 56 def source(radius = 2) @source ||= get_source(file, number, radius) end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/batbugger/backtrace.rb', line 40 def to_s "#{filtered_file}:#{filtered_number}:in `#{filtered_method}'" end |