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
5a731302
Commit
5a731302
authored
Dec 24, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed :image_magick_path to :command_path, deprecated :image_magick_path
parent
06a5d776
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
10 deletions
+37
-10
lib/paperclip.rb
+11
-6
lib/paperclip/attachment.rb
+1
-1
test/paperclip_test.rb
+25
-3
No files found.
lib/paperclip.rb
View file @
5a731302
...
...
@@ -43,18 +43,23 @@ module Paperclip
# Provides configurability to Paperclip. There are a number of options available, such as:
# * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of
# an uploaded image. Defaults to true.
# *
image_magick_path: Defines the path at which to find the +convert+ and +identify+
# *
command_path: Defines the path at which to find the command line
# programs if they are not visible to Rails the system's search path. Defaults to
# nil, which uses the first executable found in the search path.
# nil, which uses the first executable found in the user's search path.
# * image_magick_path: Deprecated alias of command_path.
def
options
@options
||=
{
:whiny_thumbnails
=>
true
,
:image_magick_path
=>
nil
:image_magick_path
=>
nil
,
:command_path
=>
nil
}
end
def
path_for_command
command
#:nodoc:
path
=
[
options
[
:image_magick_path
],
command
].
compact
if
options
[
:image_magick_path
]
ActiveSupport
::
Deprecation
.
warn
(
":image_magick_path is deprecated and will be removed. Use :command_path instead"
)
end
path
=
[
options
[
:image_magick_path
]
||
options
[
:command_path
],
command
].
compact
File
.
join
(
*
path
)
end
...
...
@@ -124,8 +129,8 @@ module Paperclip
# has_attached_file :avatar, :styles => { :normal => "100x100#" },
# :default_style => :normal
# user.avatar.url # => "/avatars/23/normal_me.png"
# * +whiny_thumbnails+: Will raise an error if Paperclip cannot p
rocess thumbnails of an
#
uploaded image. This will ov
rride the global setting for this attachment.
# * +whiny_thumbnails+: Will raise an error if Paperclip cannot p
ost_process an uploaded file due
#
to a command line error. This will ove
rride the global setting for this attachment.
# Defaults to true.
# * +convert_options+: When creating thumbnails, use this free-form options
# field to pass in various convert command options. Typical options are "-strip" to
...
...
lib/paperclip/attachment.rb
View file @
5a731302
...
...
@@ -35,7 +35,7 @@ module Paperclip
@storage
=
options
[
:storage
]
@whiny
=
options
[
:whiny_thumbnails
]
@convert_options
=
options
[
:convert_options
]
||
{}
@processors
=
[
:thumbnail
]
@processors
=
options
[
:processors
]
||
[
:thumbnail
]
@options
=
options
@queued_for_delete
=
[]
@queued_for_write
=
{}
...
...
test/paperclip_test.rb
View file @
5a731302
require
'test/helper'
class
PaperclipTest
<
Test
::
Unit
::
TestCase
context
"Calling Paperclip.run"
do
[
:image_magick_path
,
:convert_path
].
each
do
|
path
|
context
"Calling Paperclip.run with an
#{
path
}
specified"
do
setup
do
Paperclip
.
options
[
:image_magick_path
]
=
nil
Paperclip
.
options
[
:convert_path
]
=
nil
Paperclip
.
options
[
path
]
=
"/usr/bin"
end
should
"execute the right command"
do
Paperclip
.
expects
(
:path_for_command
).
with
(
"convert"
).
returns
(
"/usr/bin/convert"
)
Paperclip
.
expects
(
:bit_bucket
).
returns
(
"/dev/null"
)
Paperclip
.
expects
(
:"`"
).
with
(
"/usr/bin/convert one.jpg two.jpg 2>/dev/null"
)
Paperclip
.
run
(
"convert"
,
"one.jpg two.jpg"
)
end
end
end
context
"Calling Paperclip.run with no path specified"
do
setup
do
Paperclip
.
options
[
:image_magick_path
]
=
nil
Paperclip
.
options
[
:convert_path
]
=
nil
end
should
"execute the right command"
do
Paperclip
.
expects
(
:path_for_command
).
with
(
"convert"
).
returns
(
"
/usr/bin/
convert"
)
Paperclip
.
expects
(
:path_for_command
).
with
(
"convert"
).
returns
(
"convert"
)
Paperclip
.
expects
(
:bit_bucket
).
returns
(
"/dev/null"
)
Paperclip
.
expects
(
:"`"
).
with
(
"
/usr/bin/
convert one.jpg two.jpg 2>/dev/null"
)
Paperclip
.
expects
(
:"`"
).
with
(
"convert one.jpg two.jpg 2>/dev/null"
)
Paperclip
.
run
(
"convert"
,
"one.jpg two.jpg"
)
end
end
...
...
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