Module: PasvLib::CoreExtensions::Process
- Includes:
- Time
- Defined in:
- lib/pasv_lib.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
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pasv_lib.rb', line 79 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
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pasv_lib.rb', line 41 def run_it *a, &b exit_status, stdout, stderr = SystemUniversal::Run.systemu *a, &b puts stdout unless stdout.empty? unless stderr.empty? || stderr.include?("Insecure world writable dir") $stderr.puts stderr end exit_status end |
#run_it!(*a, &b) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pasv_lib.rb', line 53 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 |