Class: Kdeploy::CommandExecutor
- Inherits:
-
Object
- Object
- Kdeploy::CommandExecutor
- Defined in:
- lib/kdeploy/command_executor.rb
Overview
Executes a single command and records execution time
Instance Method Summary collapse
- #execute_run(command, host_name) ⇒ Object
- #execute_upload(command, host_name) ⇒ Object
- #execute_upload_template(command, host_name) ⇒ Object
-
#initialize(executor, output) ⇒ CommandExecutor
constructor
A new instance of CommandExecutor.
Constructor Details
#initialize(executor, output) ⇒ CommandExecutor
Returns a new instance of CommandExecutor.
6 7 8 9 |
# File 'lib/kdeploy/command_executor.rb', line 6 def initialize(executor, output) @executor = executor @output = output end |
Instance Method Details
#execute_run(command, host_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kdeploy/command_executor.rb', line 11 def execute_run(command, host_name) cmd = command[:command] use_sudo = command[:sudo] show_command_header(host_name, :run, cmd) result, duration = measure_time do @executor.execute(cmd, use_sudo: use_sudo) end show_command_output(result) { command: cmd, output: result, duration: duration, type: :run } end |
#execute_upload(command, host_name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kdeploy/command_executor.rb', line 22 def execute_upload(command, host_name) show_command_header(host_name, :upload, "#{command[:source]} -> #{command[:destination]}") _result, duration = measure_time do @executor.upload(command[:source], command[:destination]) end { command: "upload: #{command[:source]} -> #{command[:destination]}", duration: duration, type: :upload } end |
#execute_upload_template(command, host_name) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kdeploy/command_executor.rb', line 34 def execute_upload_template(command, host_name) show_command_header(host_name, :upload_template, "#{command[:source]} -> #{command[:destination]}") _result, duration = measure_time do @executor.upload_template(command[:source], command[:destination], command[:variables]) end { command: "upload_template: #{command[:source]} -> #{command[:destination]}", duration: duration, type: :upload_template } end |