Class: Flail::Backtrace
- Inherits:
-
Object
- Object
- Flail::Backtrace
- Defined in:
- lib/flail/backtrace.rb
Overview
Front end to parsing the backtrace for each notice
Defined Under Namespace
Classes: Line
Constant Summary collapse
- DEFAULT_FILTERS =
[ lambda { |line| line.gsub(/^\.\//, "") }, lambda { |line| if defined?(Gem) Gem.path.inject(line) do |line, path| line.gsub(/#{path}/, "[GEM_ROOT]") end end }, lambda { |line| line if line !~ %r{lib/flail} } ].freeze
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
holder for an Array of Backtrace::Line instances.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(lines) ⇒ Backtrace
constructor
A new instance of Backtrace.
- #inspect ⇒ Object
- #to_ary ⇒ Object
Constructor Details
#initialize(lines) ⇒ Backtrace
Returns a new instance of Backtrace.
84 85 86 |
# File 'lib/flail/backtrace.rb', line 84 def initialize(lines) self.lines = lines end |
Instance Attribute Details
#lines ⇒ Object
holder for an Array of Backtrace::Line instances
65 66 67 |
# File 'lib/flail/backtrace.rb', line 65 def lines @lines end |
Class Method Details
.parse(ruby_backtrace, opts = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/flail/backtrace.rb', line 67 def self.parse(ruby_backtrace, opts = {}) ruby_lines = split_multiline_backtrace(ruby_backtrace) filters = opts[:filters] || [] filtered_lines = ruby_lines.to_a.map do |line| filters.inject(line) do |line, proc| proc.call(line) end end.compact lines = filtered_lines.collect do |unparsed_line| Line.parse(unparsed_line) end instance = new(lines) end |
Instance Method Details
#==(other) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/flail/backtrace.rb', line 92 def ==(other) if other.respond_to?(:lines) lines == other.lines else false end end |
#inspect ⇒ Object
88 89 90 |
# File 'lib/flail/backtrace.rb', line 88 def inspect "<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">" end |
#to_ary ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/flail/backtrace.rb', line 100 def to_ary lines.inject([]) do |collector, line| collector << { :number => line.number, :file => line.file, :method => line.method } end end |