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
0216d4d7
Commit
0216d4d7
authored
May 20, 2011
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some better errors when commands aren't found, and tests to ensure the errors show
parent
a2d5e5a1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
1 deletions
+42
-1
lib/paperclip/geometry.rb
+2
-0
lib/paperclip/thumbnail.rb
+3
-1
test/geometry_test.rb
+13
-0
test/thumbnail_test.rb
+24
-0
No files found.
lib/paperclip/geometry.rb
View file @
0216d4d7
...
...
@@ -19,6 +19,8 @@ module Paperclip
Paperclip
.
run
(
"identify"
,
"-format %wx%h :file"
,
:file
=>
"
#{
file
}
[0]"
)
rescue
Cocaine
::
ExitStatusError
""
rescue
Cocaine
::
CommandNotFoundError
=>
e
raise
Paperclip
::
CommandNotFoundError
.
new
(
"Could not run the `identify` command. Please install ImageMagick."
)
end
parse
(
geometry
)
||
raise
(
NotIdentifiedByImageMagickError
.
new
(
"
#{
file
}
is not recognized by the 'identify' command."
))
...
...
lib/paperclip/thumbnail.rb
View file @
0216d4d7
...
...
@@ -59,8 +59,10 @@ module Paperclip
parameters
=
parameters
.
flatten
.
compact
.
join
(
" "
).
strip
.
squeeze
(
" "
)
success
=
Paperclip
.
run
(
"convert"
,
parameters
,
:source
=>
"
#{
File
.
expand_path
(
src
.
path
)
}
[0]"
,
:dest
=>
File
.
expand_path
(
dst
.
path
))
rescue
Cocaine
::
CommandLine
Error
=>
e
rescue
Cocaine
::
ExitStatus
Error
=>
e
raise
PaperclipError
,
"There was an error processing the thumbnail for
#{
@basename
}
"
if
@whiny
rescue
Cocaine
::
CommandNotFoundError
=>
e
raise
Paperclip
::
CommandNotFoundError
.
new
(
"Could not run the `convert` command. Please install ImageMagick."
)
end
dst
...
...
test/geometry_test.rb
View file @
0216d4d7
...
...
@@ -120,6 +120,19 @@ class GeometryTest < Test::Unit::TestCase
assert_raise
(
Paperclip
::
NotIdentifiedByImageMagickError
){
@geo
=
Paperclip
::
Geometry
.
from_file
(
file
)
}
end
should
"let us know when a command isn't found versus a processing error"
do
old_path
=
ENV
[
'PATH'
]
begin
ENV
[
'PATH'
]
=
''
assert_raises
(
Paperclip
::
CommandNotFoundError
)
do
file
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"5k.png"
)
@geo
=
Paperclip
::
Geometry
.
from_file
(
file
)
end
ensure
ENV
[
'PATH'
]
=
old_path
end
end
[[
'vertical'
,
900
,
1440
,
true
,
false
,
false
,
1440
,
900
,
0.625
],
[
'horizontal'
,
1024
,
768
,
false
,
true
,
false
,
1024
,
768
,
1.3333
],
[
'square'
,
100
,
100
,
false
,
false
,
true
,
100
,
100
,
1
]].
each
do
|
args
|
...
...
test/thumbnail_test.rb
View file @
0216d4d7
...
...
@@ -73,6 +73,18 @@ class ThumbnailTest < Test::Unit::TestCase
@thumb
=
Paperclip
::
Thumbnail
.
new
(
@file
,
:geometry
=>
"100x50#"
)
end
should
"let us know when a command isn't found versus a processing error"
do
old_path
=
ENV
[
'PATH'
]
begin
ENV
[
'PATH'
]
=
''
assert_raises
(
Paperclip
::
CommandNotFoundError
)
do
@thumb
.
make
end
ensure
ENV
[
'PATH'
]
=
old_path
end
end
should
"report its correct current and target geometries"
do
assert_equal
"100x50#"
,
@thumb
.
target_geometry
.
to_s
assert_equal
"434x66"
,
@thumb
.
current_geometry
.
to_s
...
...
@@ -182,6 +194,18 @@ class ThumbnailTest < Test::Unit::TestCase
@thumb
.
make
end
end
should
"let us know when a command isn't found versus a processing error"
do
old_path
=
ENV
[
'PATH'
]
begin
ENV
[
'PATH'
]
=
''
assert_raises
(
Paperclip
::
CommandNotFoundError
)
do
@thumb
.
make
end
ensure
ENV
[
'PATH'
]
=
old_path
end
end
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