Sha256: 4190a8964dcff5e60db2bcafda41ffa684f45bc899876bfe07ad952ab60c4a26

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

module MethodLog
  class MethodCommit
    attr_reader :method_definition

    def initialize(commit, method_definition)
      @commit = commit
      @method_definition = method_definition
    end

    def update(commit)
      @commit = commit
    end

    def ==(other)
      (commit == other.commit) && (method_definition == other.method_definition)
    end

    def hash
      [commit, method_definition].hash
    end

    def sha
      commit.sha
    end

    def author
      commit.author
    end

    def message
      commit.message
    end

    def method_source
      method_definition && method_definition.source + $/
    end

    def source_file
      method_definition && method_definition.source_file
    end

    def to_s
      [
        "commit #{sha}",
        "Author: #{author[:name]} <#{author[:email]}>",
        "Date:   #{author[:time].strftime('%a %b %-e %T %Y %z')}",
        '',
        message
      ].join($/)
    end

    protected

    attr_reader :commit
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
method_log-0.2.1 lib/method_log/method_commit.rb
method_log-0.2.0 lib/method_log/method_commit.rb