Class: Scripted::Commands::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/scripted/commands/shell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Shell

Returns a new instance of Shell.



9
10
11
# File 'lib/scripted/commands/shell.rb', line 9

def initialize(command)
  @command = command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/scripted/commands/shell.rb', line 7

def command
  @command
end

Instance Method Details

#execute!(log = STDOUT) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scripted/commands/shell.rb', line 13

def execute!(log = STDOUT)
  process = ChildProcess.build(command)

  process.io.stdout = log
  process.io.stderr = log
  process.start

  process.wait
  if process.exit_code != 0
    fail CommandFailed, "`#{command}` failed with exit status #{process.exit_code}"
  end
end