Class: Soaring::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/soaring/tools.rb

Class Method Summary collapse

Class Method Details

.execute(command) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/soaring/tools.rb', line 5

def self.execute(command)
  captured_stdout = ''
  captured_stderr = ''
  exit_status = Open3.popen3(ENV, command) {|stdin, stdout, stderr, wait_thr|
    pid = wait_thr.pid # pid of the started process.
    stdin.close
    captured_stdout = stdout.read
    captured_stderr = stderr.read
    wait_thr.value # Process::Status object returned.
  }
  ["#{captured_stdout}#{captured_stderr}", exit_status]
end