Sha256: a5111be7ddc863f54148e73a6e2bf927550dcdf8bc65324aa60c3072c40bed8e

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

module Perkins
  class Commit

    attr_reader :sha
    attr_accessor :branch

    def initialize(sha,  repo)
      return if sha.nil?
      @commit = repo.git.gcommit(sha)
      @sha = sha
    end

    def author
      @commit.author.name unless @commit.blank?
    end

    def email
      @commit.author.email unless @commit.blank?
    end

    def created_at
      @commit.author.date unless @commit.blank?
    end

    def message
      @commit.message unless @commit.blank?
    end

    def as_json(opts={})
      data = {}
      fields = [:author, :email, :created_at, :message, :sha]
      fields.each{|f| data[f] = send(f)}
      data
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
perkins-0.0.5 lib/perkins/commit.rb
perkins-0.0.3 lib/perkins/commit.rb
perkins-0.0.2 lib/perkins/commit.rb