Class: Lapsoss::BacktraceFrame
- Inherits:
-
Data
- Object
- Data
- Lapsoss::BacktraceFrame
- Defined in:
- lib/lapsoss/backtrace_frame.rb
Instance Attribute Summary collapse
-
#absolute_path ⇒ Object
readonly
Returns the value of attribute absolute_path.
-
#block_info ⇒ Object
readonly
Returns the value of attribute block_info.
-
#code_context ⇒ Object
readonly
Returns the value of attribute code_context.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#in_app ⇒ Object
readonly
Returns the value of attribute in_app.
-
#line_number ⇒ Object
(also: #lineno)
readonly
Returns the value of attribute line_number.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#raw_line ⇒ Object
(also: #raw)
readonly
Returns the value of attribute raw_line.
Instance Method Summary collapse
- #add_code_context(processor, context_lines = 3) ⇒ Object
- #app_frame? ⇒ Boolean
- #excluded?(exclude_patterns = []) ⇒ Boolean
- #library_frame? ⇒ Boolean
- #relative_filename(load_paths = []) ⇒ Object
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Instance Attribute Details
#absolute_path ⇒ Object (readonly)
Returns the value of attribute absolute_path
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def absolute_path @absolute_path end |
#block_info ⇒ Object (readonly)
Returns the value of attribute block_info
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def block_info @block_info end |
#code_context ⇒ Object (readonly)
Returns the value of attribute code_context
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def code_context @code_context end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def filename @filename end |
#function ⇒ Object (readonly)
Returns the value of attribute function
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def function @function end |
#in_app ⇒ Object (readonly)
Returns the value of attribute in_app
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def in_app @in_app end |
#line_number ⇒ Object (readonly) Also known as: lineno
Returns the value of attribute line_number
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def line_number @line_number end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def method_name @method_name end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def module_name @module_name end |
#raw_line ⇒ Object (readonly) Also known as: raw
Returns the value of attribute raw_line
4 5 6 |
# File 'lib/lapsoss/backtrace_frame.rb', line 4 def raw_line @raw_line end |
Instance Method Details
#add_code_context(processor, context_lines = 3) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/lapsoss/backtrace_frame.rb', line 34 def add_code_context(processor, context_lines = 3) return unless line_number # Use absolute path if available, otherwise try filename path_to_read = absolute_path || filename return unless path_to_read with(code_context: processor.get_code_context(path_to_read, line_number, context_lines)) end |
#app_frame? ⇒ Boolean
52 53 54 |
# File 'lib/lapsoss/backtrace_frame.rb', line 52 def app_frame? in_app end |
#excluded?(exclude_patterns = []) ⇒ Boolean
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/lapsoss/backtrace_frame.rb', line 56 def excluded?(exclude_patterns = []) return false if exclude_patterns.empty? exclude_patterns.any? do |pattern| case pattern when Regexp raw_line.match?(pattern) when String raw_line.include?(pattern) else false end end end |
#library_frame? ⇒ Boolean
48 49 50 |
# File 'lib/lapsoss/backtrace_frame.rb', line 48 def library_frame? !in_app end |
#relative_filename(load_paths = []) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/lapsoss/backtrace_frame.rb', line 71 def relative_filename(load_paths = []) return filename unless filename && load_paths.any? # Try to make path relative to load paths load_paths.each do |load_path| if filename.start_with?(load_path) relative = filename.sub(%r{^#{Regexp.escape(load_path)}/?}, "") return relative unless relative.empty? end end filename end |
#to_h ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lapsoss/backtrace_frame.rb', line 20 def to_h { filename: filename, absolute_path: absolute_path, line_number: line_number, method: method_name, function: function, module: module_name, in_app: in_app, code_context: code_context, raw: raw_line }.compact end |
#valid? ⇒ Boolean
44 45 46 |
# File 'lib/lapsoss/backtrace_frame.rb', line 44 def valid? filename && (line_number.nil? || line_number >= 0) end |