active_storage_validations 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcd9bfe3dafea8c00d688ab4816cf69c9848455a8d94fa5a4727fcd2f8e707e1
4
- data.tar.gz: 623d46eb1b8eeb8e835496f174ce4dda01dee9df2e21b2d2033c6db8f387dd17
3
+ metadata.gz: 77abbd375626f37f0ecae9dc8710249bde59202cb71ea2e925b5c2f026afd025
4
+ data.tar.gz: 5d694245be38c6f3ea7f3e1d157974e9bd5e63a67be276e25fccde072e48a52e
5
5
  SHA512:
6
- metadata.gz: f22a2f92007a66c55d5a72d2c8158b95e88d1237650dd5e094a7362d36eabf35e0201d6e5ee4a5f3c896fdff21b601e5a9d5fbedc0d328b375d45fe81cf01d81
7
- data.tar.gz: 85568d6d041a7a367f14f841e1617c5ac11b97de7ad3df72a8f1c90b3364077a2dcdbfd5e501ba77fe132bc4810a276307e3b6f5413427ffced46fad963d3d0f
6
+ metadata.gz: c7e1a56bf9eb906d7bb5c05c2d89d901bbe93ca63ed86423276edb1eb22078f35dd70b40c997c9b0ed7e53df7364c8ed264ca627cf415bf74b8054e1a9d19f00
7
+ data.tar.gz: 024c5f428d64ed7462e395cea6add2c121b393ccd7d89992a0304fe44e97cdba6eb99b9b5b6ace0a4a199e759d31e08dd2eb1427c3aee4acfa6f624fe8238027
data/README.md CHANGED
@@ -243,10 +243,13 @@ end
243
243
  #### Content type shorthands
244
244
 
245
245
  If you choose to use a content_type 'shorthand' (like `png`), note that it will be converted to a full content type using `Marcel::MimeType.for` under the hood. Therefore, you should check if the content_type is registered by [`Marcel::EXTENSIONS`](https://github.com/rails/marcel/blob/main/lib/marcel/tables.rb). If it's not, you can register it by adding the following code to your `config/initializers/mime_types.rb` file:
246
+
246
247
  ```ruby
247
248
  Marcel::MimeType.extend "application/ino", extensions: %w(ino), parents: "text/plain" # Registering arduino INO files
248
249
  ```
249
250
 
251
+ Be sure to at least include one the the `extensions`, `parents` or `magic` option, otherwise the content type will not be registered.
252
+
250
253
  #### Content type spoofing protection
251
254
 
252
255
  By default, the gem does not prevent content type spoofing. You can enable it by setting the `spoofing_protection` option to `true` in your validator options.
@@ -215,12 +215,14 @@ module ActiveStorageValidations
215
215
  raise ArgumentError, "'image/jpg' is not a valid content type, you should use 'image/jpeg' instead"
216
216
  end
217
217
 
218
- all_available_marcel_content_types.keys.exclude?(content_type.to_s)
218
+ all_available_marcel_content_types.exclude?(content_type.to_s)
219
219
  end
220
220
 
221
221
  def all_available_marcel_content_types
222
- @all_available_marcel_content_types ||= Marcel::MAGIC.map {|dd| dd.first }
223
- .each_with_object(Marcel::TYPE_EXTS) { |(k,v), h| h[k] = v unless h.key?(k) }
222
+ @all_available_marcel_content_types ||= Marcel::TYPE_EXTS
223
+ .keys
224
+ .push(*Marcel::MAGIC.map(&:first))
225
+ .tap(&:uniq!)
224
226
  end
225
227
 
226
228
  def invalid_extension?(content_type)
@@ -2,6 +2,12 @@
2
2
 
3
3
  module ActiveStorageValidations
4
4
  class Railtie < ::Rails::Railtie
5
+ initializer 'active_storage_validations.configure', after: :load_config_initializers do
6
+ ActiveSupport.on_load(:active_record) do
7
+ send :include, ActiveStorageValidations
8
+ end
9
+ end
10
+
5
11
  initializer 'active_storage_validations.extend_active_storage_blob' do
6
12
  ActiveSupport.on_load(:active_storage_blob) do
7
13
  include(ActiveStorageValidations::ASVBlobMetadatable)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveStorageValidations
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  end
@@ -14,8 +14,6 @@ require 'active_storage_validations/analyzer/audio_analyzer'
14
14
  require 'active_storage_validations/extensors/asv_blob_metadatable'
15
15
  require 'active_storage_validations/extensors/asv_marcelable'
16
16
 
17
- require 'active_storage_validations/railtie'
18
- require 'active_storage_validations/engine'
19
17
  require 'active_storage_validations/attached_validator'
20
18
  require 'active_storage_validations/content_type_validator'
21
19
  require 'active_storage_validations/limit_validator'
@@ -26,6 +24,5 @@ require 'active_storage_validations/processable_file_validator'
26
24
  require 'active_storage_validations/size_validator'
27
25
  require 'active_storage_validations/total_size_validator'
28
26
 
29
- ActiveSupport.on_load(:active_record) do
30
- send :include, ActiveStorageValidations
31
- end
27
+ require 'active_storage_validations/engine'
28
+ require 'active_storage_validations/railtie'
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: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-28 00:00:00.000000000 Z
11
+ date: 2025-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob