From 3872f411af2f0f1cc44b2e44d6aa0db94496baa6 Mon Sep 17 00:00:00 2001 From: Rob Dupuis Date: Tue, 26 May 2015 12:23:42 +0100 Subject: [PATCH] Introduce runtime(command) method Reduce complexity in the format_command_completion_status method --- lib/airbrussh/formatter.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/airbrussh/formatter.rb b/lib/airbrussh/formatter.rb index e00063f..0ca6d92 100644 --- a/lib/airbrussh/formatter.rb +++ b/lib/airbrussh/formatter.rb @@ -123,8 +123,7 @@ def write_command(command) end if command.finished? - status = format_command_completion_status(command) - print_line " #{status}" + print_line " #{format_exit_status(command)} #{runtime(command)}" end end @@ -148,22 +147,21 @@ def std_stream_lines(command, stream) end end - def format_command_completion_status(command) + def format_exit_status(command) user = command.user { command.host.user } host = command.host.to_s user_at_host = [user, host].join("@") number = number(command) - status = \ - if command.failure? - red("✘ #{number} #{user_at_host} (see #{@log_file} for details)") - else - green("✔ #{number} #{user_at_host}") - end - - runtime = light_black(format("%5.3fs", command.runtime)) + if command.failure? + red("✘ #{number} #{user_at_host} (see #{@log_file} for details)") + else + green("✔ #{number} #{user_at_host}") + end + end - status + " " + runtime + def runtime(command) + light_black(format("%5.3fs", command.runtime)) end def clock