paperclip 2.3.11 → 2.3.16
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of paperclip might be problematic. Click here for more details.
- data/README.md +30 -4
- data/Rakefile +3 -3
- data/init.rb +3 -0
- data/lib/generators/paperclip/paperclip_generator.rb +3 -1
- data/lib/paperclip/attachment.rb +27 -12
- data/lib/paperclip/{callback_compatability.rb → callback_compatibility.rb} +0 -0
- data/lib/paperclip/geometry.rb +4 -1
- data/lib/paperclip/interpolations.rb +8 -3
- data/lib/paperclip/iostream.rb +1 -1
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +20 -14
- data/lib/paperclip/processor.rb +1 -1
- data/lib/paperclip/storage/filesystem.rb +8 -3
- data/lib/paperclip/storage/fog.rb +48 -13
- data/lib/paperclip/storage/s3.rb +54 -16
- data/lib/paperclip/style.rb +4 -3
- data/lib/paperclip/thumbnail.rb +18 -3
- data/lib/paperclip/upfile.rb +20 -13
- data/lib/paperclip/version.rb +1 -1
- data/lib/paperclip.rb +60 -27
- data/lib/tasks/paperclip.rake +32 -23
- data/test/attachment_test.rb +116 -0
- data/test/fixtures/animated.gif +0 -0
- data/test/fog_test.rb +30 -19
- data/test/geometry_test.rb +29 -0
- data/test/helper.rb +3 -0
- data/test/integration_test.rb +40 -4
- data/test/interpolations_test.rb +14 -0
- data/test/matchers/validate_attachment_content_type_matcher_test.rb +42 -2
- data/test/paperclip_test.rb +18 -40
- data/test/storage_test.rb +244 -7
- data/test/style_test.rb +30 -5
- data/test/thumbnail_test.rb +111 -6
- data/test/upfile_test.rb +3 -2
- metadata +103 -122
- data/lib/paperclip/command_line.rb +0 -86
- data/test/command_line_test.rb +0 -138
data/test/style_test.rb
CHANGED
@@ -62,12 +62,12 @@ class StyleTest < Test::Unit::TestCase
|
|
62
62
|
|
63
63
|
context "An attachment with style rules in various forms" do
|
64
64
|
setup do
|
65
|
+
styles = ActiveSupport::OrderedHash.new
|
66
|
+
styles[:aslist] = ["100x100", :png]
|
67
|
+
styles[:ashash] = {:geometry => "100x100", :format => :png}
|
68
|
+
styles[:asstring] = "100x100"
|
65
69
|
@attachment = attachment :path => ":basename.:extension",
|
66
|
-
:styles =>
|
67
|
-
:aslist => ["100x100", :png],
|
68
|
-
:ashash => {:geometry => "100x100", :format => :png},
|
69
|
-
:asstring => "100x100"
|
70
|
-
}
|
70
|
+
:styles => styles
|
71
71
|
end
|
72
72
|
should "have the right number of styles" do
|
73
73
|
assert_kind_of Hash, @attachment.styles
|
@@ -92,6 +92,9 @@ class StyleTest < Test::Unit::TestCase
|
|
92
92
|
assert_nil @attachment.styles[:asstring].format
|
93
93
|
end
|
94
94
|
|
95
|
+
should "retain order" do
|
96
|
+
assert_equal [:aslist, :ashash, :asstring], @attachment.styles.keys
|
97
|
+
end
|
95
98
|
end
|
96
99
|
|
97
100
|
context "An attachment with :convert_options" do
|
@@ -138,4 +141,26 @@ class StyleTest < Test::Unit::TestCase
|
|
138
141
|
end
|
139
142
|
|
140
143
|
end
|
144
|
+
|
145
|
+
context "A style rule with :processors supplied as procs" do
|
146
|
+
setup do
|
147
|
+
@attachment = attachment :path => ":basename.:extension",
|
148
|
+
:styles => {
|
149
|
+
:foo => {
|
150
|
+
:geometry => "100x100#",
|
151
|
+
:format => :png,
|
152
|
+
:processors => lambda{|a| [:test]}
|
153
|
+
}
|
154
|
+
},
|
155
|
+
:processors => [:thumbnail]
|
156
|
+
end
|
157
|
+
|
158
|
+
should "defer processing of procs until they are needed" do
|
159
|
+
assert_kind_of Proc, @attachment.styles[:foo].instance_variable_get("@processors")
|
160
|
+
end
|
161
|
+
|
162
|
+
should "call procs when they are needed" do
|
163
|
+
assert_equal [:test], @attachment.styles[:foo].processors
|
164
|
+
end
|
165
|
+
end
|
141
166
|
end
|
data/test/thumbnail_test.rb
CHANGED
@@ -73,6 +73,18 @@ class ThumbnailTest < Test::Unit::TestCase
|
|
73
73
|
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x50#")
|
74
74
|
end
|
75
75
|
|
76
|
+
should "let us know when a command isn't found versus a processing error" do
|
77
|
+
old_path = ENV['PATH']
|
78
|
+
begin
|
79
|
+
ENV['PATH'] = ''
|
80
|
+
assert_raises(Paperclip::CommandNotFoundError) do
|
81
|
+
@thumb.make
|
82
|
+
end
|
83
|
+
ensure
|
84
|
+
ENV['PATH'] = old_path
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
76
88
|
should "report its correct current and target geometries" do
|
77
89
|
assert_equal "100x50#", @thumb.target_geometry.to_s
|
78
90
|
assert_equal "434x66", @thumb.current_geometry.to_s
|
@@ -91,8 +103,10 @@ class ThumbnailTest < Test::Unit::TestCase
|
|
91
103
|
end
|
92
104
|
|
93
105
|
should "send the right command to convert when sent #make" do
|
94
|
-
Paperclip
|
95
|
-
arg
|
106
|
+
Paperclip.expects(:run).with do |*arg|
|
107
|
+
arg[0] == 'convert' &&
|
108
|
+
arg[1] == ':source -resize "x50" -crop "100x50+114+0" +repage :dest' &&
|
109
|
+
arg[2][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
|
96
110
|
end
|
97
111
|
@thumb.make
|
98
112
|
end
|
@@ -115,8 +129,10 @@ class ThumbnailTest < Test::Unit::TestCase
|
|
115
129
|
end
|
116
130
|
|
117
131
|
should "send the right command to convert when sent #make" do
|
118
|
-
Paperclip
|
119
|
-
arg
|
132
|
+
Paperclip.expects(:run).with do |*arg|
|
133
|
+
arg[0] == 'convert' &&
|
134
|
+
arg[1] == '-strip :source -resize "x50" -crop "100x50+114+0" +repage :dest' &&
|
135
|
+
arg[2][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
|
120
136
|
end
|
121
137
|
@thumb.make
|
122
138
|
end
|
@@ -153,8 +169,10 @@ class ThumbnailTest < Test::Unit::TestCase
|
|
153
169
|
end
|
154
170
|
|
155
171
|
should "send the right command to convert when sent #make" do
|
156
|
-
Paperclip
|
157
|
-
arg
|
172
|
+
Paperclip.expects(:run).with do |*arg|
|
173
|
+
arg[0] == 'convert' &&
|
174
|
+
arg[1] == ':source -resize "x50" -crop "100x50+114+0" +repage -strip -depth 8 :dest' &&
|
175
|
+
arg[2][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
|
158
176
|
end
|
159
177
|
@thumb.make
|
160
178
|
end
|
@@ -176,6 +194,18 @@ class ThumbnailTest < Test::Unit::TestCase
|
|
176
194
|
@thumb.make
|
177
195
|
end
|
178
196
|
end
|
197
|
+
|
198
|
+
should "let us know when a command isn't found versus a processing error" do
|
199
|
+
old_path = ENV['PATH']
|
200
|
+
begin
|
201
|
+
ENV['PATH'] = ''
|
202
|
+
assert_raises(Paperclip::CommandNotFoundError) do
|
203
|
+
@thumb.make
|
204
|
+
end
|
205
|
+
ensure
|
206
|
+
ENV['PATH'] = old_path
|
207
|
+
end
|
208
|
+
end
|
179
209
|
end
|
180
210
|
end
|
181
211
|
|
@@ -224,4 +254,79 @@ class ThumbnailTest < Test::Unit::TestCase
|
|
224
254
|
end
|
225
255
|
end
|
226
256
|
end
|
257
|
+
|
258
|
+
context "An animated gif" do
|
259
|
+
setup do
|
260
|
+
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "animated.gif"), 'rb')
|
261
|
+
end
|
262
|
+
|
263
|
+
teardown { @file.close }
|
264
|
+
|
265
|
+
should "start with 12 frames with size 100x100" do
|
266
|
+
cmd = %Q[identify -format "%wx%h" "#{@file.path}"]
|
267
|
+
assert_equal "100x100"*12, `#{cmd}`.chomp
|
268
|
+
end
|
269
|
+
|
270
|
+
context "with static output" do
|
271
|
+
setup do
|
272
|
+
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50", :format => :jpg)
|
273
|
+
end
|
274
|
+
|
275
|
+
should "create the single frame thumbnail when sent #make" do
|
276
|
+
dst = @thumb.make
|
277
|
+
cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
|
278
|
+
assert_equal "50x50", `#{cmd}`.chomp
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
context "with animated output format" do
|
283
|
+
setup do
|
284
|
+
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50", :format => :gif)
|
285
|
+
end
|
286
|
+
|
287
|
+
should "create the 12 frames thumbnail when sent #make" do
|
288
|
+
dst = @thumb.make
|
289
|
+
cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
|
290
|
+
assert_equal "50x50"*12, `#{cmd}`.chomp
|
291
|
+
end
|
292
|
+
|
293
|
+
should "use the -coalesce option" do
|
294
|
+
assert_equal @thumb.transformation_command.first, "-coalesce"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
context "with omitted output format" do
|
299
|
+
setup do
|
300
|
+
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50")
|
301
|
+
end
|
302
|
+
|
303
|
+
should "create the 12 frames thumbnail when sent #make" do
|
304
|
+
dst = @thumb.make
|
305
|
+
cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
|
306
|
+
assert_equal "50x50"*12, `#{cmd}`.chomp
|
307
|
+
end
|
308
|
+
|
309
|
+
should "use the -coalesce option" do
|
310
|
+
assert_equal @thumb.transformation_command.first, "-coalesce"
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
context "with animated option set to false" do
|
315
|
+
setup do
|
316
|
+
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50", :animated => false)
|
317
|
+
end
|
318
|
+
|
319
|
+
should "output the gif format" do
|
320
|
+
dst = @thumb.make
|
321
|
+
cmd = %Q[identify "#{dst.path}"]
|
322
|
+
assert_match /GIF/, `#{cmd}`.chomp
|
323
|
+
end
|
324
|
+
|
325
|
+
should "create the single frame thumbnail when sent #make" do
|
326
|
+
dst = @thumb.make
|
327
|
+
cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
|
328
|
+
assert_equal "50x50", `#{cmd}`.chomp
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
227
332
|
end
|
data/test/upfile_test.rb
CHANGED
@@ -6,12 +6,13 @@ class UpfileTest < Test::Unit::TestCase
|
|
6
6
|
%w(png) => 'image/png',
|
7
7
|
%w(gif) => 'image/gif',
|
8
8
|
%w(bmp) => 'image/bmp',
|
9
|
+
%w(svg) => 'image/svg+xml',
|
9
10
|
%w(txt) => 'text/plain',
|
10
11
|
%w(htm html) => 'text/html',
|
11
12
|
%w(csv) => 'text/csv',
|
12
|
-
%w(xml) => '
|
13
|
+
%w(xml) => 'application/xml',
|
13
14
|
%w(css) => 'text/css',
|
14
|
-
%w(js) => 'application/
|
15
|
+
%w(js) => 'application/javascript',
|
15
16
|
%w(foo) => 'application/x-foo'
|
16
17
|
}.each do |extensions, content_type|
|
17
18
|
extensions.each do |extension|
|
metadata
CHANGED
@@ -1,134 +1,122 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.16
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 3
|
9
|
-
- 11
|
10
|
-
version: 2.3.11
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jon Yurek
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-07-29 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: activerecord
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2154149360 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 2.3.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: activesupport
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *2154149360
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
requirement: &2154148840 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 7
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 3
|
49
|
-
- 2
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
50
32
|
version: 2.3.2
|
51
33
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: shoulda
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *2154148840
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cocaine
|
38
|
+
requirement: &2154148160 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.0.2
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2154148160
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mime-types
|
49
|
+
requirement: &2154143920 !ruby/object:Gem::Requirement
|
57
50
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2154143920
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: shoulda
|
60
|
+
requirement: &2154139460 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
65
66
|
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: appraisal
|
69
67
|
prerelease: false
|
70
|
-
|
68
|
+
version_requirements: *2154139460
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: appraisal
|
71
|
+
requirement: &2154138980 !ruby/object:Gem::Requirement
|
71
72
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
79
77
|
type: :development
|
80
|
-
version_requirements: *id004
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: mocha
|
83
78
|
prerelease: false
|
84
|
-
|
79
|
+
version_requirements: *2154138980
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: mocha
|
82
|
+
requirement: &2154138200 !ruby/object:Gem::Requirement
|
85
83
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
93
88
|
type: :development
|
94
|
-
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: aws-s3
|
97
89
|
prerelease: false
|
98
|
-
|
90
|
+
version_requirements: *2154138200
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: aws-s3
|
93
|
+
requirement: &2154137060 !ruby/object:Gem::Requirement
|
99
94
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
version: "0"
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
107
99
|
type: :development
|
108
|
-
version_requirements: *id006
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: sqlite3-ruby
|
111
100
|
prerelease: false
|
112
|
-
|
101
|
+
version_requirements: *2154137060
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: sqlite3
|
104
|
+
requirement: &2154136260 !ruby/object:Gem::Requirement
|
113
105
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
version: "0"
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
121
110
|
type: :development
|
122
|
-
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2154136260
|
123
113
|
description: Easy upload management for ActiveRecord
|
124
114
|
email: jyurek@thoughtbot.com
|
125
115
|
executables: []
|
126
|
-
|
127
116
|
extensions: []
|
128
|
-
|
129
|
-
extra_rdoc_files:
|
117
|
+
extra_rdoc_files:
|
130
118
|
- README.md
|
131
|
-
files:
|
119
|
+
files:
|
132
120
|
- README.md
|
133
121
|
- LICENSE
|
134
122
|
- Rakefile
|
@@ -137,8 +125,7 @@ files:
|
|
137
125
|
- lib/generators/paperclip/templates/paperclip_migration.rb.erb
|
138
126
|
- lib/generators/paperclip/USAGE
|
139
127
|
- lib/paperclip/attachment.rb
|
140
|
-
- lib/paperclip/
|
141
|
-
- lib/paperclip/command_line.rb
|
128
|
+
- lib/paperclip/callback_compatibility.rb
|
142
129
|
- lib/paperclip/geometry.rb
|
143
130
|
- lib/paperclip/interpolations.rb
|
144
131
|
- lib/paperclip/iostream.rb
|
@@ -160,11 +147,11 @@ files:
|
|
160
147
|
- lib/paperclip.rb
|
161
148
|
- lib/tasks/paperclip.rake
|
162
149
|
- test/attachment_test.rb
|
163
|
-
- test/command_line_test.rb
|
164
150
|
- test/database.yml
|
165
151
|
- test/fixtures/12k.png
|
166
152
|
- test/fixtures/50x50.png
|
167
153
|
- test/fixtures/5k.png
|
154
|
+
- test/fixtures/animated.gif
|
168
155
|
- test/fixtures/bad.png
|
169
156
|
- test/fixtures/s3.yml
|
170
157
|
- test/fixtures/text.txt
|
@@ -191,40 +178,34 @@ files:
|
|
191
178
|
- generators/paperclip/templates/paperclip_migration.rb.erb
|
192
179
|
- generators/paperclip/USAGE
|
193
180
|
- shoulda_macros/paperclip.rb
|
194
|
-
|
195
|
-
homepage: http://www.thoughtbot.com/projects/paperclip
|
181
|
+
homepage: https://github.com/thoughtbot/paperclip
|
196
182
|
licenses: []
|
197
|
-
|
198
183
|
post_install_message:
|
199
|
-
rdoc_options:
|
184
|
+
rdoc_options:
|
200
185
|
- --line-numbers
|
201
186
|
- --inline-source
|
202
|
-
require_paths:
|
187
|
+
require_paths:
|
203
188
|
- lib
|
204
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
205
190
|
none: false
|
206
|
-
requirements:
|
207
|
-
- -
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
|
210
|
-
segments:
|
191
|
+
requirements:
|
192
|
+
- - ! '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
segments:
|
211
196
|
- 0
|
212
|
-
|
213
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
|
+
hash: -2764173214089552631
|
198
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
199
|
none: false
|
215
|
-
requirements:
|
216
|
-
- -
|
217
|
-
- !ruby/object:Gem::Version
|
218
|
-
|
219
|
-
|
220
|
-
- 0
|
221
|
-
version: "0"
|
222
|
-
requirements:
|
200
|
+
requirements:
|
201
|
+
- - ! '>='
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
requirements:
|
223
205
|
- ImageMagick
|
224
206
|
rubyforge_project: paperclip
|
225
|
-
rubygems_version: 1.
|
207
|
+
rubygems_version: 1.8.5
|
226
208
|
signing_key:
|
227
209
|
specification_version: 3
|
228
210
|
summary: File attachments as attributes for ActiveRecord
|
229
211
|
test_files: []
|
230
|
-
|
@@ -1,86 +0,0 @@
|
|
1
|
-
module Paperclip
|
2
|
-
class CommandLine
|
3
|
-
class << self
|
4
|
-
attr_accessor :path
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize(binary, params = "", options = {})
|
8
|
-
@binary = binary.dup
|
9
|
-
@params = params.dup
|
10
|
-
@options = options.dup
|
11
|
-
@swallow_stderr = @options.has_key?(:swallow_stderr) ? @options.delete(:swallow_stderr) : Paperclip.options[:swallow_stderr]
|
12
|
-
@expected_outcodes = @options.delete(:expected_outcodes)
|
13
|
-
@expected_outcodes ||= [0]
|
14
|
-
end
|
15
|
-
|
16
|
-
def command
|
17
|
-
cmd = []
|
18
|
-
cmd << full_path(@binary)
|
19
|
-
cmd << interpolate(@params, @options)
|
20
|
-
cmd << bit_bucket if @swallow_stderr
|
21
|
-
cmd.join(" ")
|
22
|
-
end
|
23
|
-
|
24
|
-
def run
|
25
|
-
Paperclip.log(command)
|
26
|
-
begin
|
27
|
-
output = self.class.send(:'`', command)
|
28
|
-
rescue Errno::ENOENT
|
29
|
-
raise Paperclip::CommandNotFoundError
|
30
|
-
end
|
31
|
-
if $?.exitstatus == 127
|
32
|
-
raise Paperclip::CommandNotFoundError
|
33
|
-
end
|
34
|
-
unless @expected_outcodes.include?($?.exitstatus)
|
35
|
-
raise Paperclip::PaperclipCommandLineError, "Command '#{command}' returned #{$?.exitstatus}. Expected #{@expected_outcodes.join(", ")}"
|
36
|
-
end
|
37
|
-
output
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def full_path(binary)
|
43
|
-
[self.class.path, binary].compact.join("/")
|
44
|
-
end
|
45
|
-
|
46
|
-
def interpolate(pattern, vars)
|
47
|
-
# interpolates :variables and :{variables}
|
48
|
-
pattern.gsub(%r#:(?:\w+|\{\w+\})#) do |match|
|
49
|
-
key = match[1..-1]
|
50
|
-
key = key[1..-2] if key[0,1] == '{'
|
51
|
-
if invalid_variables.include?(key)
|
52
|
-
raise PaperclipCommandLineError,
|
53
|
-
"Interpolation of #{key} isn't allowed."
|
54
|
-
end
|
55
|
-
interpolation(vars, key) || match
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def invalid_variables
|
60
|
-
%w(expected_outcodes swallow_stderr)
|
61
|
-
end
|
62
|
-
|
63
|
-
def interpolation(vars, key)
|
64
|
-
if vars.key?(key.to_sym)
|
65
|
-
shell_quote(vars[key.to_sym])
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def shell_quote(string)
|
70
|
-
return "" if string.nil? or string.blank?
|
71
|
-
if self.class.unix?
|
72
|
-
string.split("'").map{|m| "'#{m}'" }.join("\\'")
|
73
|
-
else
|
74
|
-
%{"#{string}"}
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def bit_bucket
|
79
|
-
self.class.unix? ? "2>/dev/null" : "2>NUL"
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.unix?
|
83
|
-
File.exist?("/dev/null")
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|