Class: Blastr::SourceControl::GitRevision

Inherits:
Object
  • Object
show all
Defined in:
lib/scm/git.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, date) ⇒ GitRevision

Returns a new instance of GitRevision.

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/scm/git.rb', line 18

def initialize(name, date)
  @name = name
  @date = date
  raise ArgumentError if date.nil? and name != "HEAD"
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



16
17
18
# File 'lib/scm/git.rb', line 16

def date
  @date
end

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/scm/git.rb', line 16

def name
  @name
end

Class Method Details

.headObject



34
35
36
# File 'lib/scm/git.rb', line 34

def self.head
  GitRevision.new("HEAD", nil)
end

Instance Method Details

#==(other) ⇒ Object



38
39
40
41
# File 'lib/scm/git.rb', line 38

def ==(other)
  return false unless other.is_a? GitRevision
  other.name == @name and other.date == @date
end

#before?(revision) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/scm/git.rb', line 28

def before?(revision)
  return false if @name == "HEAD"
  return true if revision.name == "HEAD"
  @date < revision.date
end

#to_sObject



24
25
26
# File 'lib/scm/git.rb', line 24

def to_s
  @name
end