Class: VCLog::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/vclog/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Tag

Setup new Tag intsance.

If :commit is not provided, it is assume that the underlying SCM simply creates tags as references to a commit. That is to say the tag information and the commit information are one and the same. This is the case for Hg, but not for Git, for instance.



50
51
52
53
54
55
56
# File 'lib/vclog/tag.rb', line 50

def initialize(data={})
  @commit = data.delete(:commit) || Change.new(data)

  data.each do |k,v|
    __send__("#{k}=", v)
  end
end

Instance Attribute Details

#author ⇒ Object Also known as: tagger, who

Creator to the tag.



24
25
26
# File 'lib/vclog/tag.rb', line 24

def author
  @author
end

#commit ⇒ Object

Last commit before Tag.



34
35
36
# File 'lib/vclog/tag.rb', line 34

def commit
  @commit
end

#date ⇒ Object

Date tag was made.



19
20
21
# File 'lib/vclog/tag.rb', line 19

def date
  @date
end

#files ⇒ Object



40
41
42
# File 'lib/vclog/tag.rb', line 40

def files
  @files
end

#id ⇒ Object

Tag's commit id.



9
10
11
# File 'lib/vclog/tag.rb', line 9

def id
  @id
end

#message ⇒ Object Also known as: msg

Tag message.



29
30
31
# File 'lib/vclog/tag.rb', line 29

def message
  @message
end

#name ⇒ Object Also known as: label, tag

Tag name, which in this case is typically a version stamp.



14
15
16
# File 'lib/vclog/tag.rb', line 14

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object

Normal tag order is the reverse typical sorts.



130
131
132
133
# File 'lib/vclog/tag.rb', line 130

def <=>(other)
  return -1 if name == 'HEAD'
  other.name <=> name
end

#inspect ⇒ Object

Inspection string for Tag.



122
123
124
125
# File 'lib/vclog/tag.rb', line 122

def inspect
  dstr = date ? date.strftime('%Y-%m-%d %H:%M:%S') : '(date?)'
  "<Tag #{name} #{dstr}>"
end

#parse_date(date) ⇒ Object (private)



140
141
142
143
144
145
146
147
# File 'lib/vclog/tag.rb', line 140

def parse_date(date)
  case date
  when Time
    date
  else
    Time.parse(date.to_s)
  end
end

#to_h ⇒ Object

Convert to Hash.



109
110
111
112
113
114
115
116
117
# File 'lib/vclog/tag.rb', line 109

def to_h
  {
    'name'    => name,
    'date'    => date,
    'author'  => author,
    'message' => message,
    'commit'  => commit.to_h
  }
end