Class: Raven::StacktraceInterface::Frame

Inherits:
Interface
  • Object
show all
Defined in:
lib/raven/interfaces/stack_trace.rb

Overview

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

Instance Method Summary collapse

Methods inherited from Interface

#assert_required_properties_set!, name

Constructor Details

#initialize(*arguments) ⇒ Frame

Returns a new instance of Frame.



38
39
40
41
42
43
# File 'lib/raven/interfaces/stack_trace.rb', line 38

def initialize(*arguments)
  self.vars = {}
  self.pre_context = []
  self.post_context = []
  super(*arguments)
end

Instance Method Details

#filenameObject



45
46
47
48
49
50
# File 'lib/raven/interfaces/stack_trace.rb', line 45

def filename
  return nil if self.abs_path.nil?

  prefix = $:.select {|s| self.abs_path.start_with?(s)}.sort_by {|s| s.length}.last
  prefix ? self.abs_path[prefix.chomp(File::SEPARATOR).length+1..-1] : self.abs_path
end

#to_hashObject



52
53
54
55
56
57
58
59
60
# File 'lib/raven/interfaces/stack_trace.rb', line 52

def to_hash
  data = super
  data['filename'] = self.filename
  data.delete('vars') unless self.vars && !self.vars.empty?
  data.delete('pre_context') unless self.pre_context && !self.pre_context.empty?
  data.delete('post_context') unless self.post_context && !self.post_context.empty?
  data.delete('context_line') unless self.context_line && !self.context_line.empty?
  data
end