Class: Raven::StacktraceInterface::Frame
- Defined in:
- lib/raven/interfaces/stack_trace.rb
Overview
Not actually an interface, but I want to use the same style
Instance Attribute Summary collapse
-
#abs_path ⇒ Object
Returns the value of attribute abs_path.
-
#context_line ⇒ Object
Returns the value of attribute context_line.
-
#function ⇒ Object
Returns the value of attribute function.
-
#in_app ⇒ Object
Returns the value of attribute in_app.
-
#lineno ⇒ Object
Returns the value of attribute lineno.
-
#module ⇒ Object
Returns the value of attribute module.
-
#post_context ⇒ Object
Returns the value of attribute post_context.
-
#pre_context ⇒ Object
Returns the value of attribute pre_context.
-
#vars ⇒ Object
Returns the value of attribute vars.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(*arguments) ⇒ Frame
constructor
A new instance of Frame.
- #longest_load_path ⇒ Object
- #project_root ⇒ Object
- #to_hash(*args) ⇒ Object
- #under_project_root? ⇒ Boolean
Methods inherited from Interface
Constructor Details
#initialize(*arguments) ⇒ Frame
Returns a new instance of Frame.
32 33 34 35 |
# File 'lib/raven/interfaces/stack_trace.rb', line 32 def initialize(*arguments) self.vars, self.pre_context, self.post_context = [], [], [] super(*arguments) end |
Instance Attribute Details
#abs_path ⇒ Object
Returns the value of attribute abs_path.
22 23 24 |
# File 'lib/raven/interfaces/stack_trace.rb', line 22 def abs_path @abs_path end |
#context_line ⇒ Object
Returns the value of attribute context_line.
27 28 29 |
# File 'lib/raven/interfaces/stack_trace.rb', line 27 def context_line @context_line end |
#function ⇒ Object
Returns the value of attribute function.
23 24 25 |
# File 'lib/raven/interfaces/stack_trace.rb', line 23 def function @function end |
#in_app ⇒ Object
Returns the value of attribute in_app.
30 31 32 |
# File 'lib/raven/interfaces/stack_trace.rb', line 30 def in_app @in_app end |
#lineno ⇒ Object
Returns the value of attribute lineno.
29 30 31 |
# File 'lib/raven/interfaces/stack_trace.rb', line 29 def lineno @lineno end |
#module ⇒ Object
Returns the value of attribute module.
28 29 30 |
# File 'lib/raven/interfaces/stack_trace.rb', line 28 def module @module end |
#post_context ⇒ Object
Returns the value of attribute post_context.
26 27 28 |
# File 'lib/raven/interfaces/stack_trace.rb', line 26 def post_context @post_context end |
#pre_context ⇒ Object
Returns the value of attribute pre_context.
25 26 27 |
# File 'lib/raven/interfaces/stack_trace.rb', line 25 def pre_context @pre_context end |
#vars ⇒ Object
Returns the value of attribute vars.
24 25 26 |
# File 'lib/raven/interfaces/stack_trace.rb', line 24 def vars @vars end |
Instance Method Details
#filename ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/raven/interfaces/stack_trace.rb', line 37 def filename return nil if self.abs_path.nil? prefix = if under_project_root? && in_app project_root elsif under_project_root? longest_load_path || project_root else longest_load_path end prefix ? self.abs_path[prefix.to_s.chomp(File::SEPARATOR).length+1..-1] : self.abs_path end |
#longest_load_path ⇒ Object
59 60 61 |
# File 'lib/raven/interfaces/stack_trace.rb', line 59 def longest_load_path $LOAD_PATH.select { |s| self.abs_path.start_with?(s.to_s) }.sort_by { |s| s.to_s.length }.last end |
#project_root ⇒ Object
55 56 57 |
# File 'lib/raven/interfaces/stack_trace.rb', line 55 def project_root @project_root ||= Raven.configuration.project_root && Raven.configuration.project_root.to_s end |
#to_hash(*args) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/raven/interfaces/stack_trace.rb', line 63 def to_hash(*args) data = super(*args) 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 |
#under_project_root? ⇒ Boolean
51 52 53 |
# File 'lib/raven/interfaces/stack_trace.rb', line 51 def under_project_root? project_root && abs_path.start_with?(project_root) end |