Class: Perkins::Commit
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Instance Method Summary collapse
- #as_json(opts = {}) ⇒ Object
- #author ⇒ Object
- #created_at ⇒ Object
- #email ⇒ Object
-
#initialize(sha, repo) ⇒ Commit
constructor
A new instance of Commit.
- #message ⇒ Object
Constructor Details
#initialize(sha, repo) ⇒ Commit
Returns a new instance of Commit.
7 8 9 10 11 |
# File 'lib/perkins/commit.rb', line 7 def initialize(sha, repo) return if sha.nil? @commit = repo.git.gcommit(sha) @sha = sha end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
5 6 7 |
# File 'lib/perkins/commit.rb', line 5 def branch @branch end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
4 5 6 |
# File 'lib/perkins/commit.rb', line 4 def sha @sha end |
Instance Method Details
#as_json(opts = {}) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/perkins/commit.rb', line 29 def as_json(opts={}) data = {} fields = [:author, :email, :created_at, :message, :sha] fields.each{|f| data[f] = send(f)} data end |
#author ⇒ Object
13 14 15 |
# File 'lib/perkins/commit.rb', line 13 def @commit..name unless @commit.blank? end |
#created_at ⇒ Object
21 22 23 |
# File 'lib/perkins/commit.rb', line 21 def created_at @commit..date unless @commit.blank? end |
#email ⇒ Object
17 18 19 |
# File 'lib/perkins/commit.rb', line 17 def email @commit..email unless @commit.blank? end |
#message ⇒ Object
25 26 27 |
# File 'lib/perkins/commit.rb', line 25 def @commit. unless @commit.blank? end |