Class: Raven::Backtrace

Inherits:
Object
  • Object
show all
Defined in:
lib/raven/backtrace.rb

Overview

Front end to parsing the backtrace for each notice

Defined Under Namespace

Classes: Line

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines) ⇒ Backtrace

Returns a new instance of Backtrace.



91
92
93
# File 'lib/raven/backtrace.rb', line 91

def initialize(lines)
  self.lines = lines
end

Instance Attribute Details

#linesObject

holder for an Array of Backtrace::Line instances



72
73
74
# File 'lib/raven/backtrace.rb', line 72

def lines
  @lines
end

Class Method Details

.parse(ruby_backtrace, opts = {}) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/raven/backtrace.rb', line 74

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



107
108
109
110
111
112
113
# File 'lib/raven/backtrace.rb', line 107

def ==(other)
  if other.respond_to?(:lines)
    lines == other.lines
  else
    false
  end
end

#inspectObject



95
96
97
# File 'lib/raven/backtrace.rb', line 95

def inspect
  "<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">"
end

#to_sObject



99
100
101
102
103
104
105
# File 'lib/raven/backtrace.rb', line 99

def to_s
  content = []
  lines.each do |line|
    content << line
  end
  content.join("\n")
end