Class: Sentry::StacktraceInterface::Frame
- Defined in:
- lib/sentry/interfaces/stacktrace.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(project_root, line) ⇒ Frame
constructor
A new instance of Frame.
- #set_context(linecache, context_lines) ⇒ Object
- #to_hash(*args) ⇒ Object
Methods inherited from Interface
Constructor Details
#initialize(project_root, line) ⇒ Frame
Returns a new instance of Frame.
36 37 38 39 40 41 42 43 44 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 36 def initialize(project_root, line) @project_root = project_root @abs_path = line.file if line.file @function = line.method if line.method @lineno = line.number @in_app = line.in_app @module = line.module_name if line.module_name end |
Instance Attribute Details
#abs_path ⇒ Object
Returns the value of attribute abs_path.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def abs_path @abs_path end |
#context_line ⇒ Object
Returns the value of attribute context_line.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def context_line @context_line end |
#function ⇒ Object
Returns the value of attribute function.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def function @function end |
#in_app ⇒ Object
Returns the value of attribute in_app.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def in_app @in_app end |
#lineno ⇒ Object
Returns the value of attribute lineno.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def lineno @lineno end |
#module ⇒ Object
Returns the value of attribute module.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def module @module end |
#post_context ⇒ Object
Returns the value of attribute post_context.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def post_context @post_context end |
#pre_context ⇒ Object
Returns the value of attribute pre_context.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def pre_context @pre_context end |
#vars ⇒ Object
Returns the value of attribute vars.
33 34 35 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 33 def vars @vars end |
Instance Method Details
#filename ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 46 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 |
#set_context(linecache, context_lines) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 62 def set_context(linecache, context_lines) return unless abs_path self.pre_context, self.context_line, self.post_context = \ linecache.get_file_context(abs_path, lineno, context_lines) end |
#to_hash(*args) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/sentry/interfaces/stacktrace.rb', line 69 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 |