Class: RightGit::Git::Tag

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

Overview

A tag in a Git repository.

Defined Under Namespace

Classes: TagError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, name) ⇒ Tag

Returns a new instance of Tag.

Parameters:

  • repo (Repository)

    hosting tag

  • name (String)

    of tag



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

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.



30
31
32
# File 'lib/right_git/git/tag.rb', line 30

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo.



30
31
32
# File 'lib/right_git/git/tag.rb', line 30

def repo
  @repo
end

Instance Method Details

#<=>(other) ⇒ Integer

Returns comparison value.

Parameters:

Returns:

  • (Integer)

    comparison value



65
66
67
68
69
70
71
# File 'lib/right_git/git/tag.rb', line 65

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



55
56
57
58
59
60
61
# File 'lib/right_git/git/tag.rb', line 55

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

#deleteTrueClass

Deletes this tag.

Returns:

  • (TrueClass)

    always true



76
77
78
79
# File 'lib/right_git/git/tag.rb', line 76

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

#to_sString Also known as: inspect

Returns stringized.

Returns:

  • (String)

    stringized



48
49
50
# File 'lib/right_git/git/tag.rb', line 48

def to_s
  "#{self.class.name}: #{@name.inspect}"
end