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
32b9a28c
Commit
32b9a28c
authored
Aug 09, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All tests passing on Windows (if you have 'file.exe' installed).
parent
00c0daf4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
10 deletions
+10
-10
lib/paperclip/thumbnail.rb
+2
-2
lib/paperclip/upfile.rb
+1
-1
test/paperclip_test.rb
+4
-4
test/thumbnail_test.rb
+3
-3
No files found.
lib/paperclip/thumbnail.rb
View file @
32b9a28c
...
@@ -71,8 +71,8 @@ module Paperclip
...
@@ -71,8 +71,8 @@ module Paperclip
def
transformation_command
def
transformation_command
scale
,
crop
=
@current_geometry
.
transformation_to
(
@target_geometry
,
crop?
)
scale
,
crop
=
@current_geometry
.
transformation_to
(
@target_geometry
,
crop?
)
trans
=
[]
trans
=
[]
trans
<<
"-resize"
<<
"'
#{
scale
}
'"
unless
scale
.
nil?
||
scale
.
empty?
trans
<<
"-resize"
<<
%["#{scale}"]
unless
scale
.
nil?
||
scale
.
empty?
trans
<<
"-crop"
<<
"'
#{
crop
}
'"
<<
"+repage"
if
crop
trans
<<
"-crop"
<<
%["#{crop}"]
<<
"+repage"
if
crop
trans
trans
end
end
end
end
...
...
lib/paperclip/upfile.rb
View file @
32b9a28c
...
@@ -17,7 +17,7 @@ module Paperclip
...
@@ -17,7 +17,7 @@ module Paperclip
when
"csv"
,
"xml"
,
"css"
then
"text/
#{
type
}
"
when
"csv"
,
"xml"
,
"css"
then
"text/
#{
type
}
"
else
else
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
content_type
=
(
Paperclip
.
run
(
"file"
,
"--mime-type :file"
,
:file
=>
self
.
path
).
split
(
':'
).
last
.
strip
rescue
"application/x-
#{
type
}
"
)
content_type
=
(
Paperclip
.
run
(
"file"
,
"-
b -
-mime-type :file"
,
:file
=>
self
.
path
).
split
(
':'
).
last
.
strip
rescue
"application/x-
#{
type
}
"
)
content_type
=
"application/x-
#{
type
}
"
if
content_type
.
match
(
/\(.*?\)/
)
content_type
=
"application/x-
#{
type
}
"
if
content_type
.
match
(
/\(.*?\)/
)
content_type
content_type
end
end
...
...
test/paperclip_test.rb
View file @
32b9a28c
...
@@ -11,19 +11,19 @@ class PaperclipTest < Test::Unit::TestCase
...
@@ -11,19 +11,19 @@ class PaperclipTest < Test::Unit::TestCase
should
"execute the right command with :image_magick_path"
do
should
"execute the right command with :image_magick_path"
do
Paperclip
.
options
[
:image_magick_path
]
=
"/usr/bin"
Paperclip
.
options
[
:image_magick_path
]
=
"/usr/bin"
Paperclip
.
expects
(
:log
).
with
(
includes
(
'[DEPRECATION]'
))
Paperclip
.
expects
(
:log
).
with
(
includes
(
'[DEPRECATION]'
))
Paperclip
.
expects
(
:log
).
with
(
"/usr/bin/convert 'one.jpg' 'two.jpg'"
)
Paperclip
.
expects
(
:log
).
with
(
regexp_matches
(
%r{/usr/bin/convert ['"]one.jpg['"] ['"]two.jpg['"]}
)
)
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
(
"/usr/bin/convert 'one.jpg' 'two.jpg'"
)
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
(
regexp_matches
(
%r{/usr/bin/convert ['"]one.jpg['"] ['"]two.jpg['"]}
)
)
Paperclip
.
run
(
"convert"
,
":one :two"
,
:one
=>
"one.jpg"
,
:two
=>
"two.jpg"
)
Paperclip
.
run
(
"convert"
,
":one :two"
,
:one
=>
"one.jpg"
,
:two
=>
"two.jpg"
)
end
end
should
"execute the right command with :command_path"
do
should
"execute the right command with :command_path"
do
Paperclip
.
options
[
:command_path
]
=
"/usr/bin"
Paperclip
.
options
[
:command_path
]
=
"/usr/bin"
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
(
"/usr/bin/convert 'one.jpg' 'two.jpg'"
)
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
(
regexp_matches
(
%r{/usr/bin/convert ['"]one.jpg['"] ['"]two.jpg['"]}
)
)
Paperclip
.
run
(
"convert"
,
":one :two"
,
:one
=>
"one.jpg"
,
:two
=>
"two.jpg"
)
Paperclip
.
run
(
"convert"
,
":one :two"
,
:one
=>
"one.jpg"
,
:two
=>
"two.jpg"
)
end
end
should
"execute the right command with no path"
do
should
"execute the right command with no path"
do
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
(
"convert 'one.jpg' 'two.jpg'"
)
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
(
regexp_matches
(
%r{convert ['"]one.jpg['"] ['"]two.jpg['"]}
)
)
Paperclip
.
run
(
"convert"
,
":one :two"
,
:one
=>
"one.jpg"
,
:two
=>
"two.jpg"
)
Paperclip
.
run
(
"convert"
,
":one :two"
,
:one
=>
"one.jpg"
,
:two
=>
"two.jpg"
)
end
end
...
...
test/thumbnail_test.rb
View file @
32b9a28c
...
@@ -92,7 +92,7 @@ class ThumbnailTest < Test::Unit::TestCase
...
@@ -92,7 +92,7 @@ class ThumbnailTest < Test::Unit::TestCase
should
"send the right command to convert when sent #make"
do
should
"send the right command to convert when sent #make"
do
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
do
|
arg
|
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
do
|
arg
|
arg
.
match
%r{convert
'
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
\[
0
\]
' -resize 'x50' -crop '100x50
\+
114
\+
0'
\+
repage '.*?'
}
arg
.
match
%r{convert
["']
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
\[
0
\]
["'] -resize ["']x50["'] -crop ["']100x50
\+
114
\+
0["']
\+
repage ["'].*?["']
}
end
end
@thumb
.
make
@thumb
.
make
end
end
...
@@ -116,7 +116,7 @@ class ThumbnailTest < Test::Unit::TestCase
...
@@ -116,7 +116,7 @@ class ThumbnailTest < Test::Unit::TestCase
should
"send the right command to convert when sent #make"
do
should
"send the right command to convert when sent #make"
do
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
do
|
arg
|
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
do
|
arg
|
arg
.
match
%r{convert -strip
'
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
\[
0
\]
' -resize 'x50' -crop '100x50
\+
114
\+
0'
\+
repage '.*?'
}
arg
.
match
%r{convert -strip
["']
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
\[
0
\]
["'] -resize ["']x50["'] -crop ["']100x50
\+
114
\+
0["']
\+
repage ["'].*?["']
}
end
end
@thumb
.
make
@thumb
.
make
end
end
...
@@ -154,7 +154,7 @@ class ThumbnailTest < Test::Unit::TestCase
...
@@ -154,7 +154,7 @@ class ThumbnailTest < Test::Unit::TestCase
should
"send the right command to convert when sent #make"
do
should
"send the right command to convert when sent #make"
do
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
do
|
arg
|
Paperclip
::
CommandLine
.
expects
(
:"`"
).
with
do
|
arg
|
arg
.
match
%r{convert
'
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
\[
0
\]
' -resize 'x50' -crop '100x50
\+
114
\+
0'
\+
repage -strip -depth 8 '.*?'
}
arg
.
match
%r{convert
["']
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
\[
0
\]
["'] -resize ["']x50["'] -crop ["']100x50
\+
114
\+
0["']
\+
repage -strip -depth 8 ["'].*?["']
}
end
end
@thumb
.
make
@thumb
.
make
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