Class: GitWrapper::Commands::Remote

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

Instance Attribute Summary

Attributes inherited from Git

#error, #location_folder, #output

Instance Method Summary collapse

Methods inherited from Git

#execute, #initialize, #success?

Constructor Details

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

Instance Method Details

#add(url) ⇒ Object



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

def add(url)
  @url = url
  @mode = :add
  self
end

#commandObject



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

def command
  command = "remote "

  if @mode == :add
    command += "add #{@name} \"#{@url}\""
  elsif @mode == :remove
    command += "rm #{@name}"
  elsif @mode == :list
    command += "show"
  else
    raise "Unespecified remote mode"
  end

  command
end

#listObject



21
22
23
24
# File 'lib/git_wrapper/commands/remote.rb', line 21

def list
  @mode = :list
  self
end

#name(name) ⇒ Object



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

def name(name)
  @name = name
  self
end

#removeObject



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

def remove
  @mode = :remove
  self
end

#resultObject



42
43
44
45
# File 'lib/git_wrapper/commands/remote.rb', line 42

def result
  return @output.split(/\n/) if @mode == :list
  super
end