Class: Sentry::LineCache Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry/linecache.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Method Summary collapse

Constructor Details

#initializeLineCache

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LineCache.

API:

  • private



6
7
8
# File 'lib/sentry/linecache.rb', line 6

def initialize
  @cache = {}
end

Instance Method Details

#get_file_context(filename, lineno, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Any linecache you provide to Sentry must implement this method. Returns an Array of Strings representing the lines in the source file. The number of lines retrieved is (2 * context) + 1, the middle line should be the line requested by lineno. See specs for more information.

API:

  • private



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sentry/linecache.rb', line 14

def get_file_context(filename, lineno, context)
  lines = getlines(filename)
  return nil, nil, nil unless lines

  first_line = lineno - context
  pre = Array.new(context) { |i| line_at(lines, first_line + i) }
  context_line = line_at(lines, lineno)
  post = Array.new(context) { |i| line_at(lines, lineno + 1 + i) }

  [pre, context_line, post]
end