carrierwave 2.2.0 → 2.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6e511db9d3eebc43bd42613884cf42ba2ad5f236a438a609cccc67c6ce3d192
4
- data.tar.gz: 20cef424394b5a40d27e73e8677161870c6d35f60734fd05cf2d0666f461b834
3
+ metadata.gz: 188b2d0a4b8e09fcfadd3e5066a1dabe2d6ad178ba26384ea1dbe7da2b9f5eb9
4
+ data.tar.gz: a5a76814bdcb877f75a059a5a0746e8dfb07755dcd5cfea80a7f9a3382dd4af1
5
5
  SHA512:
6
- metadata.gz: 28aeace46926db2716ac4600a67cb3a318c553f8f04f533fcf19afaddbafc46489bc3df5d523bc878f5b77164d4110c69ddfe346944caeb46b0dd83df39d7ac9
7
- data.tar.gz: dc271f6fdfd5a515295185265a53b0b894ecef7e1d72bdcaa062357dacd5c7e9bca54a818ffcd344a95b341628451f5b6e579b62587845148075f9db9de949f7
6
+ metadata.gz: 88a7f9a0fb94488b1b28c842def1b527781b1c7dcefc5c3e3010481b682b5175fc76172f4ac5d77f103dae99fcfbdfc7c61b69737d353f9bcc22a45b0b9cde01
7
+ data.tar.gz: f1c14065946dcaa080e45b5221f39b7da3886b659fe27f4755edf8df72234c1e3aafeb73ccdc0adac5d1ef1cdbdf98adc98f1a2853610b442efe9d1526907eee
data/README.md CHANGED
@@ -361,6 +361,22 @@ created. This can cut down on processing cost.
361
361
 
362
362
  See `carrierwave/processing/mini_magick.rb` for details.
363
363
 
364
+ ### conditional process
365
+
366
+ If you want to use conditional process, you can only use `if` statement.
367
+
368
+ See `carrierwave/uploader/processing.rb` for details.
369
+
370
+ ```ruby
371
+ class MyUploader < CarrierWave::Uploader::Base
372
+ process :scale => [200, 200], :if => :image?
373
+
374
+ def image?(carrier_wave_sanitized_file)
375
+ true
376
+ end
377
+ end
378
+ ```
379
+
364
380
  ### Nested versions
365
381
 
366
382
  It is possible to nest versions within versions:
@@ -1056,6 +1072,8 @@ See [CONTRIBUTING.md](https://github.com/carrierwaveuploader/carrierwave/blob/ma
1056
1072
 
1057
1073
  ## License
1058
1074
 
1075
+ The MIT License (MIT)
1076
+
1059
1077
  Copyright (c) 2008-2015 Jonas Nicklas
1060
1078
 
1061
1079
  Permission is hereby granted, free of charge, to any person obtaining
@@ -29,8 +29,14 @@ module CarrierWave
29
29
  response = OpenURI.open_uri(process_uri(url.to_s), headers)
30
30
  else
31
31
  request = nil
32
- response = SsrfFilter.get(uri, headers: headers) do |req|
33
- request = req
32
+ if ::SsrfFilter::VERSION.to_f < 1.1
33
+ response = SsrfFilter.get(uri, headers: headers) do |req|
34
+ request = req
35
+ end
36
+ else
37
+ response = SsrfFilter.get(uri, headers: headers, request_proc: ->(req) { request = req }) do |res|
38
+ res.body # ensure to read body
39
+ end
34
40
  end
35
41
  response.uri = request.uri
36
42
  response.value
@@ -1,8 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'active_support/core_ext/string/multibyte'
3
3
  require 'mini_mime'
4
- require 'mimemagic'
5
- require 'mimemagic/overlay'
4
+ require 'marcel'
6
5
 
7
6
  module CarrierWave
8
7
 
@@ -262,7 +261,7 @@ module CarrierWave
262
261
  def content_type
263
262
  @content_type ||=
264
263
  existing_content_type ||
265
- mime_magic_content_type ||
264
+ marcel_magic_content_type ||
266
265
  mini_mime_content_type
267
266
  end
268
267
 
@@ -325,18 +324,18 @@ module CarrierWave
325
324
 
326
325
  def existing_content_type
327
326
  if @file.respond_to?(:content_type) && @file.content_type
328
- @file.content_type.to_s.chomp
327
+ Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)
329
328
  end
330
329
  end
331
330
 
332
- def mime_magic_content_type
331
+ def marcel_magic_content_type
333
332
  if path
334
333
  type = File.open(path) do |file|
335
- MimeMagic.by_magic(file).try(:type)
334
+ Marcel::Magic.by_magic(file).try(:type)
336
335
  end
337
336
 
338
337
  if type.nil?
339
- type = ::MiniMime.lookup_by_filename(path).try(:content_type)
338
+ type = Marcel::Magic.by_path(path).try(:type)
340
339
  type = 'invalid/invalid' unless type.nil? || type.start_with?('text/')
341
340
  end
342
341
 
@@ -30,7 +30,7 @@ module CarrierWave
30
30
  #
31
31
  # Google credentials contain the following keys:
32
32
  # [:google_storage_access_key_id]
33
- # [:google_storage_secrete_access_key]
33
+ # [:google_storage_secret_access_key]
34
34
  #
35
35
  #
36
36
  # Local credentials contain the following keys:
@@ -147,8 +147,9 @@ module CarrierWave
147
147
  :public => uploader.fog_public
148
148
  ).files.all(:prefix => uploader.cache_dir).each do |file|
149
149
  # generate_cache_id returns key formated TIMEINT-PID(-COUNTER)-RND
150
- time = file.key.scan(/(\d+)-\d+-\d+(?:-\d+)?/).first.map { |t| t.to_i }
151
- time = Time.at(*time)
150
+ matched = file.key.match(/(\d+)-\d+-\d+(?:-\d+)?/)
151
+ next unless matched
152
+ time = Time.at(matched[1].to_i)
152
153
  file.destroy if time < (Time.now.utc - seconds)
153
154
  end
154
155
  end
@@ -51,7 +51,7 @@ module CarrierWave
51
51
  def whitelisted_content_type?(content_type)
52
52
  Array(content_type_allowlist).any? do |item|
53
53
  item = Regexp.quote(item) if item.class != Regexp
54
- content_type =~ /#{item}/
54
+ content_type =~ /\A#{item}/
55
55
  end
56
56
  end
57
57
 
@@ -80,7 +80,17 @@ module CarrierWave
80
80
  next unless self.send(condition, new_file)
81
81
  end
82
82
  end
83
- self.send(method, *args)
83
+
84
+ if args.is_a? Array
85
+ kwargs, args = args.partition { |arg| arg.is_a? Hash }
86
+ end
87
+
88
+ if kwargs.present?
89
+ kwargs = kwargs.reduce(:merge)
90
+ self.send(method, *args, **kwargs)
91
+ else
92
+ self.send(method, *args)
93
+ end
84
94
  end
85
95
  end
86
96
  end
@@ -1,3 +1,3 @@
1
1
  module CarrierWave
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.6"
3
3
  end
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: 2.2.0
4
+ version: 2.2.6
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-23 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
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.1'
69
69
  - !ruby/object:Gem::Dependency
70
- name: mimemagic
70
+ name: marcel
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.3.0
75
+ version: 1.0.0
76
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.3.0
82
+ version: 1.0.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: addressable
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
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'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: webmock
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -199,6 +213,9 @@ dependencies:
199
213
  - - "~>"
200
214
  - !ruby/object:Gem::Version
201
215
  version: '1.7'
216
+ - - "!="
217
+ - !ruby/object:Gem::Version
218
+ version: 1.12.1
202
219
  type: :development
203
220
  prerelease: false
204
221
  version_requirements: !ruby/object:Gem::Requirement
@@ -206,6 +223,9 @@ dependencies:
206
223
  - - "~>"
207
224
  - !ruby/object:Gem::Version
208
225
  version: '1.7'
226
+ - - "!="
227
+ - !ruby/object:Gem::Version
228
+ version: 1.12.1
209
229
  - !ruby/object:Gem::Dependency
210
230
  name: fog-local
211
231
  requirement: !ruby/object:Gem::Requirement
@@ -392,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
392
412
  - !ruby/object:Gem::Version
393
413
  version: '0'
394
414
  requirements: []
395
- rubygems_version: 3.1.2
415
+ rubygems_version: 3.4.10
396
416
  signing_key:
397
417
  specification_version: 4
398
418
  summary: Ruby file upload library