Class: RightGit::Git::Tag

Inherits:
Object
  • Object
show all
Includes:
BelongsToRepository
Defined in:
lib/right_git/git/tag.rb

Overview

A tag in a Git repository.

Defined Under Namespace

Classes: TagError

Instance Attribute Summary collapse

Attributes included from BelongsToRepository

#repo

Instance Method Summary collapse

Methods included from BelongsToRepository

#logger

Constructor Details

#initialize(repo, name) ⇒ Tag

Returns a new instance of Tag.

Parameters:

  • repo (Repository)

    hosting tag

  • name (String)

    of tag



38
39
40
41
42
43
44
45
46
47
# File 'lib/right_git/git/tag.rb', line 38

def initialize(repo, name)
  # TEAL FIX: only invalid characters seem to be whitespace and some file
  # system special characters; need to locate a definitive schema for tag
  # names.
  if name.index(/\s|[:\\?*<>\|]/)
    raise TagError, 'name is invalid'
  end
  @repo = repo
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



32
33
34
# File 'lib/right_git/git/tag.rb', line 32

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Integer

Returns comparison value.

Parameters:

Returns:

  • (Integer)

    comparison value



71
72
73
74
75
76
77
# File 'lib/right_git/git/tag.rb', line 71

def <=>(other)
  if other.kind_of?(self.class)
    @name <=> other.name
  else
    raise ::ArgumentError, 'Wrong type'
  end
end

#==(other) ⇒ TrueClass|FalseClass

Returns true if equivalent.

Parameters:

Returns:

  • (TrueClass|FalseClass)

    true if equivalent



61
62
63
64
65
66
67
# File 'lib/right_git/git/tag.rb', line 61

def ==(other)
  if other.kind_of?(self.class)
    @name == other.name
  else
    false
  end
end

#deleteTrueClass

Deletes this tag.

Returns:

  • (TrueClass)

    always true



82
83
84
85
# File 'lib/right_git/git/tag.rb', line 82

def delete
  @repo.vet_output("tag -d #{@name}")
  true
end

#inspectString

Returns info about this Ruby object.

Returns:

  • (String)

    info about this Ruby object



55
56
57
# File 'lib/right_git/git/tag.rb', line 55

def inspect
  "#<#{self.class.name}:#{name.inspect}>"
end

#to_sString

Returns the tag’s name.

Returns:

  • (String)

    the tag’s name



50
51
52
# File 'lib/right_git/git/tag.rb', line 50

def to_s
  name
end