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
ecd369df
Commit
ecd369df
authored
Jun 07, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No more NotIdentifiedByImageMagick errors if IM is not in the path. Give a real error.
Based on a commit by Henrik N <henrik@nyh.se>
parent
44124a5f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
lib/paperclip.rb
+9
-2
test/paperclip_test.rb
+14
-0
No files found.
lib/paperclip.rb
View file @
ecd369df
...
@@ -113,6 +113,10 @@ module Paperclip
...
@@ -113,6 +113,10 @@ module Paperclip
Paperclip
.
log
(
command
)
if
Paperclip
.
options
[
:log_command
]
Paperclip
.
log
(
command
)
if
Paperclip
.
options
[
:log_command
]
output
=
`
#{
command
}
`
output
=
`
#{
command
}
`
if
$?
.
exitstatus
==
127
raise
CommandNotFoundError
end
unless
expected_outcodes
.
include?
(
$?
.
exitstatus
)
unless
expected_outcodes
.
include?
(
$?
.
exitstatus
)
raise
PaperclipCommandLineError
,
raise
PaperclipCommandLineError
,
"Error while running
#{
cmd
}
. Expected return code to be
#{
expected_outcodes
.
join
(
", "
)
}
but was
#{
$?
.
exitstatus
}
"
,
"Error while running
#{
cmd
}
. Expected return code to be
#{
expected_outcodes
.
join
(
", "
)
}
but was
#{
$?
.
exitstatus
}
"
,
...
@@ -167,7 +171,7 @@ module Paperclip
...
@@ -167,7 +171,7 @@ module Paperclip
class
PaperclipError
<
StandardError
#:nodoc:
class
PaperclipError
<
StandardError
#:nodoc:
end
end
class
PaperclipCommandLineError
<
Standard
Error
#:nodoc:
class
PaperclipCommandLineError
<
Paperclip
Error
#:nodoc:
attr_accessor
:output
attr_accessor
:output
def
initialize
(
msg
=
nil
,
output
=
nil
)
def
initialize
(
msg
=
nil
,
output
=
nil
)
super
(
msg
)
super
(
msg
)
...
@@ -175,9 +179,12 @@ module Paperclip
...
@@ -175,9 +179,12 @@ module Paperclip
end
end
end
end
class
CommandNotFoundError
<
PaperclipError
end
class
NotIdentifiedByImageMagickError
<
PaperclipError
#:nodoc:
class
NotIdentifiedByImageMagickError
<
PaperclipError
#:nodoc:
end
end
class
InfiniteInterpolationError
<
PaperclipError
#:nodoc:
class
InfiniteInterpolationError
<
PaperclipError
#:nodoc:
end
end
...
...
test/paperclip_test.rb
View file @
ecd369df
...
@@ -62,6 +62,20 @@ class PaperclipTest < Test::Unit::TestCase
...
@@ -62,6 +62,20 @@ class PaperclipTest < Test::Unit::TestCase
end
end
end
end
context
"Calling Paperclip.run when the command is not found"
do
should
"tell you the command isn't there"
do
begin
assert_raises
(
Paperclip
::
CommandNotFoundError
)
do
`ruby -e 'exit 127'`
# Stub $?.exitstatus to be 127, i.e. Command Not Found.
Paperclip
.
stubs
(
:"`"
).
returns
(
""
)
Paperclip
.
run
(
"command"
)
end
ensure
`ruby -e 'exit 0'`
# Unstub $?.exitstatus
end
end
end
should
"prevent dangerous characters in the command via quoting"
do
should
"prevent dangerous characters in the command via quoting"
do
Paperclip
.
options
[
:image_magick_path
]
=
nil
Paperclip
.
options
[
:image_magick_path
]
=
nil
Paperclip
.
options
[
:command_path
]
=
nil
Paperclip
.
options
[
:command_path
]
=
nil
...
...
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