paperclip 2.3.11 → 2.3.12

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.

@@ -138,4 +138,26 @@ class StyleTest < Test::Unit::TestCase
138
138
  end
139
139
 
140
140
  end
141
+
142
+ context "A style rule with :processors supplied as procs" do
143
+ setup do
144
+ @attachment = attachment :path => ":basename.:extension",
145
+ :styles => {
146
+ :foo => {
147
+ :geometry => "100x100#",
148
+ :format => :png,
149
+ :processors => lambda{|a| [:test]}
150
+ }
151
+ },
152
+ :processors => [:thumbnail]
153
+ end
154
+
155
+ should "defer processing of procs until they are needed" do
156
+ assert_kind_of Proc, @attachment.styles[:foo].instance_variable_get("@processors")
157
+ end
158
+
159
+ should "call procs when they are needed" do
160
+ assert_equal [:test], @attachment.styles[:foo].processors
161
+ end
162
+ end
141
163
  end
@@ -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::CommandLine.expects(:"`").with do |arg|
95
- arg.match %r{convert ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage ["'].*?["']}
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::CommandLine.expects(:"`").with do |arg|
119
- arg.match %r{convert -strip ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage ["'].*?["']}
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::CommandLine.expects(:"`").with do |arg|
157
- arg.match %r{convert ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage -strip -depth 8 ["'].*?["']}
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,53 @@ 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
+ end
293
+
294
+ context "with omitted output format" do
295
+ setup do
296
+ @thumb = Paperclip::Thumbnail.new(@file, :geometry => "50x50")
297
+ end
298
+
299
+ should "create the 12 frames thumbnail when sent #make" do
300
+ dst = @thumb.make
301
+ cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
302
+ assert_equal "50x50"*12, `#{cmd}`.chomp
303
+ end
304
+ end
305
+ end
227
306
  end
@@ -6,6 +6,7 @@ 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',
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 11
10
- version: 2.3.11
9
+ - 12
10
+ version: 2.3.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jon Yurek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-08 00:00:00 -04:00
18
+ date: 2011-06-28 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -51,21 +51,23 @@ dependencies:
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: shoulda
54
+ name: cocaine
55
55
  prerelease: false
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- hash: 3
61
+ hash: 27
62
62
  segments:
63
63
  - 0
64
- version: "0"
65
- type: :development
64
+ - 0
65
+ - 2
66
+ version: 0.0.2
67
+ type: :runtime
66
68
  version_requirements: *id003
67
69
  - !ruby/object:Gem::Dependency
68
- name: appraisal
70
+ name: shoulda
69
71
  prerelease: false
70
72
  requirement: &id004 !ruby/object:Gem::Requirement
71
73
  none: false
@@ -79,7 +81,7 @@ dependencies:
79
81
  type: :development
80
82
  version_requirements: *id004
81
83
  - !ruby/object:Gem::Dependency
82
- name: mocha
84
+ name: appraisal
83
85
  prerelease: false
84
86
  requirement: &id005 !ruby/object:Gem::Requirement
85
87
  none: false
@@ -93,7 +95,7 @@ dependencies:
93
95
  type: :development
94
96
  version_requirements: *id005
95
97
  - !ruby/object:Gem::Dependency
96
- name: aws-s3
98
+ name: mocha
97
99
  prerelease: false
98
100
  requirement: &id006 !ruby/object:Gem::Requirement
99
101
  none: false
@@ -107,7 +109,7 @@ dependencies:
107
109
  type: :development
108
110
  version_requirements: *id006
109
111
  - !ruby/object:Gem::Dependency
110
- name: sqlite3-ruby
112
+ name: aws-s3
111
113
  prerelease: false
112
114
  requirement: &id007 !ruby/object:Gem::Requirement
113
115
  none: false
@@ -120,6 +122,20 @@ dependencies:
120
122
  version: "0"
121
123
  type: :development
122
124
  version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ name: sqlite3-ruby
127
+ prerelease: false
128
+ requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ type: :development
138
+ version_requirements: *id008
123
139
  description: Easy upload management for ActiveRecord
124
140
  email: jyurek@thoughtbot.com
125
141
  executables: []
@@ -133,66 +149,64 @@ files:
133
149
  - LICENSE
134
150
  - Rakefile
135
151
  - init.rb
136
- - lib/generators/paperclip/paperclip_generator.rb
137
- - lib/generators/paperclip/templates/paperclip_migration.rb.erb
138
- - lib/generators/paperclip/USAGE
152
+ - lib/paperclip.rb
139
153
  - lib/paperclip/attachment.rb
140
- - lib/paperclip/callback_compatability.rb
141
- - lib/paperclip/command_line.rb
154
+ - lib/paperclip/callback_compatibility.rb
142
155
  - lib/paperclip/geometry.rb
143
156
  - lib/paperclip/interpolations.rb
144
157
  - lib/paperclip/iostream.rb
145
- - lib/paperclip/matchers/have_attached_file_matcher.rb
146
- - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
147
- - lib/paperclip/matchers/validate_attachment_presence_matcher.rb
148
- - lib/paperclip/matchers/validate_attachment_size_matcher.rb
149
158
  - lib/paperclip/matchers.rb
150
159
  - lib/paperclip/processor.rb
151
160
  - lib/paperclip/railtie.rb
152
- - lib/paperclip/storage/filesystem.rb
153
- - lib/paperclip/storage/fog.rb
154
- - lib/paperclip/storage/s3.rb
155
161
  - lib/paperclip/storage.rb
156
162
  - lib/paperclip/style.rb
157
163
  - lib/paperclip/thumbnail.rb
158
164
  - lib/paperclip/upfile.rb
159
165
  - lib/paperclip/version.rb
160
- - lib/paperclip.rb
161
166
  - lib/tasks/paperclip.rake
167
+ - lib/paperclip/matchers/have_attached_file_matcher.rb
168
+ - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
169
+ - lib/paperclip/matchers/validate_attachment_presence_matcher.rb
170
+ - lib/paperclip/matchers/validate_attachment_size_matcher.rb
171
+ - lib/paperclip/storage/filesystem.rb
172
+ - lib/paperclip/storage/fog.rb
173
+ - lib/paperclip/storage/s3.rb
174
+ - lib/generators/paperclip/paperclip_generator.rb
175
+ - lib/generators/paperclip/USAGE
176
+ - lib/generators/paperclip/templates/paperclip_migration.rb.erb
162
177
  - test/attachment_test.rb
163
- - test/command_line_test.rb
164
178
  - test/database.yml
165
- - test/fixtures/12k.png
166
- - test/fixtures/50x50.png
167
- - test/fixtures/5k.png
168
- - test/fixtures/bad.png
169
- - test/fixtures/s3.yml
170
- - test/fixtures/text.txt
171
- - test/fixtures/twopage.pdf
172
- - test/fixtures/uppercase.PNG
173
179
  - test/fog_test.rb
174
180
  - test/geometry_test.rb
175
181
  - test/helper.rb
176
182
  - test/integration_test.rb
177
183
  - test/interpolations_test.rb
178
184
  - test/iostream_test.rb
179
- - test/matchers/have_attached_file_matcher_test.rb
180
- - test/matchers/validate_attachment_content_type_matcher_test.rb
181
- - test/matchers/validate_attachment_presence_matcher_test.rb
182
- - test/matchers/validate_attachment_size_matcher_test.rb
183
185
  - test/paperclip_test.rb
184
186
  - test/processor_test.rb
185
187
  - test/storage_test.rb
186
188
  - test/style_test.rb
187
189
  - test/thumbnail_test.rb
188
190
  - test/upfile_test.rb
189
- - rails/init.rb
191
+ - test/fixtures/12k.png
192
+ - test/fixtures/50x50.png
193
+ - test/fixtures/5k.png
194
+ - test/fixtures/animated.gif
195
+ - test/fixtures/bad.png
196
+ - test/fixtures/s3.yml
197
+ - test/fixtures/text.txt
198
+ - test/fixtures/twopage.pdf
199
+ - test/fixtures/uppercase.PNG
200
+ - test/matchers/have_attached_file_matcher_test.rb
201
+ - test/matchers/validate_attachment_content_type_matcher_test.rb
202
+ - test/matchers/validate_attachment_presence_matcher_test.rb
203
+ - test/matchers/validate_attachment_size_matcher_test.rb
190
204
  - generators/paperclip/paperclip_generator.rb
191
- - generators/paperclip/templates/paperclip_migration.rb.erb
192
205
  - generators/paperclip/USAGE
206
+ - generators/paperclip/templates/paperclip_migration.rb.erb
193
207
  - shoulda_macros/paperclip.rb
194
208
  has_rdoc: true
195
- homepage: http://www.thoughtbot.com/projects/paperclip
209
+ homepage: https://github.com/thoughtbot/paperclip
196
210
  licenses: []
197
211
 
198
212
  post_install_message:
@@ -222,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
236
  requirements:
223
237
  - ImageMagick
224
238
  rubyforge_project: paperclip
225
- rubygems_version: 1.4.1
239
+ rubygems_version: 1.5.2
226
240
  signing_key:
227
241
  specification_version: 3
228
242
  summary: File attachments as attributes for ActiveRecord
@@ -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