From 9d61fa027630c2a41e6d8fefa41706d59ffb39ea Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 14 May 2014 14:33:09 -0400 Subject: [PATCH] merge Environment#build_command and #expand_varref --- lib/rscons/environment.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index f6bad7d..2a5881e 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -209,22 +209,22 @@ module Rscons @targets = {} end - # Build a command line from the given template, resolving references to - # variables using the Environment's construction variables and any extra - # variables specified. - # @param command_template [Array] template for the command with variable - # references - # @param extra_vars [Hash, VarSet] extra variables to use in addition to - # (or replace) the Environment's construction variables when building - # the command - def build_command(command_template, extra_vars) - @varset.merge(extra_vars).expand_varref(command_template) - end - - # Expand a construction variable reference (String or Array) - def expand_varref(varref) - @varset.expand_varref(varref) + # Expand a construction variable reference. + # + # @param varref [Array, String] Variable reference to expand. + # @param extra_vars [Hash, VarSet] + # Extra variables to use in addition to (or replace) the Environment's + # construction variables when expanding the variable reference. + # + # @return [Array, String] Expansion of the variable reference. + def expand_varref(varref, extra_vars = nil) + if extra_vars.nil? + @varset + else + @varset.merge(extra_vars) + end.expand_varref(varref) end + alias_method :build_command, :expand_varref # Execute a builder command # @param short_desc [String] Message to print if the Environment's echo