Class: Thrust::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/thrust/executor.rb

Constant Summary collapse

CommandFailed =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#capture_output_from_system(cmd) ⇒ Object

Raises:



14
15
16
17
18
19
# File 'lib/thrust/executor.rb', line 14

def capture_output_from_system(cmd)
  captured_output = `#{cmd}`
  raise(CommandFailed, '******** Build failed ********') if $?.exitstatus > 0

  captured_output
end

#check_command_for_failure(cmd) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/thrust/executor.rb', line 21

def check_command_for_failure(cmd)
  STDERR.puts "Executing #{cmd} and checking for FAILURE"
  result = %x[#{cmd} 2>&1]
  STDERR.puts "Results:"
  STDERR.puts result

  result.include?("Finished") && !result.include?("FAILURE") && !result.include?("EXCEPTION")
end

#system(cmd, output_file = nil) ⇒ Object



8
9
10
11
12
# File 'lib/thrust/executor.rb', line 8

def system(cmd, output_file = nil)
  STDERR.puts "Executing #{cmd}"
  cmd += " > #{output_file}" if output_file
  Kernel::system(cmd)
end

#system_or_exit(cmd, output_file = nil) ⇒ Object



4
5
6
# File 'lib/thrust/executor.rb', line 4

def system_or_exit(cmd, output_file = nil)
  system(cmd, output_file) or raise(CommandFailed, '******** Build failed ********')
end