Module: Aai::CoreExtensions::Process
- Includes:
- Time
- Defined in:
- lib/aai/core_extensions.rb
Instance Method Summary collapse
-
#run_and_time_it!(title = "", cmd = "", logger = AbortIf::logger, &b) ⇒ Object
Examples.
- #run_it(*a, &b) ⇒ Object
- #run_it!(*a, &b) ⇒ Object
Methods included from Time
Instance Method Details
#run_and_time_it!(title = "", cmd = "", logger = AbortIf::logger, &b) ⇒ Object
Examples
Process.extend CoreExtensions::Process Time.extend CoreExtensions::Time
Process.run_and_time_it! “Saying hello”,
%Q{echo "hello world"}
Process.run_and_time_it! “This will raise SystemExit”,
"ls arstoeiarntoairnt" do
puts "i like pie"
end
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/aai/core_extensions.rb', line 69 def run_and_time_it! title="", cmd="", logger=AbortIf::logger, &b AbortIf.logger.debug { "Running: #{cmd}" } time_it title, logger do run_it! cmd, &b end end |
#run_it(*a, &b) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/aai/core_extensions.rb', line 34 def run_it *a, &b exit_status, stdout, stderr = systemu *a, &b puts stdout unless stdout.empty? $stderr.puts stderr unless stderr.empty? exit_status end |
#run_it!(*a, &b) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/aai/core_extensions.rb', line 43 def run_it! *a, &b exit_status = self.run_it *a, &b # Sometimes, exited? is not true and there will be no exit # status. Success should catch all failures. AbortIf.abort_unless exit_status.success?, "Command failed with status " + "'#{exit_status.to_s}' " + "when running '#{a.inspect}', " + "'#{b.inspect}'" exit_status end |