class Raven::StacktraceInterface::Frame

Not actually an interface, but I want to use the same style

Attributes

abs_path[RW]
context_line[RW]
function[RW]
in_app[RW]
lineno[RW]
module[RW]
post_context[RW]
pre_context[RW]
vars[RW]

Public Class Methods

new(*arguments) click to toggle source
Calls superclass method Raven::Interface::new
# File lib/raven/interfaces/stack_trace.rb, line 24
def initialize(*arguments)
  super(*arguments)
end

Public Instance Methods

filename() click to toggle source
# File lib/raven/interfaces/stack_trace.rb, line 28
def filename
  return if abs_path.nil?
  return @filename if instance_variable_defined?(:@filename)

  prefix =
    if under_project_root? && in_app
      project_root
    elsif under_project_root?
      longest_load_path || project_root
    else
      longest_load_path
    end

  @filename = prefix ? abs_path[prefix.to_s.chomp(File::SEPARATOR).length + 1..-1] : abs_path
end
to_hash(*args) click to toggle source
Calls superclass method Raven::Interface#to_hash
# File lib/raven/interfaces/stack_trace.rb, line 44
def to_hash(*args)
  data = super(*args)
  data[:filename] = filename
  data.delete(:vars) unless vars && !vars.empty?
  data.delete(:pre_context) unless pre_context && !pre_context.empty?
  data.delete(:post_context) unless post_context && !post_context.empty?
  data.delete(:context_line) unless context_line && !context_line.empty?
  data
end

Private Instance Methods

longest_load_path() click to toggle source
# File lib/raven/interfaces/stack_trace.rb, line 64
def longest_load_path
  $LOAD_PATH.select { |path| abs_path.start_with?(path.to_s) }.max_by(&:size)
end
project_root() click to toggle source
# File lib/raven/interfaces/stack_trace.rb, line 60
def project_root
  @project_root ||= Raven.configuration.project_root&.to_s
end
under_project_root?() click to toggle source
# File lib/raven/interfaces/stack_trace.rb, line 56
def under_project_root?
  project_root && abs_path.start_with?(project_root)
end