carrierwave 1.3.2 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +235 -91
  3. data/lib/carrierwave/compatibility/paperclip.rb +4 -2
  4. data/lib/carrierwave/downloader/base.rb +101 -0
  5. data/lib/carrierwave/downloader/remote_file.rb +68 -0
  6. data/lib/carrierwave/locale/en.yml +9 -6
  7. data/lib/carrierwave/mount.rb +53 -61
  8. data/lib/carrierwave/mounter.rb +167 -77
  9. data/lib/carrierwave/orm/activerecord.rb +23 -58
  10. data/lib/carrierwave/processing/mini_magick.rb +108 -123
  11. data/lib/carrierwave/processing/rmagick.rb +11 -15
  12. data/lib/carrierwave/processing/vips.rb +284 -0
  13. data/lib/carrierwave/processing.rb +1 -0
  14. data/lib/carrierwave/sanitized_file.rb +60 -66
  15. data/lib/carrierwave/storage/abstract.rb +5 -5
  16. data/lib/carrierwave/storage/file.rb +6 -5
  17. data/lib/carrierwave/storage/fog.rb +101 -62
  18. data/lib/carrierwave/storage.rb +1 -0
  19. data/lib/carrierwave/test/matchers.rb +11 -7
  20. data/lib/carrierwave/uploader/cache.rb +40 -24
  21. data/lib/carrierwave/uploader/callbacks.rb +1 -1
  22. data/lib/carrierwave/uploader/configuration.rb +38 -19
  23. data/lib/carrierwave/uploader/content_type_allowlist.rb +62 -0
  24. data/lib/carrierwave/uploader/content_type_denylist.rb +62 -0
  25. data/lib/carrierwave/uploader/dimension.rb +66 -0
  26. data/lib/carrierwave/uploader/download.rb +2 -123
  27. data/lib/carrierwave/uploader/extension_allowlist.rb +63 -0
  28. data/lib/carrierwave/uploader/extension_denylist.rb +64 -0
  29. data/lib/carrierwave/uploader/file_size.rb +2 -2
  30. data/lib/carrierwave/uploader/mountable.rb +6 -0
  31. data/lib/carrierwave/uploader/processing.rb +42 -7
  32. data/lib/carrierwave/uploader/proxy.rb +17 -4
  33. data/lib/carrierwave/uploader/serialization.rb +1 -1
  34. data/lib/carrierwave/uploader/store.rb +47 -7
  35. data/lib/carrierwave/uploader/url.rb +7 -4
  36. data/lib/carrierwave/uploader/versions.rb +157 -109
  37. data/lib/carrierwave/uploader.rb +10 -17
  38. data/lib/carrierwave/utilities/file_name.rb +47 -0
  39. data/lib/carrierwave/utilities/uri.rb +14 -11
  40. data/lib/carrierwave/utilities.rb +1 -0
  41. data/lib/carrierwave/validations/active_model.rb +7 -9
  42. data/lib/carrierwave/version.rb +1 -1
  43. data/lib/carrierwave.rb +13 -17
  44. data/lib/generators/templates/{uploader.rb → uploader.rb.erb} +3 -3
  45. data/lib/generators/uploader_generator.rb +3 -3
  46. metadata +103 -36
  47. data/lib/carrierwave/uploader/content_type_blacklist.rb +0 -48
  48. data/lib/carrierwave/uploader/content_type_whitelist.rb +0 -48
  49. data/lib/carrierwave/uploader/extension_blacklist.rb +0 -51
  50. data/lib/carrierwave/uploader/extension_whitelist.rb +0 -52
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-08 00:00:00.000000000 Z
11
+ date: 2024-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,84 +16,98 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.0
33
+ version: 6.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.0.0
40
+ version: 6.0.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: mime-types
42
+ name: image_processing
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.16'
47
+ version: '1.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.16'
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: ssrf_filter
56
+ name: marcel
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: 1.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: 1.0.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: pg
70
+ name: addressable
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
75
+ version: '2.6'
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '2.6'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rails
84
+ name: ssrf_filter
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
88
95
  - !ruby/object:Gem::Version
89
- version: 4.0.0
96
+ version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: csv
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">="
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 4.0.0
110
+ version: '3.0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: cucumber
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,34 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '3.4'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec-retry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.28'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.28'
125
167
  - !ruby/object:Gem::Dependency
126
168
  name: webmock
127
169
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +198,20 @@ dependencies:
156
198
  requirements:
157
199
  - - "~>"
158
200
  - !ruby/object:Gem::Version
159
- version: 1.7.1
201
+ version: '1.7'
202
+ - - "!="
203
+ - !ruby/object:Gem::Version
204
+ version: 1.12.1
160
205
  type: :development
161
206
  prerelease: false
162
207
  version_requirements: !ruby/object:Gem::Requirement
163
208
  requirements:
164
209
  - - "~>"
165
210
  - !ruby/object:Gem::Version
166
- version: 1.7.1
211
+ version: '1.7'
212
+ - - "!="
213
+ - !ruby/object:Gem::Version
214
+ version: 1.12.1
167
215
  - !ruby/object:Gem::Dependency
168
216
  name: fog-local
169
217
  requirement: !ruby/object:Gem::Requirement
@@ -210,14 +258,14 @@ dependencies:
210
258
  name: rmagick
211
259
  requirement: !ruby/object:Gem::Requirement
212
260
  requirements:
213
- - - "~>"
261
+ - - ">="
214
262
  - !ruby/object:Gem::Version
215
263
  version: '2.16'
216
264
  type: :development
217
265
  prerelease: false
218
266
  version_requirements: !ruby/object:Gem::Requirement
219
267
  requirements:
220
- - - "~>"
268
+ - - ">="
221
269
  - !ruby/object:Gem::Version
222
270
  version: '2.16'
223
271
  - !ruby/object:Gem::Dependency
@@ -262,6 +310,20 @@ dependencies:
262
310
  - - ">="
263
311
  - !ruby/object:Gem::Version
264
312
  version: '0'
313
+ - !ruby/object:Gem::Dependency
314
+ name: pry-byebug
315
+ requirement: !ruby/object:Gem::Requirement
316
+ requirements:
317
+ - - ">="
318
+ - !ruby/object:Gem::Version
319
+ version: '0'
320
+ type: :development
321
+ prerelease: false
322
+ version_requirements: !ruby/object:Gem::Requirement
323
+ requirements:
324
+ - - ">="
325
+ - !ruby/object:Gem::Version
326
+ version: '0'
265
327
  description: Upload files in your Ruby applications, map them to a range of ORMs,
266
328
  store them on different backends.
267
329
  email:
@@ -274,6 +336,8 @@ files:
274
336
  - README.md
275
337
  - lib/carrierwave.rb
276
338
  - lib/carrierwave/compatibility/paperclip.rb
339
+ - lib/carrierwave/downloader/base.rb
340
+ - lib/carrierwave/downloader/remote_file.rb
277
341
  - lib/carrierwave/error.rb
278
342
  - lib/carrierwave/locale/en.yml
279
343
  - lib/carrierwave/mount.rb
@@ -282,6 +346,7 @@ files:
282
346
  - lib/carrierwave/processing.rb
283
347
  - lib/carrierwave/processing/mini_magick.rb
284
348
  - lib/carrierwave/processing/rmagick.rb
349
+ - lib/carrierwave/processing/vips.rb
285
350
  - lib/carrierwave/sanitized_file.rb
286
351
  - lib/carrierwave/storage.rb
287
352
  - lib/carrierwave/storage/abstract.rb
@@ -292,12 +357,13 @@ files:
292
357
  - lib/carrierwave/uploader/cache.rb
293
358
  - lib/carrierwave/uploader/callbacks.rb
294
359
  - lib/carrierwave/uploader/configuration.rb
295
- - lib/carrierwave/uploader/content_type_blacklist.rb
296
- - lib/carrierwave/uploader/content_type_whitelist.rb
360
+ - lib/carrierwave/uploader/content_type_allowlist.rb
361
+ - lib/carrierwave/uploader/content_type_denylist.rb
297
362
  - lib/carrierwave/uploader/default_url.rb
363
+ - lib/carrierwave/uploader/dimension.rb
298
364
  - lib/carrierwave/uploader/download.rb
299
- - lib/carrierwave/uploader/extension_blacklist.rb
300
- - lib/carrierwave/uploader/extension_whitelist.rb
365
+ - lib/carrierwave/uploader/extension_allowlist.rb
366
+ - lib/carrierwave/uploader/extension_denylist.rb
301
367
  - lib/carrierwave/uploader/file_size.rb
302
368
  - lib/carrierwave/uploader/mountable.rb
303
369
  - lib/carrierwave/uploader/processing.rb
@@ -308,10 +374,11 @@ files:
308
374
  - lib/carrierwave/uploader/url.rb
309
375
  - lib/carrierwave/uploader/versions.rb
310
376
  - lib/carrierwave/utilities.rb
377
+ - lib/carrierwave/utilities/file_name.rb
311
378
  - lib/carrierwave/utilities/uri.rb
312
379
  - lib/carrierwave/validations/active_model.rb
313
380
  - lib/carrierwave/version.rb
314
- - lib/generators/templates/uploader.rb
381
+ - lib/generators/templates/uploader.rb.erb
315
382
  - lib/generators/uploader_generator.rb
316
383
  homepage: https://github.com/carrierwaveuploader/carrierwave
317
384
  licenses:
@@ -326,14 +393,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
326
393
  requirements:
327
394
  - - ">="
328
395
  - !ruby/object:Gem::Version
329
- version: 2.0.0
396
+ version: 2.5.0
330
397
  required_rubygems_version: !ruby/object:Gem::Requirement
331
398
  requirements:
332
399
  - - ">="
333
400
  - !ruby/object:Gem::Version
334
401
  version: '0'
335
402
  requirements: []
336
- rubygems_version: 3.1.2
403
+ rubygems_version: 3.4.10
337
404
  signing_key:
338
405
  specification_version: 4
339
406
  summary: Ruby file upload library
@@ -1,48 +0,0 @@
1
- module CarrierWave
2
- module Uploader
3
- module ContentTypeBlacklist
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- before :cache, :check_content_type_blacklist!
8
- end
9
-
10
- ##
11
- # Override this method in your uploader to provide a blacklist of files content types
12
- # which are not allowed to be uploaded.
13
- # Not only strings but Regexp are allowed as well.
14
- #
15
- # === Returns
16
- #
17
- # [NilClass, String, Regexp, Array[String, Regexp]] a blacklist of content types which are not allowed to be uploaded
18
- #
19
- # === Examples
20
- #
21
- # def content_type_blacklist
22
- # %w(text/json application/json)
23
- # end
24
- #
25
- # Basically the same, but using a Regexp:
26
- #
27
- # def content_type_blacklist
28
- # [/(text|application)\/json/]
29
- # end
30
- #
31
- def content_type_blacklist; end
32
-
33
- private
34
-
35
- def check_content_type_blacklist!(new_file)
36
- content_type = new_file.content_type
37
- if content_type_blacklist && blacklisted_content_type?(content_type)
38
- raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.content_type_blacklist_error", content_type: content_type)
39
- end
40
- end
41
-
42
- def blacklisted_content_type?(content_type)
43
- Array(content_type_blacklist).any? { |item| content_type =~ /#{item}/ }
44
- end
45
-
46
- end # ContentTypeBlacklist
47
- end # Uploader
48
- end # CarrierWave
@@ -1,48 +0,0 @@
1
- module CarrierWave
2
- module Uploader
3
- module ContentTypeWhitelist
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- before :cache, :check_content_type_whitelist!
8
- end
9
-
10
- ##
11
- # Override this method in your uploader to provide a whitelist of files content types
12
- # which are allowed to be uploaded.
13
- # Not only strings but Regexp are allowed as well.
14
- #
15
- # === Returns
16
- #
17
- # [NilClass, String, Regexp, Array[String, Regexp]] a whitelist of content types which are allowed to be uploaded
18
- #
19
- # === Examples
20
- #
21
- # def content_type_whitelist
22
- # %w(text/json application/json)
23
- # end
24
- #
25
- # Basically the same, but using a Regexp:
26
- #
27
- # def content_type_whitelist
28
- # [/(text|application)\/json/]
29
- # end
30
- #
31
- def content_type_whitelist; end
32
-
33
- private
34
-
35
- def check_content_type_whitelist!(new_file)
36
- content_type = new_file.content_type
37
- if content_type_whitelist && !whitelisted_content_type?(content_type)
38
- raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.content_type_whitelist_error", content_type: content_type, allowed_types: Array(content_type_whitelist).join(", "))
39
- end
40
- end
41
-
42
- def whitelisted_content_type?(content_type)
43
- Array(content_type_whitelist).any? { |item| content_type =~ /#{item}/ }
44
- end
45
-
46
- end # ContentTypeWhitelist
47
- end # Uploader
48
- end # CarrierWave
@@ -1,51 +0,0 @@
1
- module CarrierWave
2
- module Uploader
3
- module ExtensionBlacklist
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- before :cache, :check_extension_blacklist!
8
- end
9
-
10
- ##
11
- # Override this method in your uploader to provide a black list of extensions which
12
- # are prohibited to be uploaded. Compares the file's extension case insensitive.
13
- # Furthermore, not only strings but Regexp are allowed as well.
14
- #
15
- # When using a Regexp in the black list, `\A` and `\z` are automatically added to
16
- # the Regexp expression, also case insensitive.
17
- #
18
- # === Returns
19
-
20
- # [NilClass, String, Regexp, Array[String, Regexp]] a black list of extensions which are prohibited to be uploaded
21
- #
22
- # === Examples
23
- #
24
- # def extension_blacklist
25
- # %w(swf tiff)
26
- # end
27
- #
28
- # Basically the same, but using a Regexp:
29
- #
30
- # def extension_blacklist
31
- # [/swf/, 'tiff']
32
- # end
33
- #
34
-
35
- def extension_blacklist; end
36
-
37
- private
38
-
39
- def check_extension_blacklist!(new_file)
40
- extension = new_file.extension.to_s
41
- if extension_blacklist && blacklisted_extension?(extension)
42
- raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.extension_blacklist_error", extension: new_file.extension.inspect, prohibited_types: Array(extension_blacklist).join(", "))
43
- end
44
- end
45
-
46
- def blacklisted_extension?(extension)
47
- Array(extension_blacklist).any? { |item| extension =~ /\A#{item}\z/i }
48
- end
49
- end
50
- end
51
- end
@@ -1,52 +0,0 @@
1
- module CarrierWave
2
- module Uploader
3
- module ExtensionWhitelist
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- before :cache, :check_extension_whitelist!
8
- end
9
-
10
- ##
11
- # Override this method in your uploader to provide a white list of extensions which
12
- # are allowed to be uploaded. Compares the file's extension case insensitive.
13
- # Furthermore, not only strings but Regexp are allowed as well.
14
- #
15
- # When using a Regexp in the white list, `\A` and `\z` are automatically added to
16
- # the Regexp expression, also case insensitive.
17
- #
18
- # === Returns
19
- #
20
- # [NilClass, String, Regexp, Array[String, Regexp]] a white list of extensions which are allowed to be uploaded
21
- #
22
- # === Examples
23
- #
24
- # def extension_whitelist
25
- # %w(jpg jpeg gif png)
26
- # end
27
- #
28
- # Basically the same, but using a Regexp:
29
- #
30
- # def extension_whitelist
31
- # [/jpe?g/, 'gif', 'png']
32
- # end
33
- #
34
- def extension_whitelist; end
35
-
36
- private
37
-
38
- def check_extension_whitelist!(new_file)
39
- extension = new_file.extension.to_s
40
- if extension_whitelist && !whitelisted_extension?(extension)
41
- raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.extension_whitelist_error", extension: new_file.extension.inspect, allowed_types: Array(extension_whitelist).join(", "))
42
- end
43
- end
44
-
45
- def whitelisted_extension?(extension)
46
- downcase_extension = extension.downcase
47
- Array(extension_whitelist).any? { |item| downcase_extension =~ /\A#{item}\z/i }
48
- end
49
-
50
- end # ExtensionWhitelist
51
- end # Uploader
52
- end # CarrierWave