Class: RubyReactor::Utils::BacktraceLocation
- Inherits:
-
Object
- Object
- RubyReactor::Utils::BacktraceLocation
- Defined in:
- lib/ruby_reactor/utils/backtrace_location.rb
Constant Summary collapse
- LINE_PATTERN =
Ruby 3.x backtraces use single-quoted method names; older formats use backticks.
/^(.+?):(\d+)(?::in .*)?$/
Class Method Summary collapse
Class Method Details
.extract(backtrace) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby_reactor/utils/backtrace_location.rb', line 20 def self.extract(backtrace) return [nil, nil] unless backtrace.is_a?(Array) && backtrace.any? skip_internal = ENV["RUBY_REACTOR_DEBUG"] != "true" backtrace.each do |line| file_path, line_number = parse(line) next unless file_path next if skip_internal && internal_path?(file_path) return [file_path, line_number] end parse(backtrace.first) || [nil, nil] end |
.internal_path?(file_path) ⇒ Boolean
16 17 18 |
# File 'lib/ruby_reactor/utils/backtrace_location.rb', line 16 def self.internal_path?(file_path) file_path.start_with?(RubyReactor.internal_lib_path) end |
.parse(line) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/ruby_reactor/utils/backtrace_location.rb', line 9 def self.parse(line) match = line.match(LINE_PATTERN) return nil unless match [match[1], match[2].to_i] end |