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.



27
28
29
30
31
# File 'lib/machines/command.rb', line 27

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

Class Attribute Details

.consoleObject

Returns the value of attribute console.



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

def console
  @console
end

.debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

.fileObject

Returns the value of attribute file.



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

def file
  @file
end

Instance Attribute Details

#checkObject

Returns the value of attribute check.



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

def check
  @check
end

#commandObject

Returns the value of attribute command.



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

def command
  @command
end

Class Method Details

.scpObject



23
24
25
# File 'lib/machines/command.rb', line 23

def self.scp
  @@scp
end

.scp=(scp) ⇒ Object



11
12
13
# File 'lib/machines/command.rb', line 11

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

.sshObject



19
20
21
# File 'lib/machines/command.rb', line 19

def self.ssh
  @@ssh
end

.ssh=(ssh) ⇒ Object



15
16
17
# File 'lib/machines/command.rb', line 15

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

Instance Method Details

#infoObject



41
42
43
# File 'lib/machines/command.rb', line 41

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

#runObject



37
38
39
# File 'lib/machines/command.rb', line 37

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

#use_sudoObject



33
34
35
# File 'lib/machines/command.rb', line 33

def use_sudo
  @sudo = 'sudo'
end