Closed scalp42 closed 9 years ago
I added some printing output in the interpolate
method, the output is interesting when calling parse.run
once:
def interpolate(pattern, interpolations)
ap "in interpolate method"
interpolations = stringify_keys(interpolations)
res = pattern.gsub(/:\{?(\w+)\b\}?/) do |match|
key = match.tr(":{}", "")
if interpolations.key?(key)
shell_quote_all_values(interpolations[key])
else
match
end
end
ap res
res
end
"in interpolate method"
"'uptime' -s 'name:loadbalancer-i*' --timeout 1200 --quorum 10% --no-wait"
"in interpolate method"
":job -s :query --timeout 1200 --quorum 10% --no-wait"
Looks like it gets executed twice disregarding the interpolated one.
The problem is that you have to pass your interpolations to run
, not command
. The command
method just returns the command that will be run given the interpolations you pass in. It does not run the command and it does not change the state of the object.
First, thanks for the gem!
Please have a look at the following gist:
Where I would expect
parse.run
to run the following:it appears to run without interpolating:
Any idea @jyurek ?
Thanks in advance!