carrierwave 1.3.2 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of carrierwave might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +117 -43
- data/lib/carrierwave/downloader/base.rb +93 -0
- data/lib/carrierwave/downloader/remote_file.rb +65 -0
- data/lib/carrierwave/locale/en.yml +5 -4
- data/lib/carrierwave/mount.rb +25 -19
- data/lib/carrierwave/mounter.rb +71 -48
- data/lib/carrierwave/orm/activerecord.rb +14 -8
- data/lib/carrierwave/processing/mini_magick.rb +100 -117
- data/lib/carrierwave/processing/rmagick.rb +2 -2
- data/lib/carrierwave/processing/vips.rb +284 -0
- data/lib/carrierwave/processing.rb +1 -0
- data/lib/carrierwave/sanitized_file.rb +38 -16
- data/lib/carrierwave/storage/file.rb +2 -2
- data/lib/carrierwave/storage/fog.rb +44 -13
- data/lib/carrierwave/storage.rb +1 -0
- data/lib/carrierwave/uploader/cache.rb +24 -16
- data/lib/carrierwave/uploader/configuration.rb +28 -15
- data/lib/carrierwave/uploader/content_type_blacklist.rb +17 -8
- data/lib/carrierwave/uploader/content_type_whitelist.rb +20 -8
- data/lib/carrierwave/uploader/download.rb +2 -123
- data/lib/carrierwave/uploader/extension_blacklist.rb +18 -10
- data/lib/carrierwave/uploader/extension_whitelist.rb +19 -10
- data/lib/carrierwave/uploader/mountable.rb +6 -0
- data/lib/carrierwave/uploader/processing.rb +11 -1
- data/lib/carrierwave/uploader/proxy.rb +2 -2
- data/lib/carrierwave/uploader/serialization.rb +1 -1
- data/lib/carrierwave/uploader/store.rb +5 -3
- data/lib/carrierwave/uploader/url.rb +6 -3
- data/lib/carrierwave/uploader/versions.rb +43 -13
- data/lib/carrierwave/uploader.rb +0 -9
- data/lib/carrierwave/validations/active_model.rb +3 -3
- data/lib/carrierwave/version.rb +1 -1
- data/lib/carrierwave.rb +4 -0
- data/lib/generators/templates/uploader.rb +2 -2
- metadata +96 -17
@@ -23,7 +23,7 @@ module CarrierWave
|
|
23
23
|
prepend Module.new {
|
24
24
|
def initialize(*)
|
25
25
|
super
|
26
|
-
@versions = nil
|
26
|
+
@versions, @versions_to_cache, @versions_to_store = nil
|
27
27
|
end
|
28
28
|
}
|
29
29
|
end
|
@@ -220,16 +220,18 @@ module CarrierWave
|
|
220
220
|
# Recreate versions and reprocess them. This can be used to recreate
|
221
221
|
# versions if their parameters somehow have changed.
|
222
222
|
#
|
223
|
-
def recreate_versions!(*
|
223
|
+
def recreate_versions!(*names)
|
224
224
|
# Some files could possibly not be stored on the local disk. This
|
225
225
|
# doesn't play nicely with processing. Make sure that we're only
|
226
226
|
# processing a cached file
|
227
227
|
#
|
228
228
|
# The call to store! will trigger the necessary callbacks to both
|
229
229
|
# process this version and all sub-versions
|
230
|
-
|
231
|
-
|
232
|
-
|
230
|
+
|
231
|
+
if names.any?
|
232
|
+
set_versions_to_cache_and_store(names)
|
233
|
+
store!(file)
|
234
|
+
reset_versions_to_cache_and_store
|
233
235
|
else
|
234
236
|
cache! if !cached?
|
235
237
|
store!
|
@@ -237,6 +239,39 @@ module CarrierWave
|
|
237
239
|
end
|
238
240
|
|
239
241
|
private
|
242
|
+
|
243
|
+
def set_versions_to_cache_and_store(names)
|
244
|
+
@versions_to_cache = source_versions_of(names)
|
245
|
+
@versions_to_store = active_versions_with_names_in(@versions_to_cache + names)
|
246
|
+
end
|
247
|
+
|
248
|
+
def reset_versions_to_cache_and_store
|
249
|
+
@versions_to_cache, @versions_to_store = nil, nil
|
250
|
+
end
|
251
|
+
|
252
|
+
def versions_to_cache
|
253
|
+
@versions_to_cache || dependent_versions
|
254
|
+
end
|
255
|
+
|
256
|
+
def versions_to_store
|
257
|
+
@versions_to_store || active_versions
|
258
|
+
end
|
259
|
+
|
260
|
+
def source_versions_of(requested_names)
|
261
|
+
versions.inject([]) do |sources, (name, uploader)|
|
262
|
+
next sources unless requested_names.include?(name)
|
263
|
+
next sources unless source_name = uploader.class.version_options[:from_version]
|
264
|
+
|
265
|
+
sources << [source_name, versions[source_name]]
|
266
|
+
end.uniq
|
267
|
+
end
|
268
|
+
|
269
|
+
def active_versions_with_names_in(names)
|
270
|
+
active_versions.select do |pretendent_name, uploader|
|
271
|
+
names.include?(pretendent_name)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
240
275
|
def assign_parent_cache_id(file)
|
241
276
|
active_versions.each do |name, uploader|
|
242
277
|
uploader.parent_cache_id = @cache_id
|
@@ -270,19 +305,14 @@ module CarrierWave
|
|
270
305
|
end
|
271
306
|
|
272
307
|
def cache_versions!(new_file)
|
273
|
-
|
308
|
+
versions_to_cache.each do |name, v|
|
274
309
|
v.send(:cache_id=, @cache_id)
|
275
310
|
v.cache!(new_file)
|
276
311
|
end
|
277
312
|
end
|
278
313
|
|
279
|
-
def store_versions!(new_file
|
280
|
-
|
281
|
-
active = Hash[active_versions]
|
282
|
-
versions.each { |v| active[v].try(:store!, new_file) } unless active.empty?
|
283
|
-
else
|
284
|
-
active_versions.each { |name, v| v.store!(new_file) }
|
285
|
-
end
|
314
|
+
def store_versions!(new_file)
|
315
|
+
versions_to_store.each { |name, v| v.store!(new_file) }
|
286
316
|
end
|
287
317
|
|
288
318
|
def remove_versions!
|
data/lib/carrierwave/uploader.rb
CHANGED
@@ -43,15 +43,6 @@ module CarrierWave
|
|
43
43
|
class Base
|
44
44
|
attr_reader :file
|
45
45
|
|
46
|
-
##
|
47
|
-
# Workaround for class_attribute malfunction when used with Module#prepend
|
48
|
-
#
|
49
|
-
if RUBY_VERSION < '2.1.0'
|
50
|
-
def self.singleton_class?
|
51
|
-
!ancestors.include? self
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
46
|
include CarrierWave::Uploader::Configuration
|
56
47
|
include CarrierWave::Uploader::Callbacks
|
57
48
|
include CarrierWave::Uploader::Proxy
|
@@ -11,7 +11,7 @@ module CarrierWave
|
|
11
11
|
class ProcessingValidator < ::ActiveModel::EachValidator
|
12
12
|
|
13
13
|
def validate_each(record, attribute, value)
|
14
|
-
|
14
|
+
record.__send__("#{attribute}_processing_errors").each do |e|
|
15
15
|
message = (e.message == e.class.to_s) ? :carrierwave_processing_error : e.message
|
16
16
|
record.errors.add(attribute, message)
|
17
17
|
end
|
@@ -21,7 +21,7 @@ module CarrierWave
|
|
21
21
|
class IntegrityValidator < ::ActiveModel::EachValidator
|
22
22
|
|
23
23
|
def validate_each(record, attribute, value)
|
24
|
-
|
24
|
+
record.__send__("#{attribute}_integrity_errors").each do |e|
|
25
25
|
message = (e.message == e.class.to_s) ? :carrierwave_integrity_error : e.message
|
26
26
|
record.errors.add(attribute, message)
|
27
27
|
end
|
@@ -31,7 +31,7 @@ module CarrierWave
|
|
31
31
|
class DownloadValidator < ::ActiveModel::EachValidator
|
32
32
|
|
33
33
|
def validate_each(record, attribute, value)
|
34
|
-
|
34
|
+
record.__send__("#{attribute}_download_errors").each do |e|
|
35
35
|
message = (e.message == e.class.to_s) ? :carrierwave_download_error : e.message
|
36
36
|
record.errors.add(attribute, message)
|
37
37
|
end
|
data/lib/carrierwave/version.rb
CHANGED
data/lib/carrierwave.rb
CHANGED
@@ -33,9 +33,9 @@ class <%= class_name %>Uploader < CarrierWave::Uploader::Base
|
|
33
33
|
# process resize_to_fit: [50, 50]
|
34
34
|
# end
|
35
35
|
|
36
|
-
# Add
|
36
|
+
# Add an allowlist of extensions which are allowed to be uploaded.
|
37
37
|
# For images you might use something like this:
|
38
|
-
# def
|
38
|
+
# def extension_allowlist
|
39
39
|
# %w(jpg jpeg gif png)
|
40
40
|
# end
|
41
41
|
|
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:
|
4
|
+
version: 2.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,42 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.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:
|
26
|
+
version: 5.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:
|
33
|
+
version: 5.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:
|
40
|
+
version: 5.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: mini_mime
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.1.3
|
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:
|
54
|
+
version: 0.1.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: image_processing
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: marcel
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: addressable
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.6'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: ssrf_filter
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +128,14 @@ dependencies:
|
|
86
128
|
requirements:
|
87
129
|
- - ">="
|
88
130
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
131
|
+
version: 5.0.0
|
90
132
|
type: :development
|
91
133
|
prerelease: false
|
92
134
|
version_requirements: !ruby/object:Gem::Requirement
|
93
135
|
requirements:
|
94
136
|
- - ">="
|
95
137
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
138
|
+
version: 5.0.0
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
140
|
name: cucumber
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +164,20 @@ dependencies:
|
|
122
164
|
- - "~>"
|
123
165
|
- !ruby/object:Gem::Version
|
124
166
|
version: '3.4'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rspec-retry
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
125
181
|
- !ruby/object:Gem::Dependency
|
126
182
|
name: webmock
|
127
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +212,20 @@ dependencies:
|
|
156
212
|
requirements:
|
157
213
|
- - "~>"
|
158
214
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.7
|
215
|
+
version: '1.7'
|
216
|
+
- - "!="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: 1.12.1
|
160
219
|
type: :development
|
161
220
|
prerelease: false
|
162
221
|
version_requirements: !ruby/object:Gem::Requirement
|
163
222
|
requirements:
|
164
223
|
- - "~>"
|
165
224
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.7
|
225
|
+
version: '1.7'
|
226
|
+
- - "!="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: 1.12.1
|
167
229
|
- !ruby/object:Gem::Dependency
|
168
230
|
name: fog-local
|
169
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,14 +272,14 @@ dependencies:
|
|
210
272
|
name: rmagick
|
211
273
|
requirement: !ruby/object:Gem::Requirement
|
212
274
|
requirements:
|
213
|
-
- - "
|
275
|
+
- - ">="
|
214
276
|
- !ruby/object:Gem::Version
|
215
277
|
version: '2.16'
|
216
278
|
type: :development
|
217
279
|
prerelease: false
|
218
280
|
version_requirements: !ruby/object:Gem::Requirement
|
219
281
|
requirements:
|
220
|
-
- - "
|
282
|
+
- - ">="
|
221
283
|
- !ruby/object:Gem::Version
|
222
284
|
version: '2.16'
|
223
285
|
- !ruby/object:Gem::Dependency
|
@@ -262,6 +324,20 @@ dependencies:
|
|
262
324
|
- - ">="
|
263
325
|
- !ruby/object:Gem::Version
|
264
326
|
version: '0'
|
327
|
+
- !ruby/object:Gem::Dependency
|
328
|
+
name: pry-byebug
|
329
|
+
requirement: !ruby/object:Gem::Requirement
|
330
|
+
requirements:
|
331
|
+
- - ">="
|
332
|
+
- !ruby/object:Gem::Version
|
333
|
+
version: '0'
|
334
|
+
type: :development
|
335
|
+
prerelease: false
|
336
|
+
version_requirements: !ruby/object:Gem::Requirement
|
337
|
+
requirements:
|
338
|
+
- - ">="
|
339
|
+
- !ruby/object:Gem::Version
|
340
|
+
version: '0'
|
265
341
|
description: Upload files in your Ruby applications, map them to a range of ORMs,
|
266
342
|
store them on different backends.
|
267
343
|
email:
|
@@ -274,6 +350,8 @@ files:
|
|
274
350
|
- README.md
|
275
351
|
- lib/carrierwave.rb
|
276
352
|
- lib/carrierwave/compatibility/paperclip.rb
|
353
|
+
- lib/carrierwave/downloader/base.rb
|
354
|
+
- lib/carrierwave/downloader/remote_file.rb
|
277
355
|
- lib/carrierwave/error.rb
|
278
356
|
- lib/carrierwave/locale/en.yml
|
279
357
|
- lib/carrierwave/mount.rb
|
@@ -282,6 +360,7 @@ files:
|
|
282
360
|
- lib/carrierwave/processing.rb
|
283
361
|
- lib/carrierwave/processing/mini_magick.rb
|
284
362
|
- lib/carrierwave/processing/rmagick.rb
|
363
|
+
- lib/carrierwave/processing/vips.rb
|
285
364
|
- lib/carrierwave/sanitized_file.rb
|
286
365
|
- lib/carrierwave/storage.rb
|
287
366
|
- lib/carrierwave/storage/abstract.rb
|
@@ -326,14 +405,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
326
405
|
requirements:
|
327
406
|
- - ">="
|
328
407
|
- !ruby/object:Gem::Version
|
329
|
-
version: 2.
|
408
|
+
version: 2.2.2
|
330
409
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
331
410
|
requirements:
|
332
411
|
- - ">="
|
333
412
|
- !ruby/object:Gem::Version
|
334
413
|
version: '0'
|
335
414
|
requirements: []
|
336
|
-
rubygems_version: 3.
|
415
|
+
rubygems_version: 3.4.10
|
337
416
|
signing_key:
|
338
417
|
specification_version: 4
|
339
418
|
summary: Ruby file upload library
|