class VCLog::Tag

Attributes

author[RW]

Creator to the tag.

commit[RW]

Last commit before Tag.

date[RW]

Date tag was made.

files[RW]

@todo Hg is using this at the moment but it really shouldn’t be here,

since it is take care of by `commit.files`.
id[RW]

Tag’s commit id.

label[RW]

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

message[RW]

Tag message.

msg[RW]

Tag message.

name[RW]

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

tag[RW]

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

tagger[RW]

Creator to the tag.

who[RW]

Creator to the tag.

Public Class Methods

new(data={}) click to toggle source

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.

# 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

Public Instance Methods

<=>(other) click to toggle source

Normal tag order is the reverse typical sorts.

# File lib/vclog/tag.rb, line 130
def <=>(other)
  return -1 if name == 'HEAD'
  other.name <=> name
end
author=(author) click to toggle source

Set author name, stripping white space.

# File lib/vclog/tag.rb, line 74
def author=(author)
  @author = author.to_s.strip
end
Also aliased as: tagger=, who=
date=(date) click to toggle source

Set the tag date, converting date to a Time object.

# File lib/vclog/tag.rb, line 89
def date=(date)
  @date = parse_date(date)
end
inspect() click to toggle source

Inspection string for Tag.

# File lib/vclog/tag.rb, line 122
def inspect
  dstr = date ? date.strftime('%Y-%m-%d %H:%M:%S') : '(date?)'
  "<Tag #{name} #{dstr}>"
end
label=(name)
Alias for: name=
message=(msg) click to toggle source

Set the tag message.

# File lib/vclog/tag.rb, line 96
def message=(msg)
  @message = msg.strip
end
Also aliased as: msg=
msg=(msg)
Alias for: message=
name=(name) click to toggle source

Set the tag name.

# File lib/vclog/tag.rb, line 61
def name=(name)
  @name = (name || 'HEAD').strip
end
Also aliased as: label=, tag=
tag=(name)
Alias for: name=
tagger=(author)
Alias for: author=
to_h() click to toggle source

Convert to Hash.

# File lib/vclog/tag.rb, line 109
def to_h
  {
    'name'    => name,
    'date'    => date,
    'author'  => author,
    'message' => message,
    'commit'  => commit.to_h
  }
end
who=(author)
Alias for: author=

Private Instance Methods

parse_date(date) click to toggle source
# File lib/vclog/tag.rb, line 140
def parse_date(date)
  case date
  when Time
    date
  else
    Time.parse(date.to_s)
  end
end