active_storage_validations 1.3.2 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of active_storage_validations might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/active_storage_validations/aspect_ratio_validator.rb +10 -10
- data/lib/active_storage_validations/attached_validator.rb +6 -6
- data/lib/active_storage_validations/base_size_validator.rb +8 -8
- data/lib/active_storage_validations/content_type_spoof_detector.rb +4 -4
- data/lib/active_storage_validations/content_type_validator.rb +32 -22
- data/lib/active_storage_validations/dimension_validator.rb +10 -10
- data/lib/active_storage_validations/limit_validator.rb +8 -8
- data/lib/active_storage_validations/marcel_extensor.rb +2 -0
- data/lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb +14 -14
- data/lib/active_storage_validations/matchers/attached_validator_matcher.rb +12 -12
- data/lib/active_storage_validations/matchers/base_size_validator_matcher.rb +14 -14
- data/lib/active_storage_validations/matchers/content_type_validator_matcher.rb +14 -14
- data/lib/active_storage_validations/matchers/dimension_validator_matcher.rb +14 -14
- data/lib/active_storage_validations/matchers/limit_validator_matcher.rb +14 -14
- data/lib/active_storage_validations/matchers/processable_image_validator_matcher.rb +14 -14
- data/lib/active_storage_validations/matchers/shared/{active_storageable.rb → asv_active_storageable.rb} +4 -2
- data/lib/active_storage_validations/matchers/shared/{allow_blankable.rb → asv_allow_blankable.rb} +4 -2
- data/lib/active_storage_validations/matchers/shared/{attachable.rb → asv_attachable.rb} +7 -1
- data/lib/active_storage_validations/matchers/shared/{contextable.rb → asv_contextable.rb} +4 -2
- data/lib/active_storage_validations/matchers/shared/{messageable.rb → asv_messageable.rb} +4 -2
- data/lib/active_storage_validations/matchers/shared/{rspecable.rb → asv_rspecable.rb} +4 -2
- data/lib/active_storage_validations/matchers/shared/{validatable.rb → asv_validatable.rb} +4 -2
- data/lib/active_storage_validations/metadata.rb +2 -2
- data/lib/active_storage_validations/processable_image_validator.rb +8 -8
- data/lib/active_storage_validations/shared/{active_storageable.rb → asv_active_storageable.rb} +4 -2
- data/lib/active_storage_validations/shared/{attachable.rb → asv_attachable.rb} +4 -2
- data/lib/active_storage_validations/shared/{errorable.rb → asv_errorable.rb} +3 -1
- data/lib/active_storage_validations/shared/{loggable.rb → asv_loggable.rb} +3 -1
- data/lib/active_storage_validations/shared/{optionable.rb → asv_optionable.rb} +4 -2
- data/lib/active_storage_validations/shared/{symbolizable.rb → asv_symbolizable.rb} +3 -1
- data/lib/active_storage_validations/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0539919d5597eda332d4c989c432986009f1944e0ab62251882cc250fa6f021a'
|
4
|
+
data.tar.gz: 8d7566007ede3adf24a60297c20d7a39b28e211bc00f5158148f3c2cdf0a82e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364050c102e1fa3feac404972479edf30eb25d7df969e7593afae838ffe556bb0cb69693c94ad8ced10b056b0d8b5c232800bc3885bdc37984c9cf51a836bff1
|
7
|
+
data.tar.gz: 7350e9ffb7d0c93bc233561ab3457aec477f988c447708498d791f559440a08207cfddf245b2b835716f978d2d8171f4c71252697183df5284ee8f33ce136540
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_attachable'
|
5
|
+
require_relative 'shared/asv_errorable'
|
6
|
+
require_relative 'shared/asv_optionable'
|
7
|
+
require_relative 'shared/asv_symbolizable'
|
8
8
|
|
9
9
|
module ActiveStorageValidations
|
10
10
|
class AspectRatioValidator < ActiveModel::EachValidator # :nodoc
|
11
|
-
include
|
12
|
-
include
|
13
|
-
include
|
14
|
-
include
|
15
|
-
include
|
11
|
+
include ASVActiveStorageable
|
12
|
+
include ASVAttachable
|
13
|
+
include ASVErrorable
|
14
|
+
include ASVOptionable
|
15
|
+
include ASVSymbolizable
|
16
16
|
|
17
17
|
AVAILABLE_CHECKS = %i[with].freeze
|
18
18
|
NAMED_ASPECT_RATIOS = %i[square portrait landscape].freeze
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_errorable'
|
5
|
+
require_relative 'shared/asv_symbolizable'
|
6
6
|
|
7
7
|
module ActiveStorageValidations
|
8
8
|
class AttachedValidator < ActiveModel::EachValidator # :nodoc:
|
9
|
-
include
|
10
|
-
include
|
11
|
-
include
|
9
|
+
include ASVActiveStorageable
|
10
|
+
include ASVErrorable
|
11
|
+
include ASVSymbolizable
|
12
12
|
|
13
13
|
ERROR_TYPES = %i[blank].freeze
|
14
14
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_errorable'
|
5
|
+
require_relative 'shared/asv_optionable'
|
6
|
+
require_relative 'shared/asv_symbolizable'
|
7
7
|
|
8
8
|
module ActiveStorageValidations
|
9
9
|
class BaseSizeValidator < ActiveModel::EachValidator # :nodoc:
|
10
|
-
include
|
11
|
-
include
|
12
|
-
include
|
13
|
-
include
|
10
|
+
include ASVActiveStorageable
|
11
|
+
include ASVErrorable
|
12
|
+
include ASVOptionable
|
13
|
+
include ASVSymbolizable
|
14
14
|
|
15
15
|
delegate :number_to_human_size, to: ActiveSupport::NumberHelper
|
16
16
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_attachable'
|
4
|
+
require_relative 'shared/asv_loggable'
|
5
5
|
require 'open3'
|
6
6
|
|
7
7
|
module ActiveStorageValidations
|
8
8
|
class ContentTypeSpoofDetector
|
9
9
|
class FileCommandLineToolNotInstalledError < StandardError; end
|
10
10
|
|
11
|
-
include
|
12
|
-
include
|
11
|
+
include ASVAttachable
|
12
|
+
include ASVLoggable
|
13
13
|
|
14
14
|
def initialize(record, attribute, attachable)
|
15
15
|
@record = record
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_attachable'
|
5
|
+
require_relative 'shared/asv_errorable'
|
6
|
+
require_relative 'shared/asv_optionable'
|
7
|
+
require_relative 'shared/asv_symbolizable'
|
8
8
|
require_relative 'content_type_spoof_detector'
|
9
9
|
|
10
10
|
module ActiveStorageValidations
|
11
11
|
class ContentTypeValidator < ActiveModel::EachValidator # :nodoc:
|
12
|
-
include
|
13
|
-
include
|
14
|
-
include
|
15
|
-
include
|
16
|
-
include
|
12
|
+
include ASVActiveStorageable
|
13
|
+
include ASVAttachable
|
14
|
+
include ASVErrorable
|
15
|
+
include ASVOptionable
|
16
|
+
include ASVSymbolizable
|
17
17
|
|
18
18
|
AVAILABLE_CHECKS = %i[with in].freeze
|
19
19
|
ERROR_TYPES = %i[
|
@@ -56,22 +56,32 @@ module ActiveStorageValidations
|
|
56
56
|
@attachable_filename = attachable_filename(attachable).to_s
|
57
57
|
end
|
58
58
|
|
59
|
+
# Check if the provided content_type is authorized and not spoofed against
|
60
|
+
# the file io.
|
59
61
|
def is_valid?(record, attribute, attachable)
|
60
|
-
|
61
|
-
authorized_content_type?(record, attribute, attachable) &&
|
62
|
+
authorized_content_type?(record, attribute, attachable) &&
|
62
63
|
not_spoofing_content_type?(record, attribute, attachable)
|
63
64
|
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
# Dead code that we keep here for some time, maybe we will find a solution
|
67
|
+
# to this check later? (November 2024)
|
68
|
+
#
|
69
|
+
# We do not perform any validations against the extension because it is an
|
70
|
+
# unreliable source of truth. For example, a `.csv` file could have its
|
71
|
+
# `text/csv` content_type changed to `application/vnd.ms-excel` because
|
72
|
+
# it had been opened by Excel at some point, making the file extension vs
|
73
|
+
# file content_type check invalid.
|
74
|
+
# def extension_matches_content_type?(record, attribute, attachable)
|
75
|
+
# return true if !@attachable_filename || !@attachable_content_type
|
76
|
+
|
77
|
+
# extension = @attachable_filename.split('.').last
|
78
|
+
# possible_extensions = Marcel::TYPE_EXTS[@attachable_content_type]
|
79
|
+
# return true if possible_extensions && extension.downcase.in?(possible_extensions)
|
80
|
+
|
81
|
+
# errors_options = initialize_and_populate_error_options(options, attachable)
|
82
|
+
# add_error(record, attribute, ERROR_TYPES.first, **errors_options)
|
83
|
+
# false
|
84
|
+
# end
|
75
85
|
|
76
86
|
def authorized_content_type?(record, attribute, attachable)
|
77
87
|
attachable_content_type_is_authorized = @authorized_content_types.any? do |authorized_content_type|
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_attachable'
|
5
|
+
require_relative 'shared/asv_errorable'
|
6
|
+
require_relative 'shared/asv_optionable'
|
7
|
+
require_relative 'shared/asv_symbolizable'
|
8
8
|
|
9
9
|
module ActiveStorageValidations
|
10
10
|
class DimensionValidator < ActiveModel::EachValidator # :nodoc
|
11
|
-
include
|
12
|
-
include
|
13
|
-
include
|
14
|
-
include
|
15
|
-
include
|
11
|
+
include ASVActiveStorageable
|
12
|
+
include ASVAttachable
|
13
|
+
include ASVErrorable
|
14
|
+
include ASVOptionable
|
15
|
+
include ASVSymbolizable
|
16
16
|
|
17
17
|
AVAILABLE_CHECKS = %i[width height min max].freeze
|
18
18
|
ERROR_TYPES = %i[
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_errorable'
|
5
|
+
require_relative 'shared/asv_optionable'
|
6
|
+
require_relative 'shared/asv_symbolizable'
|
7
7
|
|
8
8
|
module ActiveStorageValidations
|
9
9
|
class LimitValidator < ActiveModel::EachValidator # :nodoc:
|
10
|
-
include
|
11
|
-
include
|
12
|
-
include
|
13
|
-
include
|
10
|
+
include ASVActiveStorageable
|
11
|
+
include ASVErrorable
|
12
|
+
include ASVOptionable
|
13
|
+
include ASVSymbolizable
|
14
14
|
|
15
15
|
AVAILABLE_CHECKS = %i[max min].freeze
|
16
16
|
ERROR_TYPES = %i[
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
8
|
-
require_relative 'shared/
|
9
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_allow_blankable'
|
5
|
+
require_relative 'shared/asv_attachable'
|
6
|
+
require_relative 'shared/asv_contextable'
|
7
|
+
require_relative 'shared/asv_messageable'
|
8
|
+
require_relative 'shared/asv_rspecable'
|
9
|
+
require_relative 'shared/asv_validatable'
|
10
10
|
|
11
11
|
module ActiveStorageValidations
|
12
12
|
module Matchers
|
@@ -15,13 +15,13 @@ module ActiveStorageValidations
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class AspectRatioValidatorMatcher
|
18
|
-
include
|
19
|
-
include
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
18
|
+
include ASVActiveStorageable
|
19
|
+
include ASVAllowBlankable
|
20
|
+
include ASVAttachable
|
21
|
+
include ASVContextable
|
22
|
+
include ASVMessageable
|
23
|
+
include ASVRspecable
|
24
|
+
include ASVValidatable
|
25
25
|
|
26
26
|
def initialize(attribute_name)
|
27
27
|
initialize_allow_blankable
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
8
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_attachable'
|
5
|
+
require_relative 'shared/asv_contextable'
|
6
|
+
require_relative 'shared/asv_messageable'
|
7
|
+
require_relative 'shared/asv_rspecable'
|
8
|
+
require_relative 'shared/asv_validatable'
|
9
9
|
|
10
10
|
module ActiveStorageValidations
|
11
11
|
module Matchers
|
@@ -14,12 +14,12 @@ module ActiveStorageValidations
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class AttachedValidatorMatcher
|
17
|
-
include
|
18
|
-
include
|
19
|
-
include
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
17
|
+
include ASVActiveStorageable
|
18
|
+
include ASVAttachable
|
19
|
+
include ASVContextable
|
20
|
+
include ASVMessageable
|
21
|
+
include ASVRspecable
|
22
|
+
include ASVValidatable
|
23
23
|
|
24
24
|
def initialize(attribute_name)
|
25
25
|
initialize_contextable
|
@@ -3,26 +3,26 @@
|
|
3
3
|
# Big thank you to the paperclip validation matchers:
|
4
4
|
# https://github.com/thoughtbot/paperclip/blob/v6.1.0/lib/paperclip/matchers/validate_attachment_size_matcher.rb
|
5
5
|
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
8
|
-
require_relative 'shared/
|
9
|
-
require_relative 'shared/
|
10
|
-
require_relative 'shared/
|
11
|
-
require_relative 'shared/
|
12
|
-
require_relative 'shared/
|
6
|
+
require_relative 'shared/asv_active_storageable'
|
7
|
+
require_relative 'shared/asv_allow_blankable'
|
8
|
+
require_relative 'shared/asv_attachable'
|
9
|
+
require_relative 'shared/asv_contextable'
|
10
|
+
require_relative 'shared/asv_messageable'
|
11
|
+
require_relative 'shared/asv_rspecable'
|
12
|
+
require_relative 'shared/asv_validatable'
|
13
13
|
|
14
14
|
module ActiveStorageValidations
|
15
15
|
module Matchers
|
16
16
|
class BaseSizeValidatorMatcher
|
17
17
|
# BaseSizeValidatorMatcher is an abstract class and shouldn't be instantiated directly.
|
18
18
|
|
19
|
-
include
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
25
|
-
include
|
19
|
+
include ASVActiveStorageable
|
20
|
+
include ASVAllowBlankable
|
21
|
+
include ASVAttachable
|
22
|
+
include ASVContextable
|
23
|
+
include ASVMessageable
|
24
|
+
include ASVRspecable
|
25
|
+
include ASVValidatable
|
26
26
|
|
27
27
|
def initialize(attribute_name)
|
28
28
|
initialize_allow_blankable
|
@@ -3,13 +3,13 @@
|
|
3
3
|
# Big thank you to the paperclip validation matchers:
|
4
4
|
# https://github.com/thoughtbot/paperclip/blob/v6.1.0/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
|
5
5
|
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
8
|
-
require_relative 'shared/
|
9
|
-
require_relative 'shared/
|
10
|
-
require_relative 'shared/
|
11
|
-
require_relative 'shared/
|
12
|
-
require_relative 'shared/
|
6
|
+
require_relative 'shared/asv_active_storageable'
|
7
|
+
require_relative 'shared/asv_allow_blankable'
|
8
|
+
require_relative 'shared/asv_attachable'
|
9
|
+
require_relative 'shared/asv_contextable'
|
10
|
+
require_relative 'shared/asv_messageable'
|
11
|
+
require_relative 'shared/asv_rspecable'
|
12
|
+
require_relative 'shared/asv_validatable'
|
13
13
|
|
14
14
|
module ActiveStorageValidations
|
15
15
|
module Matchers
|
@@ -18,13 +18,13 @@ module ActiveStorageValidations
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class ContentTypeValidatorMatcher
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
25
|
-
include
|
26
|
-
include
|
27
|
-
include
|
21
|
+
include ASVActiveStorageable
|
22
|
+
include ASVAllowBlankable
|
23
|
+
include ASVAttachable
|
24
|
+
include ASVContextable
|
25
|
+
include ASVMessageable
|
26
|
+
include ASVRspecable
|
27
|
+
include ASVValidatable
|
28
28
|
|
29
29
|
def initialize(attribute_name)
|
30
30
|
initialize_allow_blankable
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
8
|
-
require_relative 'shared/
|
9
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_allow_blankable'
|
5
|
+
require_relative 'shared/asv_attachable'
|
6
|
+
require_relative 'shared/asv_contextable'
|
7
|
+
require_relative 'shared/asv_messageable'
|
8
|
+
require_relative 'shared/asv_rspecable'
|
9
|
+
require_relative 'shared/asv_validatable'
|
10
10
|
|
11
11
|
module ActiveStorageValidations
|
12
12
|
module Matchers
|
@@ -15,13 +15,13 @@ module ActiveStorageValidations
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class DimensionValidatorMatcher
|
18
|
-
include
|
19
|
-
include
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
18
|
+
include ASVActiveStorageable
|
19
|
+
include ASVAllowBlankable
|
20
|
+
include ASVAttachable
|
21
|
+
include ASVContextable
|
22
|
+
include ASVMessageable
|
23
|
+
include ASVRspecable
|
24
|
+
include ASVValidatable
|
25
25
|
|
26
26
|
def initialize(attribute_name)
|
27
27
|
initialize_allow_blankable
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
8
|
-
require_relative 'shared/
|
9
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_allow_blankable'
|
5
|
+
require_relative 'shared/asv_attachable'
|
6
|
+
require_relative 'shared/asv_contextable'
|
7
|
+
require_relative 'shared/asv_messageable'
|
8
|
+
require_relative 'shared/asv_rspecable'
|
9
|
+
require_relative 'shared/asv_validatable'
|
10
10
|
|
11
11
|
module ActiveStorageValidations
|
12
12
|
module Matchers
|
@@ -15,13 +15,13 @@ module ActiveStorageValidations
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class LimitValidatorMatcher
|
18
|
-
include
|
19
|
-
include
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
18
|
+
include ASVActiveStorageable
|
19
|
+
include ASVAllowBlankable
|
20
|
+
include ASVAttachable
|
21
|
+
include ASVContextable
|
22
|
+
include ASVMessageable
|
23
|
+
include ASVRspecable
|
24
|
+
include ASVValidatable
|
25
25
|
|
26
26
|
def initialize(attribute_name)
|
27
27
|
initialize_allow_blankable
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
7
|
-
require_relative 'shared/
|
8
|
-
require_relative 'shared/
|
9
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_allow_blankable'
|
5
|
+
require_relative 'shared/asv_attachable'
|
6
|
+
require_relative 'shared/asv_contextable'
|
7
|
+
require_relative 'shared/asv_messageable'
|
8
|
+
require_relative 'shared/asv_rspecable'
|
9
|
+
require_relative 'shared/asv_validatable'
|
10
10
|
|
11
11
|
module ActiveStorageValidations
|
12
12
|
module Matchers
|
@@ -15,13 +15,13 @@ module ActiveStorageValidations
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class ProcessableImageValidatorMatcher
|
18
|
-
include
|
19
|
-
include
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
18
|
+
include ASVActiveStorageable
|
19
|
+
include ASVAllowBlankable
|
20
|
+
include ASVAttachable
|
21
|
+
include ASVContextable
|
22
|
+
include ASVMessageable
|
23
|
+
include ASVRspecable
|
24
|
+
include ASVValidatable
|
25
25
|
|
26
26
|
def initialize(attribute_name)
|
27
27
|
initialize_allow_blankable
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
2
4
|
|
3
5
|
module ActiveStorageValidations
|
4
6
|
module Matchers
|
5
|
-
module
|
7
|
+
module ASVActiveStorageable
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
private
|
data/lib/active_storage_validations/matchers/shared/{allow_blankable.rb → asv_allow_blankable.rb}
RENAMED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
2
4
|
|
3
5
|
module ActiveStorageValidations
|
4
6
|
module Matchers
|
5
|
-
module
|
7
|
+
module ASVAllowBlankable
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
def initialize_allow_blankable
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
2
4
|
|
3
5
|
module ActiveStorageValidations
|
4
6
|
module Matchers
|
5
|
-
module
|
7
|
+
module ASVContextable
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
def initialize_contextable
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
2
4
|
|
3
5
|
module ActiveStorageValidations
|
4
6
|
module Matchers
|
5
|
-
module
|
7
|
+
module ASVMessageable
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
def initialize_messageable
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
2
4
|
|
3
5
|
module ActiveStorageValidations
|
4
6
|
module Matchers
|
5
|
-
module
|
7
|
+
module ASVRspecable
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
def initialize_rspecable
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_loggable'
|
4
4
|
|
5
5
|
module ActiveStorageValidations
|
6
6
|
class Metadata
|
7
|
-
include
|
7
|
+
include ASVLoggable
|
8
8
|
|
9
9
|
class InvalidImageError < StandardError; end
|
10
10
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'shared/
|
4
|
-
require_relative 'shared/
|
5
|
-
require_relative 'shared/
|
6
|
-
require_relative 'shared/
|
3
|
+
require_relative 'shared/asv_active_storageable'
|
4
|
+
require_relative 'shared/asv_attachable'
|
5
|
+
require_relative 'shared/asv_errorable'
|
6
|
+
require_relative 'shared/asv_symbolizable'
|
7
7
|
|
8
8
|
module ActiveStorageValidations
|
9
9
|
class ProcessableImageValidator < ActiveModel::EachValidator # :nodoc
|
10
|
-
include
|
11
|
-
include
|
12
|
-
include
|
13
|
-
include
|
10
|
+
include ASVActiveStorageable
|
11
|
+
include ASVAttachable
|
12
|
+
include ASVErrorable
|
13
|
+
include ASVSymbolizable
|
14
14
|
|
15
15
|
ERROR_TYPES = %i[
|
16
16
|
image_not_processable
|
data/lib/active_storage_validations/shared/{active_storageable.rb → asv_active_storageable.rb}
RENAMED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveStorageValidations
|
2
|
-
# ActiveStorageValidations::
|
4
|
+
# ActiveStorageValidations::ASVActiveStorageable
|
3
5
|
#
|
4
6
|
# Validator helper methods to make our code more explicit.
|
5
|
-
module
|
7
|
+
module ASVActiveStorageable
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
private
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../metadata"
|
2
4
|
|
3
5
|
module ActiveStorageValidations
|
4
|
-
# ActiveStorageValidations::
|
6
|
+
# ActiveStorageValidations::ASVAttachable
|
5
7
|
#
|
6
8
|
# Validator methods for analyzing attachable.
|
7
9
|
#
|
8
10
|
# An attachable is a file representation such as ActiveStorage::Blob,
|
9
11
|
# ActionDispatch::Http::UploadedFile, Rack::Test::UploadedFile, Hash, String,
|
10
12
|
# File or Pathname
|
11
|
-
module
|
13
|
+
module ASVAttachable
|
12
14
|
extend ActiveSupport::Concern
|
13
15
|
|
14
16
|
private
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveStorageValidations
|
2
|
-
# ActiveStorageValidations::
|
4
|
+
# ActiveStorageValidations::ASVOptionable
|
3
5
|
#
|
4
6
|
# Helper method to flatten the validator options.
|
5
|
-
module
|
7
|
+
module ASVOptionable
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
private
|
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: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -276,24 +276,24 @@ files:
|
|
276
276
|
- lib/active_storage_validations/matchers/dimension_validator_matcher.rb
|
277
277
|
- lib/active_storage_validations/matchers/limit_validator_matcher.rb
|
278
278
|
- lib/active_storage_validations/matchers/processable_image_validator_matcher.rb
|
279
|
-
- lib/active_storage_validations/matchers/shared/
|
280
|
-
- lib/active_storage_validations/matchers/shared/
|
281
|
-
- lib/active_storage_validations/matchers/shared/
|
282
|
-
- lib/active_storage_validations/matchers/shared/
|
283
|
-
- lib/active_storage_validations/matchers/shared/
|
284
|
-
- lib/active_storage_validations/matchers/shared/
|
285
|
-
- lib/active_storage_validations/matchers/shared/
|
279
|
+
- lib/active_storage_validations/matchers/shared/asv_active_storageable.rb
|
280
|
+
- lib/active_storage_validations/matchers/shared/asv_allow_blankable.rb
|
281
|
+
- lib/active_storage_validations/matchers/shared/asv_attachable.rb
|
282
|
+
- lib/active_storage_validations/matchers/shared/asv_contextable.rb
|
283
|
+
- lib/active_storage_validations/matchers/shared/asv_messageable.rb
|
284
|
+
- lib/active_storage_validations/matchers/shared/asv_rspecable.rb
|
285
|
+
- lib/active_storage_validations/matchers/shared/asv_validatable.rb
|
286
286
|
- lib/active_storage_validations/matchers/size_validator_matcher.rb
|
287
287
|
- lib/active_storage_validations/matchers/total_size_validator_matcher.rb
|
288
288
|
- lib/active_storage_validations/metadata.rb
|
289
289
|
- lib/active_storage_validations/processable_image_validator.rb
|
290
290
|
- lib/active_storage_validations/railtie.rb
|
291
|
-
- lib/active_storage_validations/shared/
|
292
|
-
- lib/active_storage_validations/shared/
|
293
|
-
- lib/active_storage_validations/shared/
|
294
|
-
- lib/active_storage_validations/shared/
|
295
|
-
- lib/active_storage_validations/shared/
|
296
|
-
- lib/active_storage_validations/shared/
|
291
|
+
- lib/active_storage_validations/shared/asv_active_storageable.rb
|
292
|
+
- lib/active_storage_validations/shared/asv_attachable.rb
|
293
|
+
- lib/active_storage_validations/shared/asv_errorable.rb
|
294
|
+
- lib/active_storage_validations/shared/asv_loggable.rb
|
295
|
+
- lib/active_storage_validations/shared/asv_optionable.rb
|
296
|
+
- lib/active_storage_validations/shared/asv_symbolizable.rb
|
297
297
|
- lib/active_storage_validations/size_validator.rb
|
298
298
|
- lib/active_storage_validations/total_size_validator.rb
|
299
299
|
- lib/active_storage_validations/version.rb
|