Skip to content

Commit

Permalink
Extract quoting an array into a method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Nov 15, 2013
1 parent c743ecc commit 20c0469
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/cocaine/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def interpolate(pattern, interpolations)
pattern.gsub(/:\{?(\w+)\b\}?/) do |match|
key = match.tr(":{}", "")
if interpolations.key?(key)
Array(interpolations[key]).map { |value| shell_quote(value) }.join(" ")
shell_quote_all_values(interpolations[key])
else
match
end
Expand All @@ -141,6 +141,12 @@ def stringify_keys(hash)
hash
end

def shell_quote_all_values(values)
Array(values).map do |value|
shell_quote(value)
end.join(" ")
end

def shell_quote(string)
return "" if string.nil?
if unix?
Expand Down

0 comments on commit 20c0469

Please sign in to comment.