Class: TDX::Exec

Inherits:
Object
  • Object
show all
Defined in:
lib/tdx/exec.rb

Overview

Command line executor

Instance Method Summary collapse

Constructor Details

#initialize(cmd, dir = '.') ⇒ Exec

Returns a new instance of Exec.



36
37
38
39
40
# File 'lib/tdx/exec.rb', line 36

def initialize(cmd, dir = '.')
  @cmd = cmd
  @dir = dir
  @log = false
end

Instance Method Details

#stdoutObject



42
43
44
45
46
47
48
# File 'lib/tdx/exec.rb', line 42

def stdout
  puts "+ #{@cmd}" if @log
  out = `cd #{@dir} && #{@cmd}`
  raise "This one failed: #{@cmd}" unless $CHILD_STATUS.exitstatus == 0
  puts out if @log
  out
end