Sha256: 46630166e33dabb2bcf044d6c9d84dc7ee070c69f608ed85318f13747d2e6fef

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

module MethodLog
  class SourceFile
    attr_reader :path
    attr_reader :sha

    def initialize(path: nil, source: nil, repository: nil, sha: nil)
      @path = path
      @source = source
      @repository = repository
      @sha = sha
    end

    def source
      @source ||= @repository.lookup(@sha).text
    end

    def ==(other)
      (path == other.path) && (source == other.source)
    end

    def hash
      @sha || [path, source].hash
    end

    def snippet(range)
      lines = source.split($/)[range].join($/)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
method_log-0.0.5 lib/method_log/source_file.rb