Class: Git::Log::Commit
- Inherits:
-
Object
- Object
- Git::Log::Commit
- Defined in:
- lib/Git/Log.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#hash ⇒ Object
readonly
class << self.
-
#merge ⇒ Object
readonly
Returns the value of attribute merge.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ Commit
constructor
A new instance of Commit.
Constructor Details
#initialize(values = {}) ⇒ Commit
Returns a new instance of Commit.
66 67 68 69 70 71 72 |
# File 'lib/Git/Log.rb', line 66 def initialize(values = {}) @hash = values[:hash] @merge = values[:merge] @author = values[:author] @date = values[:date] @message = values[:message] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
62 63 64 |
# File 'lib/Git/Log.rb', line 62 def @author end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
63 64 65 |
# File 'lib/Git/Log.rb', line 63 def date @date end |
#hash ⇒ Object (readonly)
class << self
60 61 62 |
# File 'lib/Git/Log.rb', line 60 def hash @hash end |
#merge ⇒ Object (readonly)
Returns the value of attribute merge.
61 62 63 |
# File 'lib/Git/Log.rb', line 61 def merge @merge end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
64 65 66 |
# File 'lib/Git/Log.rb', line 64 def @message end |
Class Method Details
.parse(commit_string) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/Git/Log.rb', line 29 def parse(commit_string) hash = merge = = date = = '' commit_string.split("\n").each do |line| case line.strip when /^commit (\w+)/ hash = line.strip.capture(/^commit (\w+)/) when /^Merge: / merge = line.strip.gsub(/^Merge: /, '') when /^Author: / = line.strip.gsub(/^Author: /, '') when /^Date: / date = line.strip.gsub(/^Date: /, '') else if line.strip.empty? ( ||= '') << "\n\n" else ( ||= '') << line.lstrip end end end commit_args = { hash: hash, author: , date: date, message: .lstrip } commit_args.merge!(merge: merge) Commit.new(commit_args) end |