Class: Git::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/Git/Log.rb

Defined Under Namespace

Classes: Commit

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commits = []) ⇒ Log

Returns a new instance of Log.



101
102
103
# File 'lib/Git/Log.rb', line 101

def initialize(commits = [])
  @commits = commits
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



110
111
112
# File 'lib/Git/Log.rb', line 110

def method_missing(method_name, *args, &block)
  commits.send(method_name, *args, &block)
end

Class Attribute Details

.commitsObject (readonly)

Returns the value of attribute commits.



80
81
82
# File 'lib/Git/Log.rb', line 80

def commits
  @commits
end

Instance Attribute Details

#commitsObject (readonly)

class << self



99
100
101
# File 'lib/Git/Log.rb', line 99

def commits
  @commits
end

Class Method Details

.parse(log_stream) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/Git/Log.rb', line 82

def parse(log_stream)
  commit_log = Log.new
  commit_string = ''
  log_stream.each_line do |line|
    if line =~ /^commit/ && !commit_string.empty?
      commit_log.prepend(Commit.parse(commit_string))
      commit_string = line
    else
      commit_string << line
    end
  end
  commit_log.prepend(Commit.parse(commit_string))
  commit_log
end

Instance Method Details

#prepend(commit_object) ⇒ Object Also known as: unshift



105
106
107
# File 'lib/Git/Log.rb', line 105

def prepend(commit_object)
  commits.unshift(commit_object)
end