Commit c9205f4f by Jon Yurek

Ok, so spawn doesn't work exactly right yet.

parent 701abb01
...@@ -60,7 +60,8 @@ module Paperclip ...@@ -60,7 +60,8 @@ module Paperclip
:whiny_thumbnails => true, :whiny_thumbnails => true,
:image_magick_path => nil, :image_magick_path => nil,
:command_path => nil, :command_path => nil,
:log => true :log => true,
:swallow_stderr => true
} }
end end
...@@ -84,7 +85,9 @@ module Paperclip ...@@ -84,7 +85,9 @@ module Paperclip
# expected_outcodes, a PaperclipCommandLineError will be raised. Generally # expected_outcodes, a PaperclipCommandLineError will be raised. Generally
# a code of 0 is expected, but a list of codes may be passed if necessary. # a code of 0 is expected, but a list of codes may be passed if necessary.
def run cmd, params = "", expected_outcodes = 0 def run cmd, params = "", expected_outcodes = 0
output = `#{%Q[#{path_for_command(cmd)} #{params} 2>#{bit_bucket}].gsub(/\s+/, " ")}` command = %Q<#{%Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")}>
command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
output = `#{command}`
unless [expected_outcodes].flatten.include?($?.exitstatus) unless [expected_outcodes].flatten.include?($?.exitstatus)
raise PaperclipCommandLineError, "Error while running #{cmd}" raise PaperclipCommandLineError, "Error while running #{cmd}"
end end
......
...@@ -353,11 +353,11 @@ module Paperclip ...@@ -353,11 +353,11 @@ module Paperclip
# When processing, if the spawn plugin is installed, processing can be done in # When processing, if the spawn plugin is installed, processing can be done in
# a background fork or thread if desired. # a background fork or thread if desired.
def background(&blk) def background(&blk)
if instance.respond_to?(:spawn) && @background # if instance.respond_to?(:spawn) && @background
instance.spawn(&blk) # instance.spawn(&blk)
else # else
blk.call blk.call
end # end
end end
def callback which #:nodoc: def callback which #:nodoc:
......
...@@ -232,19 +232,19 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -232,19 +232,19 @@ class AttachmentTest < Test::Unit::TestCase
end end
end end
context "When spawn is defined on the instance" do # context "When spawn is defined on the instance" do
setup do # setup do
Dummy.any_instance.stubs(:spawn) # Dummy.any_instance.stubs(:spawn)
rebuild_model :styles => {:foo => true} # rebuild_model :styles => {:foo => true}
@dummy = Dummy.new # @dummy = Dummy.new
@file = StringIO.new("12345") # @file = StringIO.new("12345")
end # end
should "not call spawn on the instance when assigned a file" do # should "not call spawn on the instance when assigned a file" do
@dummy.expects(:spawn) # @dummy.expects(:spawn)
@dummy.avatar = @file # @dummy.avatar = @file
end # end
end # end
context "An attachment with no processors defined" do context "An attachment with no processors defined" do
setup do setup 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