Class: V::Adapters::Git::Commits

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/v/adapters/git/commits.rb

Instance Method Summary collapse

Constructor Details

#initialize(environment, branch, path) ⇒ Commits

Returns a new instance of Commits.



7
8
9
# File 'lib/v/adapters/git/commits.rb', line 7

def initialize(environment, branch, path)
  @environment, @branch, @path = environment, branch, path
end

Instance Method Details

#eachObject

TODO: work with chunks (see –max-count and –skip).



19
20
21
22
23
24
# File 'lib/v/adapters/git/commits.rb', line 19

def each
  commits = to_commit names_reversed
  commits.each { |commit| yield commit } if block_given?

  commits
end

#first(*n) ⇒ Object



11
12
13
# File 'lib/v/adapters/git/commits.rb', line 11

def first(*n)
  to_commit names_reversed.last(*n)
end

#include?(commit) ⇒ Boolean

Returns true if name of commit is included in names of commits.

Returns:

  • (Boolean)


27
28
29
# File 'lib/v/adapters/git/commits.rb', line 27

def include?(commit)
  names_reversed.include? commit.name
end

#last(*n) ⇒ Object



14
15
16
# File 'lib/v/adapters/git/commits.rb', line 14

def last(*n)
  to_commit names_reversed.first(*n)
end

#sizeObject Also known as: length

Returns the number of commits.



32
33
34
# File 'lib/v/adapters/git/commits.rb', line 32

def size
  names_reversed.size
end