Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
c9205f4f
Commit
c9205f4f
authored
Jan 04, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ok, so spawn doesn't work exactly right yet.
parent
701abb01
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
19 deletions
+22
-19
lib/paperclip.rb
+5
-2
lib/paperclip/attachment.rb
+4
-4
test/attachment_test.rb
+13
-13
No files found.
lib/paperclip.rb
View file @
c9205f4f
...
...
@@ -60,7 +60,8 @@ module Paperclip
:whiny_thumbnails
=>
true
,
:image_magick_path
=>
nil
,
:command_path
=>
nil
,
:log
=>
true
:log
=>
true
,
:swallow_stderr
=>
true
}
end
...
...
@@ -84,7 +85,9 @@ module Paperclip
# expected_outcodes, a PaperclipCommandLineError will be raised. Generally
# a code of 0 is expected, but a list of codes may be passed if necessary.
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
)
raise
PaperclipCommandLineError
,
"Error while running
#{
cmd
}
"
end
...
...
lib/paperclip/attachment.rb
View file @
c9205f4f
...
...
@@ -353,11 +353,11 @@ module Paperclip
# When processing, if the spawn plugin is installed, processing can be done in
# a background fork or thread if desired.
def
background
(
&
blk
)
if
instance
.
respond_to?
(
:spawn
)
&&
@background
instance
.
spawn
(
&
blk
)
else
#
if instance.respond_to?(:spawn) && @background
#
instance.spawn(&blk)
#
else
blk
.
call
end
#
end
end
def
callback
which
#:nodoc:
...
...
test/attachment_test.rb
View file @
c9205f4f
...
...
@@ -232,19 +232,19 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context
"When spawn is defined on the instance"
do
setup
do
Dummy
.
any_instance
.
stubs
(
:spawn
)
rebuild_model
:styles
=>
{
:foo
=>
true
}
@dummy
=
Dummy
.
new
@file
=
StringIO
.
new
(
"12345"
)
end
should
"not call spawn on the instance when assigned a file"
do
@dummy
.
expects
(
:spawn
)
@dummy
.
avatar
=
@file
end
end
#
context "When spawn is defined on the instance" do
#
setup do
#
Dummy.any_instance.stubs(:spawn)
#
rebuild_model :styles => {:foo => true}
#
@dummy = Dummy.new
#
@file = StringIO.new("12345")
#
end
#
should "not call spawn on the instance when assigned a file" do
#
@dummy.expects(:spawn)
#
@dummy.avatar = @file
#
end
#
end
context
"An attachment with no processors defined"
do
setup
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment