paperclip 2.5.0 → 2.5.1

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.

@@ -0,0 +1,14 @@
1
+ 2012-01-20 Jon Yurek <jyurek@thoughtbot.com>
2
+
3
+ * lib/paperclip/railtie.rb (insert): Hide ActiveRecord-specific stuff in
4
+ the Railtie
5
+
6
+ 2012-01-18 Luke Griffiths <wlgriffiths@gmail.com>
7
+
8
+ * lib/paperclip/storage/s3.rb (self.extended),
9
+ test/storage/s3_live_test.rb, test/storage/s3_test.rb: Add S3 encryption
10
+
11
+ 2012-01-16 Jeremy McNevin <jeremy.mcnevin@thedolancompany.com> and ralph <ralph@rvdh.de>
12
+
13
+ * lib/paperclip/storage/fog.rb (flush_writes), fog_test.rb: Pass the
14
+ content type to Fog.
data/NEWS CHANGED
@@ -1,3 +1,9 @@
1
+ New in 2.5.1:
2
+
3
+ * Feature: After we've computed the content type, pass it to Fog.
4
+ * Feature: S3 encryption with the new :s3_server_side_encryption option.
5
+ * Feature: Works without ActiveRecord, allowing for e.g. mongo backends.
6
+
1
7
  New in 2.5.0:
2
8
 
3
9
  * Performance: Only connect to S3 when absolutely needed.
@@ -18,14 +18,18 @@ module Paperclip
18
18
 
19
19
  class Railtie
20
20
  def self.insert
21
- ActiveRecord::Base.send(:include, Paperclip::Glue)
22
- File.send(:include, Paperclip::Upfile)
21
+ Paperclip.options[:logger] = Rails.logger
22
+
23
+ if defined?(ActiveRecord)
24
+ ActiveRecord::Base.send(:include, Paperclip::Glue)
25
+ Paperclip.options[:logger] = ActiveRecord::Base.logger
23
26
 
24
- Paperclip.options[:logger] = defined?(ActiveRecord) ? ActiveRecord::Base.logger : Rails.logger
27
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Paperclip::Schema)
28
+ ActiveRecord::ConnectionAdapters::Table.send(:include, Paperclip::Schema)
29
+ ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Paperclip::Schema)
30
+ end
25
31
 
26
- ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Paperclip::Schema)
27
- ActiveRecord::ConnectionAdapters::Table.send(:include, Paperclip::Schema)
28
- ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Paperclip::Schema)
32
+ File.send(:include, Paperclip::Upfile)
29
33
  end
30
34
  end
31
35
  end
@@ -80,9 +80,10 @@ module Paperclip
80
80
  retried = false
81
81
  begin
82
82
  directory.files.create(fog_file.merge(
83
- :body => file,
84
- :key => path(style),
85
- :public => fog_public
83
+ :body => file,
84
+ :key => path(style),
85
+ :public => fog_public,
86
+ :content_type => file.content_type.to_s.strip
86
87
  ))
87
88
  rescue Excon::Errors::NotFound
88
89
  raise if retried
@@ -115,6 +115,8 @@ module Paperclip
115
115
 
116
116
  @s3_headers[:storage_class] = @options[:s3_storage_class] if @options[:s3_storage_class]
117
117
 
118
+ @s3_server_side_encryption = @options[:s3_server_side_encryption]
119
+
118
120
  unless @options[:url].to_s.match(/^:s3.*url$/) || @options[:url] == ":asset_host"
119
121
  @options[:path] = @options[:path].gsub(/:url/, @options[:url]).gsub(/^:rails_root\/public\/system/, '')
120
122
  @options[:url] = ":s3_path_url"
@@ -281,6 +283,9 @@ module Paperclip
281
283
  :acl => acl
282
284
  }
283
285
  write_options[:metadata] = @s3_metadata unless @s3_metadata.empty?
286
+ unless @s3_server_side_encryption.blank?
287
+ write_options[:server_side_encryption] = @s3_server_side_encryption
288
+ end
284
289
  write_options.merge!(@s3_headers)
285
290
  s3_object(style).write(file, write_options)
286
291
  rescue AWS::S3::Errors::NoSuchBucket => e
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "2.5.0" unless defined? Paperclip::VERSION
2
+ VERSION = "2.5.1" unless defined? Paperclip::VERSION
3
3
  end
@@ -110,6 +110,13 @@ class FogTest < Test::Unit::TestCase
110
110
  directory.destroy
111
111
  end
112
112
 
113
+ should "pass the content type to the Fog::Storage::AWS::Files instance" do
114
+ Fog::Storage::AWS::Files.any_instance.expects(:create).with do |hash|
115
+ hash[:content_type]
116
+ end
117
+ @dummy.save
118
+ end
119
+
113
120
  context "without a bucket" do
114
121
  setup do
115
122
  @connection.directories.get(@fog_directory).destroy
@@ -134,5 +134,41 @@ unless ENV["S3_BUCKET"].blank?
134
134
  assert_not_found_response url
135
135
  end
136
136
  end
137
+
138
+ context "An attachment that uses S3 for storage and uses AES256 encryption" do
139
+ setup do
140
+ rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" },
141
+ :storage => :s3,
142
+ :bucket => ENV["S3_BUCKET"],
143
+ :path => ":class/:attachment/:id/:style.:extension",
144
+ :s3_credentials => File.new(File.join(File.dirname(__FILE__), "..", "fixtures", "s3.yml")),
145
+ :s3_server_side_encryption => :aes256
146
+
147
+ Dummy.delete_all
148
+ @dummy = Dummy.new
149
+ end
150
+
151
+ context "when assigned" do
152
+ setup do
153
+ @file = File.new(fixture_file('5k.png'), 'rb')
154
+ @dummy.avatar = @file
155
+ end
156
+
157
+ teardown do
158
+ @file.close
159
+ @dummy.destroy
160
+ end
161
+
162
+ context "and saved" do
163
+ setup do
164
+ @dummy.save
165
+ end
166
+
167
+ should "be encrypted on S3" do
168
+ assert @dummy.avatar.s3_object.server_side_encryption == :aes256
169
+ end
170
+ end
171
+ end
172
+ end
137
173
  end
138
174
  end
@@ -684,6 +684,45 @@ class S3Test < Test::Unit::TestCase
684
684
  end
685
685
  end
686
686
 
687
+ context "An attachment with S3 storage and using AES256 encryption" do
688
+ setup do
689
+ rebuild_model :storage => :s3,
690
+ :bucket => "testing",
691
+ :path => ":attachment/:style/:basename.:extension",
692
+ :s3_credentials => {
693
+ 'access_key_id' => "12345",
694
+ 'secret_access_key' => "54321"
695
+ },
696
+ :s3_server_side_encryption => :aes256
697
+ end
698
+
699
+ context "when assigned" do
700
+ setup do
701
+ @file = File.new(File.join(File.dirname(__FILE__), '..', 'fixtures', '5k.png'), 'rb')
702
+ @dummy = Dummy.new
703
+ @dummy.avatar = @file
704
+ end
705
+
706
+ teardown { @file.close }
707
+
708
+ context "and saved" do
709
+ setup do
710
+ object = stub
711
+ @dummy.avatar.stubs(:s3_object).returns(object)
712
+ object.expects(:write).with(anything,
713
+ :content_type => "image/png",
714
+ :acl => :public_read,
715
+ :server_side_encryption => :aes256)
716
+ @dummy.save
717
+ end
718
+
719
+ should "succeed" do
720
+ assert true
721
+ end
722
+ end
723
+ end
724
+ end
725
+
687
726
  context "An attachment with S3 storage and storage class set using the :storage_class option" do
688
727
  setup do
689
728
  rebuild_model :storage => :s3,
metadata CHANGED
@@ -1,287 +1,215 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.5.1
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 5
9
- - 0
10
- version: 2.5.0
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
- date: 2012-01-13 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- type: :runtime
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-01-27 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: &14283600 !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 2
30
- - 3
31
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
32
21
  version: 2.3.0
33
- prerelease: false
34
- name: activerecord
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
22
  type: :runtime
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 7
44
- segments:
45
- - 2
46
- - 3
47
- - 2
48
- version: 2.3.2
49
23
  prerelease: false
24
+ version_requirements: *14283600
25
+ - !ruby/object:Gem::Dependency
50
26
  name: activesupport
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- type: :runtime
54
- requirement: &id003 !ruby/object:Gem::Requirement
27
+ requirement: &14282500 !ruby/object:Gem::Requirement
55
28
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 27
60
- segments:
61
- - 0
62
- - 0
63
- - 2
64
- version: 0.0.2
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.3.2
33
+ type: :runtime
65
34
  prerelease: false
35
+ version_requirements: *14282500
36
+ - !ruby/object:Gem::Dependency
66
37
  name: cocaine
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- type: :runtime
70
- requirement: &id004 !ruby/object:Gem::Requirement
38
+ requirement: &14280720 !ruby/object:Gem::Requirement
71
39
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.2
44
+ type: :runtime
79
45
  prerelease: false
46
+ version_requirements: *14280720
47
+ - !ruby/object:Gem::Dependency
80
48
  name: mime-types
81
- version_requirements: *id004
82
- - !ruby/object:Gem::Dependency
83
- type: :development
84
- requirement: &id005 !ruby/object:Gem::Requirement
49
+ requirement: &14279580 !ruby/object:Gem::Requirement
85
50
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- hash: 3
90
- segments:
91
- - 0
92
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
93
56
  prerelease: false
57
+ version_requirements: *14279580
58
+ - !ruby/object:Gem::Dependency
94
59
  name: shoulda
95
- version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
60
+ requirement: &14276160 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
97
66
  type: :development
98
- requirement: &id006 !ruby/object:Gem::Requirement
67
+ prerelease: false
68
+ version_requirements: *14276160
69
+ - !ruby/object:Gem::Dependency
70
+ name: appraisal
71
+ requirement: &14274240 !ruby/object:Gem::Requirement
99
72
  none: false
100
- requirements:
73
+ requirements:
101
74
  - - ~>
102
- - !ruby/object:Gem::Version
103
- hash: 15
104
- segments:
105
- - 0
106
- - 4
107
- - 0
75
+ - !ruby/object:Gem::Version
108
76
  version: 0.4.0
109
- prerelease: false
110
- name: appraisal
111
- version_requirements: *id006
112
- - !ruby/object:Gem::Dependency
113
77
  type: :development
114
- requirement: &id007 !ruby/object:Gem::Requirement
115
- none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
123
78
  prerelease: false
79
+ version_requirements: *14274240
80
+ - !ruby/object:Gem::Dependency
124
81
  name: mocha
125
- version_requirements: *id007
126
- - !ruby/object:Gem::Dependency
127
- type: :development
128
- requirement: &id008 !ruby/object:Gem::Requirement
82
+ requirement: &14273340 !ruby/object:Gem::Requirement
129
83
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
135
- - 0
136
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
137
89
  prerelease: false
90
+ version_requirements: *14273340
91
+ - !ruby/object:Gem::Dependency
138
92
  name: aws-sdk
139
- version_requirements: *id008
140
- - !ruby/object:Gem::Dependency
93
+ requirement: &14272400 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
141
99
  type: :development
142
- requirement: &id009 !ruby/object:Gem::Requirement
100
+ prerelease: false
101
+ version_requirements: *14272400
102
+ - !ruby/object:Gem::Dependency
103
+ name: sqlite3
104
+ requirement: &14271240 !ruby/object:Gem::Requirement
143
105
  none: false
144
- requirements:
106
+ requirements:
145
107
  - - ~>
146
- - !ruby/object:Gem::Version
147
- hash: 19
148
- segments:
149
- - 1
150
- - 3
151
- - 4
108
+ - !ruby/object:Gem::Version
152
109
  version: 1.3.4
153
- prerelease: false
154
- name: sqlite3
155
- version_requirements: *id009
156
- - !ruby/object:Gem::Dependency
157
110
  type: :development
158
- requirement: &id010 !ruby/object:Gem::Requirement
111
+ prerelease: false
112
+ version_requirements: *14271240
113
+ - !ruby/object:Gem::Dependency
114
+ name: cucumber
115
+ requirement: &14270340 !ruby/object:Gem::Requirement
159
116
  none: false
160
- requirements:
117
+ requirements:
161
118
  - - ~>
162
- - !ruby/object:Gem::Version
163
- hash: 19
164
- segments:
165
- - 1
166
- - 1
167
- - 0
119
+ - !ruby/object:Gem::Version
168
120
  version: 1.1.0
169
- prerelease: false
170
- name: cucumber
171
- version_requirements: *id010
172
- - !ruby/object:Gem::Dependency
173
121
  type: :development
174
- requirement: &id011 !ruby/object:Gem::Requirement
175
- none: false
176
- requirements:
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- hash: 3
180
- segments:
181
- - 0
182
- version: "0"
183
122
  prerelease: false
123
+ version_requirements: *14270340
124
+ - !ruby/object:Gem::Dependency
184
125
  name: aruba
185
- version_requirements: *id011
186
- - !ruby/object:Gem::Dependency
187
- type: :development
188
- requirement: &id012 !ruby/object:Gem::Requirement
126
+ requirement: &14269680 !ruby/object:Gem::Requirement
189
127
  none: false
190
- requirements:
191
- - - ">="
192
- - !ruby/object:Gem::Version
193
- hash: 3
194
- segments:
195
- - 0
196
- version: "0"
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
197
133
  prerelease: false
134
+ version_requirements: *14269680
135
+ - !ruby/object:Gem::Dependency
198
136
  name: capybara
199
- version_requirements: *id012
200
- - !ruby/object:Gem::Dependency
201
- type: :development
202
- requirement: &id013 !ruby/object:Gem::Requirement
137
+ requirement: &14268260 !ruby/object:Gem::Requirement
203
138
  none: false
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- hash: 3
208
- segments:
209
- - 0
210
- version: "0"
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :development
211
144
  prerelease: false
145
+ version_requirements: *14268260
146
+ - !ruby/object:Gem::Dependency
212
147
  name: bundler
213
- version_requirements: *id013
214
- - !ruby/object:Gem::Dependency
215
- type: :development
216
- requirement: &id014 !ruby/object:Gem::Requirement
148
+ requirement: &14264560 !ruby/object:Gem::Requirement
217
149
  none: false
218
- requirements:
219
- - - ~>
220
- - !ruby/object:Gem::Version
221
- hash: 15
222
- segments:
223
- - 0
224
- - 2
225
- version: "0.2"
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
226
155
  prerelease: false
156
+ version_requirements: *14264560
157
+ - !ruby/object:Gem::Dependency
227
158
  name: cocaine
228
- version_requirements: *id014
229
- - !ruby/object:Gem::Dependency
230
- type: :development
231
- requirement: &id015 !ruby/object:Gem::Requirement
159
+ requirement: &14262640 !ruby/object:Gem::Requirement
232
160
  none: false
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- hash: 3
237
- segments:
238
- - 0
239
- version: "0"
161
+ requirements:
162
+ - - ~>
163
+ - !ruby/object:Gem::Version
164
+ version: '0.2'
165
+ type: :development
240
166
  prerelease: false
167
+ version_requirements: *14262640
168
+ - !ruby/object:Gem::Dependency
241
169
  name: fog
242
- version_requirements: *id015
243
- - !ruby/object:Gem::Dependency
244
- type: :development
245
- requirement: &id016 !ruby/object:Gem::Requirement
170
+ requirement: &14253520 !ruby/object:Gem::Requirement
246
171
  none: false
247
- requirements:
248
- - - ">="
249
- - !ruby/object:Gem::Version
250
- hash: 3
251
- segments:
252
- - 0
253
- version: "0"
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ type: :development
254
177
  prerelease: false
178
+ version_requirements: *14253520
179
+ - !ruby/object:Gem::Dependency
255
180
  name: rake
256
- version_requirements: *id016
257
- - !ruby/object:Gem::Dependency
258
- type: :development
259
- requirement: &id017 !ruby/object:Gem::Requirement
181
+ requirement: &14249900 !ruby/object:Gem::Requirement
260
182
  none: false
261
- requirements:
262
- - - ">="
263
- - !ruby/object:Gem::Version
264
- hash: 3
265
- segments:
266
- - 0
267
- version: "0"
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ type: :development
268
188
  prerelease: false
189
+ version_requirements: *14249900
190
+ - !ruby/object:Gem::Dependency
269
191
  name: fakeweb
270
- version_requirements: *id017
192
+ requirement: &14244620 !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: *14244620
271
201
  description: Easy upload management for ActiveRecord
272
- email:
202
+ email:
273
203
  - jyurek@thoughtbot.com
274
204
  executables: []
275
-
276
205
  extensions: []
277
-
278
206
  extra_rdoc_files: []
279
-
280
- files:
207
+ files:
281
208
  - .gitignore
282
209
  - .travis.yml
283
210
  - Appraisals
284
211
  - CONTRIBUTING.md
212
+ - ChangeLog
285
213
  - Gemfile
286
214
  - Gemfile.lock
287
215
  - LICENSE
@@ -385,31 +313,29 @@ files:
385
313
  - test/url_generator_test.rb
386
314
  homepage: https://github.com/thoughtbot/paperclip
387
315
  licenses: []
388
-
389
316
  post_install_message:
390
317
  rdoc_options: []
391
-
392
- require_paths:
318
+ require_paths:
393
319
  - lib
394
- required_ruby_version: !ruby/object:Gem::Requirement
320
+ required_ruby_version: !ruby/object:Gem::Requirement
395
321
  none: false
396
- requirements:
397
- - - ">="
398
- - !ruby/object:Gem::Version
399
- hash: 3
400
- segments:
322
+ requirements:
323
+ - - ! '>='
324
+ - !ruby/object:Gem::Version
325
+ version: '0'
326
+ segments:
401
327
  - 0
402
- version: "0"
403
- required_rubygems_version: !ruby/object:Gem::Requirement
328
+ hash: -125325840175155071
329
+ required_rubygems_version: !ruby/object:Gem::Requirement
404
330
  none: false
405
- requirements:
406
- - - ">="
407
- - !ruby/object:Gem::Version
408
- hash: 3
409
- segments:
331
+ requirements:
332
+ - - ! '>='
333
+ - !ruby/object:Gem::Version
334
+ version: '0'
335
+ segments:
410
336
  - 0
411
- version: "0"
412
- requirements:
337
+ hash: -125325840175155071
338
+ requirements:
413
339
  - ImageMagick
414
340
  rubyforge_project: paperclip
415
341
  rubygems_version: 1.8.11
@@ -417,4 +343,3 @@ signing_key:
417
343
  specification_version: 3
418
344
  summary: File attachments as attributes for ActiveRecord
419
345
  test_files: []
420
-