Permalink
Browse files

Allow commandline args like 'xc:black'

  • Loading branch information...
1 parent 91c2338 commit 1738ea1dcaf65860c53088cc62ad7f0887e629ca @jyurek jyurek committed Mar 9, 2011
Showing with 12 additions and 1 deletion.
  1. +7 −1 lib/paperclip/command_line.rb
  2. +5 −0 test/command_line_test.rb
@@ -52,14 +52,20 @@ def interpolate(pattern, vars)
raise PaperclipCommandLineError,
"Interpolation of #{key} isn't allowed."
end
- shell_quote(vars[key.to_sym])
+ interpolation(vars, key) || match
end
end
def invalid_variables
%w(expected_outcodes swallow_stderr)
end
+ def interpolation(vars, key)
+ if vars.key?(key.to_sym)
+ shell_quote(vars[key.to_sym])
+ end
+ end
+
def shell_quote(string)
return "" if string.nil? or string.blank?
if self.class.unix?
@@ -6,6 +6,11 @@ def setup
File.stubs(:exist?).with("/dev/null").returns(true)
end
+ should "allow colons in parameters" do
+ cmd = Paperclip::CommandLine.new("convert", "'a.jpg' -resize 175x220> -size 175x220 xc:black +swap -gravity center -composite 'b.jpg'", :swallow_stderr => false)
+ assert_equal "convert 'a.jpg' -resize 175x220> -size 175x220 xc:black +swap -gravity center -composite 'b.jpg'", cmd.command
+ end
+
should "take a command and parameters and produce a shell command for bash" do
cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false)
assert_equal "convert a.jpg b.png", cmd.command

0 comments on commit 1738ea1

Please sign in to comment.