Class: Kettle::Family::CommandRunner
- Inherits:
-
Object
- Object
- Kettle::Family::CommandRunner
- Defined in:
- lib/kettle/family/command_runner.rb
Instance Method Summary collapse
- #call(member:, phase:, command:, env: {}, interactive: false) ⇒ Object
-
#initialize(execute: false, gem_signing_password: nil) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
Constructor Details
#initialize(execute: false, gem_signing_password: nil) ⇒ CommandRunner
Returns a new instance of CommandRunner.
8 9 10 11 |
# File 'lib/kettle/family/command_runner.rb', line 8 def initialize(execute: false, gem_signing_password: nil) @execute = execute @gem_signing_password = gem_signing_password end |
Instance Method Details
#call(member:, phase:, command:, env: {}, interactive: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kettle/family/command_runner.rb', line 13 def call(member:, phase:, command:, env: {}, interactive: false) argv = command_argv(member: member, command: command) return skipped_result(member: member, phase: phase, argv: argv) unless execute started = Process.clock_gettime(Process::CLOCK_MONOTONIC) stdout, stderr, status = if interactive run_interactive(env: env, argv: argv, chdir: member.root) else Open3.capture3(env, *argv, chdir: member.root) end elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started CommandResult.new( member_name: member.name, phase: phase, command: argv, workdir: member.root, status: status.exitstatus, success: status.success?, stdout: stdout, stderr: stderr, elapsed_seconds: elapsed.round(3), skipped: false, reason: status.success? ? nil : "command failed" ) end |