Sha256: 2bee79ab11dd20916103aa7344ff42c6351d557a288f81e3b28160754f96953f

Contents?: true

Size: 605 Bytes

Versions: 2

Compression:

Stored size: 605 Bytes

Contents

module RightDevelop::Git
  # A commit within a Git repository.
  class Commit
    COMMIT_INFO     = /([0-9A-Fa-f]+) ([0-9]+) (.*)/

    def initialize(repo, line)
      @repo = repo
      match = COMMIT_INFO.match(line)
      raise FormatError, "Unrecognized commit summary '#{line}'" unless match && match.length >= 3
      @info = [ match[1], match[2], match[3] ]
    end

    def to_s
      @info.join(' ')
    end

    def hash
      # This overrides String#hash on purpose
      @info[0]
    end

    def timestamp
      Time.at(@info[1].to_i)
    end

    def author
      @info[2]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
right_develop-1.2.2 lib/right_develop/git/commit.rb
right_develop-1.2.0 lib/right_develop/git/commit.rb