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
169dee4d
Commit
169dee4d
authored
May 18, 2012
by
Juanjo Bazán
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Processor#identify and #convert instance methods
parent
34f44993
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletions
+29
-1
lib/paperclip/processor.rb
+12
-0
lib/paperclip/thumbnail.rb
+1
-1
test/processor_test.rb
+16
-0
No files found.
lib/paperclip/processor.rb
View file @
169dee4d
...
@@ -32,6 +32,18 @@ module Paperclip
...
@@ -32,6 +32,18 @@ module Paperclip
def
self
.
make
file
,
options
=
{},
attachment
=
nil
def
self
.
make
file
,
options
=
{},
attachment
=
nil
new
(
file
,
options
,
attachment
).
make
new
(
file
,
options
,
attachment
).
make
end
end
# The convert method runs the convert binary with the provided arguments.
# See Paperclip.run for the available options.
def
convert
(
arguments
=
""
,
local_options
=
{})
Paperclip
.
run
(
'convert'
,
arguments
,
local_options
)
end
# The identify method runs the identify binary with the provided arguments.
# See Paperclip.run for the available options.
def
identify
(
arguments
=
""
,
local_options
=
{})
Paperclip
.
run
(
'identify'
,
arguments
,
local_options
)
end
end
end
module
ProcessorHelpers
module
ProcessorHelpers
...
...
lib/paperclip/thumbnail.rb
View file @
169dee4d
...
@@ -73,7 +73,7 @@ module Paperclip
...
@@ -73,7 +73,7 @@ module Paperclip
parameters
=
parameters
.
flatten
.
compact
.
join
(
" "
).
strip
.
squeeze
(
" "
)
parameters
=
parameters
.
flatten
.
compact
.
join
(
" "
).
strip
.
squeeze
(
" "
)
success
=
Paperclip
.
run
(
"convert"
,
parameters
,
:source
=>
"
#{
File
.
expand_path
(
src
.
path
)
}#{
'[0]'
unless
animated?
}
"
,
:dest
=>
File
.
expand_path
(
dst
.
path
))
success
=
convert
(
parameters
,
:source
=>
"
#{
File
.
expand_path
(
src
.
path
)
}#{
'[0]'
unless
animated?
}
"
,
:dest
=>
File
.
expand_path
(
dst
.
path
))
rescue
Cocaine
::
ExitStatusError
=>
e
rescue
Cocaine
::
ExitStatusError
=>
e
raise
Paperclip
::
Error
,
"There was an error processing the thumbnail for
#{
@basename
}
"
if
@whiny
raise
Paperclip
::
Error
,
"There was an error processing the thumbnail for
#{
@basename
}
"
if
@whiny
rescue
Cocaine
::
CommandNotFoundError
=>
e
rescue
Cocaine
::
CommandNotFoundError
=>
e
...
...
test/processor_test.rb
View file @
169dee4d
...
@@ -7,4 +7,20 @@ class ProcessorTest < Test::Unit::TestCase
...
@@ -7,4 +7,20 @@ class ProcessorTest < Test::Unit::TestCase
Paperclip
::
Processor
.
expects
(
:new
).
with
(
:one
,
:two
,
:three
).
returns
(
processor
)
Paperclip
::
Processor
.
expects
(
:new
).
with
(
:one
,
:two
,
:three
).
returns
(
processor
)
Paperclip
::
Processor
.
make
(
:one
,
:two
,
:three
)
Paperclip
::
Processor
.
make
(
:one
,
:two
,
:three
)
end
end
context
"Calling #convert"
do
should
"run the convert command with Cocaine"
do
Paperclip
.
options
[
:log_command
]
=
false
Cocaine
::
CommandLine
.
expects
(
:new
).
with
(
"convert"
,
"stuff"
,
{}).
returns
(
stub
(
:run
))
Paperclip
::
Processor
.
new
(
'filename'
).
convert
(
"stuff"
)
end
end
context
"Calling #identify"
do
should
"run the identify command with Cocaine"
do
Paperclip
.
options
[
:log_command
]
=
false
Cocaine
::
CommandLine
.
expects
(
:new
).
with
(
"identify"
,
"stuff"
,
{}).
returns
(
stub
(
:run
))
Paperclip
::
Processor
.
new
(
'filename'
).
identify
(
"stuff"
)
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