Commit 169dee4d by Juanjo Bazán

Processor#identify and #convert instance methods

parent 34f44993
......@@ -32,6 +32,18 @@ module Paperclip
def self.make file, options = {}, attachment = nil
new(file, options, attachment).make
end
# The convert method runs the convert binary with the provided arguments.
# See Paperclip.run for the available options.
def convert(arguments = "", local_options = {})
Paperclip.run('convert', arguments, local_options)
end
# The identify method runs the identify binary with the provided arguments.
# See Paperclip.run for the available options.
def identify(arguments = "", local_options = {})
Paperclip.run('identify', arguments, local_options)
end
end
module ProcessorHelpers
......
......@@ -73,7 +73,7 @@ module Paperclip
parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
success = Paperclip.run("convert", parameters, :source => "#{File.expand_path(src.path)}#{'[0]' unless animated?}", :dest => File.expand_path(dst.path))
success = convert(parameters, :source => "#{File.expand_path(src.path)}#{'[0]' unless animated?}", :dest => File.expand_path(dst.path))
rescue Cocaine::ExitStatusError => e
raise Paperclip::Error, "There was an error processing the thumbnail for #{@basename}" if @whiny
rescue Cocaine::CommandNotFoundError => e
......
......@@ -7,4 +7,20 @@ class ProcessorTest < Test::Unit::TestCase
Paperclip::Processor.expects(:new).with(:one, :two, :three).returns(processor)
Paperclip::Processor.make(:one, :two, :three)
end
context "Calling #convert" do
should "run the convert command with Cocaine" do
Paperclip.options[:log_command] = false
Cocaine::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
Paperclip::Processor.new('filename').convert("stuff")
end
end
context "Calling #identify" do
should "run the identify command with Cocaine" do
Paperclip.options[:log_command] = false
Cocaine::CommandLine.expects(:new).with("identify", "stuff", {}).returns(stub(:run))
Paperclip::Processor.new('filename').identify("stuff")
end
end
end
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