Class: Sentry::Backtrace Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Line

Constant Summary collapse

APP_DIRS_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/(bin|exe|app|config|lib|test|spec)/.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines) ⇒ Backtrace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Backtrace.



104
105
106
# File 'lib/sentry/backtrace.rb', line 104

def initialize(lines)
  @lines = lines
end

Instance Attribute Details

#linesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

holder for an Array of Backtrace::Line instances



86
87
88
# File 'lib/sentry/backtrace.rb', line 86

def lines
  @lines
end

Class Method Details

.parse(backtrace, project_root, app_dirs_pattern, &backtrace_cleanup_callback) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/sentry/backtrace.rb', line 88

def self.parse(backtrace, project_root, app_dirs_pattern, &backtrace_cleanup_callback)
  ruby_lines = backtrace.is_a?(Array) ? backtrace : backtrace.split(/\n\s*/)

  ruby_lines = backtrace_cleanup_callback.call(ruby_lines) if backtrace_cleanup_callback

  in_app_pattern ||= begin
    Regexp.new("^(#{project_root}/)?#{app_dirs_pattern || APP_DIRS_PATTERN}")
  end

  lines = ruby_lines.to_a.map do |unparsed_line|
    Line.parse(unparsed_line, in_app_pattern)
  end

  new(lines)
end

Instance Method Details

#==(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



120
121
122
123
124
125
126
# File 'lib/sentry/backtrace.rb', line 120

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

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



108
109
110
# File 'lib/sentry/backtrace.rb', line 108

def inspect
  "<Backtrace: " + lines.map(&:inspect).join(", ") + ">"
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



112
113
114
115
116
117
118
# File 'lib/sentry/backtrace.rb', line 112

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