Sha256: d7fcfd2666d3dc7448d3d09a6ee210614aacffc4f5806316e24fc5d33a30ad32

Contents?: true

Size: 736 Bytes

Versions: 9

Compression:

Stored size: 736 Bytes

Contents

# A much simpler source line cacher because linecache sucks at platform compat

module Raven
  class LineCache
    class << self
      # TODO: a constant isn't appropriate here, refactor
      # also would there be threading bugs essentially using this as a class
      # variable?
      CACHE = {} # rubocop:disable Style/MutableConstant

      def is_valid_file(path)
        lines = getlines(path)
        !lines.nil?
      end

      def getlines(path)
        CACHE[path] ||= begin
          IO.readlines(path)
        rescue
          nil
        end
      end

      def getline(path, n)
        return nil if n < 1
        lines = getlines(path)
        return nil if lines.nil?
        lines[n - 1]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sentry-raven-1.2.3 lib/raven/linecache.rb
sentry-raven-1.2.2 lib/raven/linecache.rb
sentry-raven-1.2.1 lib/raven/linecache.rb
sentry-raven-1.2.0 lib/raven/linecache.rb
sentry-raven-1.1.0 lib/raven/linecache.rb
sentry-raven-1.0.0 lib/raven/linecache.rb
sentry-raven-0.15.6 lib/raven/linecache.rb
sentry-raven-0.15.5 lib/raven/linecache.rb
sentry-raven-0.15.4 lib/raven/linecache.rb