Commit 634864d7 by Jon Yurek

Log commands with Paperclip.options[:log_command] = true

parent af1ae004
......@@ -62,6 +62,7 @@ module Paperclip
:image_magick_path => nil,
:command_path => nil,
:log => true,
:log_command => false,
:swallow_stderr => true
}
end
......@@ -90,6 +91,7 @@ module Paperclip
def run cmd, params = "", expected_outcodes = 0
command = %Q<#{%Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")}>
command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
Paperclip.log(command) if Paperclip.options[:log_command]
output = `#{command}`
unless [expected_outcodes].flatten.include?($?.exitstatus)
raise PaperclipCommandLineError, "Error while running #{cmd}"
......
......@@ -30,6 +30,14 @@ class PaperclipTest < Test::Unit::TestCase
Paperclip.expects(:"`").with("convert one.jpg two.jpg 2>/dev/null")
Paperclip.run("convert", "one.jpg two.jpg")
end
should "log the command when :log_command is set" do
Paperclip.options[:log_command] = true
Paperclip.expects(:bit_bucket).returns("/dev/null")
Paperclip.expects(:log).with("this is the command 2>/dev/null")
Paperclip.expects(:"`").with("this is the command 2>/dev/null")
Paperclip.run("this","is the command")
end
end
should "raise when sent #processor and the name of a class that exists but isn't a subclass of Processor" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment