Class: Machines::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/machines/command.rb

Direct Known Subclasses

LogCommand, Upload

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, check) ⇒ Command

Returns a new instance of Command.



25
26
27
28
29
# File 'lib/machines/command.rb', line 25

def initialize(command, check)
  @command = command
  @check = check
  @sudo = false
end

Class Attribute Details

.consoleObject

Returns the value of attribute console.



4
5
6
# File 'lib/machines/command.rb', line 4

def console
  @console
end

.debugObject

Returns the value of attribute debug.



4
5
6
# File 'lib/machines/command.rb', line 4

def debug
  @debug
end

.fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/machines/command.rb', line 4

def file
  @file
end

Instance Attribute Details

#checkObject

Returns the value of attribute check.



7
8
9
# File 'lib/machines/command.rb', line 7

def check
  @check
end

#commandObject

Returns the value of attribute command.



7
8
9
# File 'lib/machines/command.rb', line 7

def command
  @command
end

Class Method Details

.scpObject



21
22
23
# File 'lib/machines/command.rb', line 21

def self.scp
  @@scp
end

.scp=(scp) ⇒ Object



9
10
11
# File 'lib/machines/command.rb', line 9

def self.scp= scp
  @@scp = scp
end

.sshObject



17
18
19
# File 'lib/machines/command.rb', line 17

def self.ssh
  @@ssh
end

.ssh=(ssh) ⇒ Object



13
14
15
# File 'lib/machines/command.rb', line 13

def self.ssh= ssh
  @@ssh = ssh
end

Instance Method Details

#infoObject



39
40
41
# File 'lib/machines/command.rb', line 39

def info
  ("%-6s " % (@sudo ? 'SUDO' : 'RUN')) + command
end

#runObject



35
36
37
# File 'lib/machines/command.rb', line 35

def run
  process {Command.file.log @@ssh.exec! wrap_in_export_and_sudo(@command)}
end

#use_sudoObject



31
32
33
# File 'lib/machines/command.rb', line 31

def use_sudo
  @sudo = 'sudo'
end