active_storage_validations 0.9.4 → 0.9.5

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: 58ef7bbaa01aafa835921f0ad446b86e5b5c49a73a6f08e42feb97ff9bd3c7fd
4
- data.tar.gz: e4f18d0de97ffa2adfe59e2d5d841706a8de3e6e575390aafb5b75dbf82a37a2
3
+ metadata.gz: efa69aeeea1b171286c6ca464e38146dedef79d22853c35ec6ea0ce0ca089812
4
+ data.tar.gz: e186561942afb6b295839565323d0bbed704de9e413b79ecc1fb194ada643ca5
5
5
  SHA512:
6
- metadata.gz: 5b29620eb2a65e73c9f7c1c9d2bf143ba20aed0e460fdd763d415651b80463821f5dea26d2b28834dae7dc90ad035d6bbaa47bc7e89161365bfb154485a12c8b
7
- data.tar.gz: ee7ef332175aca338df8d46de13ac0487f1aa4b5a3d7aa220bd14826b0f73f55377a6475c2b2eb9133d06aae456a2d18bdc4fbec07b7caaf9cd9fa3b8f1dcf5b
6
+ metadata.gz: c31ec657e1121427f19d7617d5efbeab639c6ebd87c0333c36510064e7b4d8125ffd8e4f5afa86121e626dd608d2ad1b859a3515c8bc7683e0793291a30c7fd2
7
+ data.tar.gz: 3141abc08b6b33d90f9874a74e93f6aaddb0ebbd52bdd36ee292a1e0ff7d37cf65a8ced082d316f48cc8e0132320c4f83304d9823971906526096264129c0145
data/README.md CHANGED
@@ -58,14 +58,14 @@ end
58
58
 
59
59
  ### More examples
60
60
 
61
- - Content type validation using symbols. In order to infer the correct mime type from the symbol, the types must be registered with `Mime::Type`.
61
+ - Content type validation using symbols. In order to infer the correct mime type from the symbol, the types must be registered with `MimeMagic::EXTENSIONS`.
62
62
 
63
63
  ```ruby
64
64
  class User < ApplicationRecord
65
65
  has_one_attached :avatar
66
66
  has_many_attached :photos
67
67
 
68
- validates :avatar, attached: true, content_type: :png # Mime[:png].to_s => 'image/png'
68
+ validates :avatar, attached: true, content_type: :png # MimeMagic.by_extension(:png).to_s => 'image/png'
69
69
  # or
70
70
  validates :photos, attached: true, content_type: [:png, :jpg, :jpeg]
71
71
  # or
@@ -343,6 +343,7 @@ You are welcome to contribute.
343
343
  - https://github.com/dolarsrg
344
344
  - https://github.com/jayshepherd
345
345
  - https://github.com/ohbarye
346
+ - https://github.com/randsina
346
347
  - https://github.com/...
347
348
 
348
349
  ## License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -20,14 +20,13 @@ module ActiveStorageValidations
20
20
  end
21
21
 
22
22
  def types
23
- (Array.wrap(options[:with]) + Array.wrap(options[:in])).compact.map do |type|
23
+ return @types if defined? @types
24
+
25
+ @types = (Array.wrap(options[:with]) + Array.wrap(options[:in])).compact.map do |type|
24
26
  if type.is_a?(Regexp)
25
27
  type
26
- elsif type.is_a?(String) && type =~ %r{\A\w+/[-+.\w]+\z} # mime-type-ish string
27
- type
28
28
  else
29
- Mime[type] || raise(ArgumentError, "content_type must be one of Regxep,"\
30
- " supported mime types (e.g. :png, 'jpg'), or mime type String ('image/jpeg')")
29
+ Marcel::MimeType.for(declared_type: type.to_s, extension: type.to_s)
31
30
  end
32
31
  end
33
32
  end
File without changes
@@ -57,7 +57,7 @@ module ActiveStorageValidations
57
57
  end
58
58
 
59
59
  def rejected_types
60
- @rejected_types || (Mime::LOOKUP.keys - allowed_types)
60
+ @rejected_types || (Marcel::TYPES.keys - allowed_types)
61
61
  end
62
62
 
63
63
  def allowed_types_allowed?
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveStorageValidations
4
- VERSION = '0.9.4'
4
+ VERSION = '0.9.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails