Class: GitWrapper::Commands::Tag

Inherits:
Git
  • Object
show all
Defined in:
lib/git_wrapper/commands/tag.rb

Instance Attribute Summary

Attributes inherited from Git

#error, #location_folder, #output

Instance Method Summary collapse

Methods inherited from Git

#execute, #initialize, #to_relative_path

Constructor Details

This class inherits a constructor from GitWrapper::Commands::Git

Instance Method Details

#commandObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/git_wrapper/commands/tag.rb', line 27

def command
  command = 'tag '

  if @mode == :create
    command += "#{@name} #{@commit.nil? ? '' : @commit}"
  elsif @mode == :remove
    command += "-d #{@name}"
  elsif @mode == :list
    #Nothing to add
  else
    raise 'Unespecified tag mode'
  end

  command
end

#create(name) ⇒ Object



5
6
7
8
9
# File 'lib/git_wrapper/commands/tag.rb', line 5

def create(name)
  @mode = :create
  @name = name
  self
end

#from(commit) ⇒ Object



11
12
13
14
# File 'lib/git_wrapper/commands/tag.rb', line 11

def from(commit)
  @commit = commit
  self
end

#listObject



22
23
24
25
# File 'lib/git_wrapper/commands/tag.rb', line 22

def list
  @mode = :list
  self
end

#remove(name) ⇒ Object



16
17
18
19
20
# File 'lib/git_wrapper/commands/tag.rb', line 16

def remove(name)
  @mode = :remove
  @name = name
  self
end

#resultObject



43
44
45
46
# File 'lib/git_wrapper/commands/tag.rb', line 43

def result
  return result_list if @mode == :list
  super
end

#result_listObject



48
49
50
# File 'lib/git_wrapper/commands/tag.rb', line 48

def result_list
  output.split("\n")
end