Sha256: 495c9c68a3b84366e9986938ecd90b3328ba391112c91e9528c9e006373ce09e

Contents?: true

Size: 549 Bytes

Versions: 6

Compression:

Stored size: 549 Bytes

Contents

module MethodLog
  class SourceFile
    attr_reader :path
    attr_reader :sha

    def initialize(options = {})
      @path = options[:path]
      @source = options[:source]
      @repository = options[:repository]
      @sha = options[: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

6 entries across 6 versions & 1 rubygems

Version Path
method_log-0.2.1 lib/method_log/source_file.rb
method_log-0.2.0 lib/method_log/source_file.rb
method_log-0.1.1 lib/method_log/source_file.rb
method_log-0.1.0 lib/method_log/source_file.rb
method_log-0.0.7 lib/method_log/source_file.rb
method_log-0.0.6 lib/method_log/source_file.rb