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
f7fdc9f1
Commit
f7fdc9f1
authored
Oct 05, 2011
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respect :log_command again
parent
0df4b606
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
16 deletions
+25
-16
lib/paperclip.rb
+14
-15
test/paperclip_test.rb
+11
-1
No files found.
lib/paperclip.rb
View file @
f7fdc9f1
...
@@ -78,29 +78,28 @@ module Paperclip
...
@@ -78,29 +78,28 @@ module Paperclip
Paperclip
::
Interpolations
[
key
]
=
block
Paperclip
::
Interpolations
[
key
]
=
block
end
end
# The run method takes a command to execute and an array of parameters
# The run method takes the name of a binary to run, the arguments to that binary
# that get passed to it. The command is prefixed with the :command_path
# and some options:
# option from Paperclip.options. If you have many commands to run and
# they are in different paths, the suggested course of action is to
# symlink them so they are all in the same directory.
#
#
# If the command returns with a result code that is not one of the
# :command_path -> A $PATH-like variable that defines where to look for the binary
# expected_outcodes, a Cocaine::CommandLineError will be raised. Generally
# on the filesystem. Colon-separated, just like $PATH.
# a code of 0 is expected, but a list of codes may be passed if necessary.
# These codes should be passed as a hash as the last argument, like so:
#
#
# Paperclip.run("echo", "something", :expected_outcodes => [0,1,2,3])
# :expected_outcodes -> An array of integers that defines the expected exit codes
# of the binary. Defaults to [0].
#
#
# This method can log the command being run when
# :log_command -> Log the command being run when set to true (defaults to false).
# Paperclip.options[:log_command] is set to true (defaults to false). This
# This will only log if logging in general is set to true as well.
# will only log if logging in general is set to true as well.
#
def
run
(
cmd
,
*
params
)
# :swallow_stderr -> Set to true if you don't care what happens on STDERR.
#
def
run
(
cmd
,
arguments
=
""
,
local_options
=
{})
if
options
[
:image_magick_path
]
if
options
[
:image_magick_path
]
Paperclip
.
log
(
"[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead"
)
Paperclip
.
log
(
"[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead"
)
end
end
command_path
=
options
[
:command_path
]
||
options
[
:image_magick_path
]
command_path
=
options
[
:command_path
]
||
options
[
:image_magick_path
]
Cocaine
::
CommandLine
.
path
=
(
Cocaine
::
CommandLine
.
path
?
[
Cocaine
::
CommandLine
.
path
,
command_path
].
flatten
:
command_path
)
Cocaine
::
CommandLine
.
path
=
(
Cocaine
::
CommandLine
.
path
?
[
Cocaine
::
CommandLine
.
path
,
command_path
].
flatten
:
command_path
)
Cocaine
::
CommandLine
.
new
(
cmd
,
*
params
).
run
local_options
=
local_options
.
merge
(
:logger
=>
logger
)
if
logging?
&&
(
options
[
:log_command
]
||
local_options
[
:log_command
])
Cocaine
::
CommandLine
.
new
(
cmd
,
arguments
,
local_options
).
run
end
end
def
processor
(
name
)
#:nodoc:
def
processor
(
name
)
#:nodoc:
...
...
test/paperclip_test.rb
View file @
f7fdc9f1
...
@@ -3,11 +3,13 @@ require './test/helper'
...
@@ -3,11 +3,13 @@ require './test/helper'
class
PaperclipTest
<
Test
::
Unit
::
TestCase
class
PaperclipTest
<
Test
::
Unit
::
TestCase
context
"Calling Paperclip.run"
do
context
"Calling Paperclip.run"
do
setup
do
setup
do
Cocaine
::
CommandLine
.
expects
(
:new
).
with
(
"convert"
,
"stuff"
).
returns
(
stub
(
:run
))
Paperclip
.
options
[
:log_command
]
=
false
Cocaine
::
CommandLine
.
expects
(
:new
).
with
(
"convert"
,
"stuff"
,
{}).
returns
(
stub
(
:run
))
@original_command_line_path
=
Cocaine
::
CommandLine
.
path
@original_command_line_path
=
Cocaine
::
CommandLine
.
path
end
end
teardown
do
teardown
do
Paperclip
.
options
[
:log_command
]
=
true
Cocaine
::
CommandLine
.
path
=
@original_command_line_path
Cocaine
::
CommandLine
.
path
=
@original_command_line_path
end
end
...
@@ -22,6 +24,14 @@ class PaperclipTest < Test::Unit::TestCase
...
@@ -22,6 +24,14 @@ class PaperclipTest < Test::Unit::TestCase
end
end
end
end
context
"Calling Paperclip.run with a logger"
do
should
"pass the defined logger if :log_command is set"
do
Paperclip
.
options
[
:log_command
]
=
true
Cocaine
::
CommandLine
.
expects
(
:new
).
with
(
"convert"
,
"stuff"
,
:logger
=>
Paperclip
.
logger
).
returns
(
stub
(
:run
))
Paperclip
.
run
(
"convert"
,
"stuff"
)
end
end
context
"Paperclip.each_instance_with_attachment"
do
context
"Paperclip.each_instance_with_attachment"
do
setup
do
setup
do
@file
=
File
.
new
(
File
.
join
(
FIXTURES_DIR
,
"5k.png"
),
'rb'
)
@file
=
File
.
new
(
File
.
join
(
FIXTURES_DIR
,
"5k.png"
),
'rb'
)
...
...
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