Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Processor#identify and #convert instance methods

  • Loading branch information...
commit 169dee4d2463acf46a592b4996212e1132010c9f 1 parent 34f4499
@xuanxu xuanxu authored
View
12 lib/paperclip/processor.rb
@@ -32,6 +32,18 @@ def make
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
View
2  lib/paperclip/thumbnail.rb
@@ -73,7 +73,7 @@ def make
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
View
16 test/processor_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.