From 01851c28720ce6d5ebdd53613b8596b6e5db4bd2 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 17 May 2017 09:04:05 -0400 Subject: [PATCH] refactor into new Environment#command_to_s --- lib/rscons/environment.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 74f3c11..9894539 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -337,11 +337,8 @@ module Rscons # # @return [true,false,nil] Return value from Kernel.system(). def execute(short_desc, command, options = {}) - print_command = proc do - puts command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ') - end if @echo == :command - print_command.call + puts command_to_s(command) elsif @echo == :short puts short_desc end @@ -350,7 +347,7 @@ module Rscons system(*env_args, *Rscons.command_executer, *command, *options_args).tap do |result| unless result or @echo == :command $stdout.write "Failed command was: " - print_command.call + puts command_to_s(command) end end end @@ -751,6 +748,17 @@ module Rscons private + # Return a string representation of a command. + # + # @param command [Array] + # The command. + # + # @return [String] + # The string representation of the command. + def command_to_s(command) + command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ') + end + # Parse dependencies for a given target from a Makefile. # # This method is used internally by Rscons builders.