active_storage_validations 1.3.0 → 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.

Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -8
  3. data/config/locales/da.yml +0 -1
  4. data/config/locales/de.yml +0 -1
  5. data/config/locales/en.yml +0 -1
  6. data/config/locales/es.yml +0 -1
  7. data/config/locales/fr.yml +0 -1
  8. data/config/locales/it.yml +0 -1
  9. data/config/locales/ja.yml +0 -1
  10. data/config/locales/nl.yml +0 -1
  11. data/config/locales/pl.yml +0 -1
  12. data/config/locales/pt-BR.yml +0 -1
  13. data/config/locales/ru.yml +0 -1
  14. data/config/locales/sv.yml +0 -1
  15. data/config/locales/tr.yml +0 -1
  16. data/config/locales/uk.yml +0 -1
  17. data/config/locales/vi.yml +0 -1
  18. data/config/locales/zh-CN.yml +0 -1
  19. data/lib/active_storage_validations/aspect_ratio_validator.rb +61 -46
  20. data/lib/active_storage_validations/attached_validator.rb +6 -6
  21. data/lib/active_storage_validations/base_size_validator.rb +8 -7
  22. data/lib/active_storage_validations/content_type_spoof_detector.rb +13 -49
  23. data/lib/active_storage_validations/content_type_validator.rb +112 -54
  24. data/lib/active_storage_validations/dimension_validator.rb +11 -10
  25. data/lib/active_storage_validations/limit_validator.rb +9 -8
  26. data/lib/active_storage_validations/marcel_extensor.rb +2 -0
  27. data/lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb +14 -14
  28. data/lib/active_storage_validations/matchers/attached_validator_matcher.rb +12 -12
  29. data/lib/active_storage_validations/matchers/base_size_validator_matcher.rb +14 -14
  30. data/lib/active_storage_validations/matchers/content_type_validator_matcher.rb +40 -40
  31. data/lib/active_storage_validations/matchers/dimension_validator_matcher.rb +14 -14
  32. data/lib/active_storage_validations/matchers/limit_validator_matcher.rb +14 -14
  33. data/lib/active_storage_validations/matchers/processable_image_validator_matcher.rb +14 -14
  34. data/lib/active_storage_validations/matchers/{concerns/active_storageable.rb → shared/asv_active_storageable.rb} +4 -2
  35. data/lib/active_storage_validations/matchers/{concerns/allow_blankable.rb → shared/asv_allow_blankable.rb} +4 -2
  36. data/lib/active_storage_validations/matchers/{concerns/attachable.rb → shared/asv_attachable.rb} +7 -1
  37. data/lib/active_storage_validations/matchers/{concerns/contextable.rb → shared/asv_contextable.rb} +4 -2
  38. data/lib/active_storage_validations/matchers/{concerns/messageable.rb → shared/asv_messageable.rb} +4 -2
  39. data/lib/active_storage_validations/matchers/{concerns/rspecable.rb → shared/asv_rspecable.rb} +4 -2
  40. data/lib/active_storage_validations/matchers/{concerns/validatable.rb → shared/asv_validatable.rb} +4 -2
  41. data/lib/active_storage_validations/metadata.rb +18 -19
  42. data/lib/active_storage_validations/processable_image_validator.rb +8 -8
  43. data/lib/active_storage_validations/{concerns/active_storageable.rb → shared/asv_active_storageable.rb} +4 -2
  44. data/lib/active_storage_validations/shared/asv_attachable.rb +136 -0
  45. data/lib/active_storage_validations/{concerns/errorable.rb → shared/asv_errorable.rb} +5 -2
  46. data/lib/active_storage_validations/{concerns/loggable.rb → shared/asv_loggable.rb} +3 -1
  47. data/lib/active_storage_validations/shared/asv_optionable.rb +29 -0
  48. data/lib/active_storage_validations/{concerns/symbolizable.rb → shared/asv_symbolizable.rb} +3 -1
  49. data/lib/active_storage_validations/size_validator.rb +2 -2
  50. data/lib/active_storage_validations/total_size_validator.rb +2 -2
  51. data/lib/active_storage_validations/version.rb +1 -1
  52. data/lib/active_storage_validations.rb +0 -1
  53. metadata +65 -25
  54. data/lib/active_storage_validations/concerns/metadatable.rb +0 -31
  55. data/lib/active_storage_validations/option_proc_unfolding.rb +0 -16
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.0
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-10-20 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 6.1.4
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.3
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.3
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: combustion
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -81,47 +95,73 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '1.3'
83
97
  - !ruby/object:Gem::Dependency
84
- name: marcel
98
+ name: mini_magick
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: 1.0.3
103
+ version: 4.9.5
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: 1.0.3
110
+ version: 4.9.5
97
111
  - !ruby/object:Gem::Dependency
98
- name: mini_magick
112
+ name: minitest-focus
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: minitest-mock_expectations
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.2'
101
132
  - - ">="
102
133
  - !ruby/object:Gem::Version
103
- version: 4.9.5
134
+ version: 1.2.0
104
135
  type: :development
105
136
  prerelease: false
106
137
  version_requirements: !ruby/object:Gem::Requirement
107
138
  requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '1.2'
108
142
  - - ">="
109
143
  - !ruby/object:Gem::Version
110
- version: 4.9.5
144
+ version: 1.2.0
111
145
  - !ruby/object:Gem::Dependency
112
- name: minitest-focus
146
+ name: minitest-stub_any_instance
113
147
  requirement: !ruby/object:Gem::Requirement
114
148
  requirements:
115
149
  - - "~>"
116
150
  - !ruby/object:Gem::Version
117
- version: '1.4'
151
+ version: '1.0'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 1.0.3
118
155
  type: :development
119
156
  prerelease: false
120
157
  version_requirements: !ruby/object:Gem::Requirement
121
158
  requirements:
122
159
  - - "~>"
123
160
  - !ruby/object:Gem::Version
124
- version: '1.4'
161
+ version: '1.0'
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: 1.0.3
125
165
  - !ruby/object:Gem::Dependency
126
166
  name: pry
127
167
  requirement: !ruby/object:Gem::Requirement
@@ -222,11 +262,6 @@ files:
222
262
  - lib/active_storage_validations/aspect_ratio_validator.rb
223
263
  - lib/active_storage_validations/attached_validator.rb
224
264
  - lib/active_storage_validations/base_size_validator.rb
225
- - lib/active_storage_validations/concerns/active_storageable.rb
226
- - lib/active_storage_validations/concerns/errorable.rb
227
- - lib/active_storage_validations/concerns/loggable.rb
228
- - lib/active_storage_validations/concerns/metadatable.rb
229
- - lib/active_storage_validations/concerns/symbolizable.rb
230
265
  - lib/active_storage_validations/content_type_spoof_detector.rb
231
266
  - lib/active_storage_validations/content_type_validator.rb
232
267
  - lib/active_storage_validations/dimension_validator.rb
@@ -237,23 +272,28 @@ files:
237
272
  - lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb
238
273
  - lib/active_storage_validations/matchers/attached_validator_matcher.rb
239
274
  - lib/active_storage_validations/matchers/base_size_validator_matcher.rb
240
- - lib/active_storage_validations/matchers/concerns/active_storageable.rb
241
- - lib/active_storage_validations/matchers/concerns/allow_blankable.rb
242
- - lib/active_storage_validations/matchers/concerns/attachable.rb
243
- - lib/active_storage_validations/matchers/concerns/contextable.rb
244
- - lib/active_storage_validations/matchers/concerns/messageable.rb
245
- - lib/active_storage_validations/matchers/concerns/rspecable.rb
246
- - lib/active_storage_validations/matchers/concerns/validatable.rb
247
275
  - lib/active_storage_validations/matchers/content_type_validator_matcher.rb
248
276
  - lib/active_storage_validations/matchers/dimension_validator_matcher.rb
249
277
  - lib/active_storage_validations/matchers/limit_validator_matcher.rb
250
278
  - lib/active_storage_validations/matchers/processable_image_validator_matcher.rb
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
251
286
  - lib/active_storage_validations/matchers/size_validator_matcher.rb
252
287
  - lib/active_storage_validations/matchers/total_size_validator_matcher.rb
253
288
  - lib/active_storage_validations/metadata.rb
254
- - lib/active_storage_validations/option_proc_unfolding.rb
255
289
  - lib/active_storage_validations/processable_image_validator.rb
256
290
  - lib/active_storage_validations/railtie.rb
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
257
297
  - lib/active_storage_validations/size_validator.rb
258
298
  - lib/active_storage_validations/total_size_validator.rb
259
299
  - lib/active_storage_validations/version.rb
@@ -278,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
318
  - !ruby/object:Gem::Version
279
319
  version: '0'
280
320
  requirements: []
281
- rubygems_version: 3.5.11
321
+ rubygems_version: 3.5.16
282
322
  signing_key:
283
323
  specification_version: 4
284
324
  summary: Validations for Active Storage
@@ -1,31 +0,0 @@
1
- require_relative '../metadata'
2
-
3
- module ActiveStorageValidations
4
- # ActiveStorageValidations::Metadatable
5
- #
6
- # Validator methods for analyzing the attachment metadata.
7
- module Metadatable
8
- extend ActiveSupport::Concern
9
-
10
- private
11
-
12
- # Loop through the newly submitted attachables to validate them
13
- def validate_changed_files_from_metadata(record, attribute)
14
- attachables_from_changes(record, attribute).each do |attachable|
15
- is_valid?(record, attribute, attachable, Metadata.new(attachable).metadata)
16
- end
17
- end
18
-
19
- # Retrieve an array of newly submitted attachables which are file
20
- # representations such as ActiveStorage::Blob, ActionDispatch::Http::UploadedFile,
21
- # Rack::Test::UploadedFile, Hash, String, File or Pathname
22
- def attachables_from_changes(record, attribute)
23
- changes = record.attachment_changes[attribute.to_s]
24
- return [] if changes.blank?
25
-
26
- Array.wrap(
27
- changes.is_a?(ActiveStorage::Attached::Changes::CreateMany) ? changes.attachables : changes.attachable
28
- )
29
- end
30
- end
31
- end
@@ -1,16 +0,0 @@
1
- module ActiveStorageValidations
2
- module OptionProcUnfolding
3
-
4
- def unfold_procs(record, object, only_keys)
5
- case object
6
- when Hash
7
- object.merge(object) { |key, value| only_keys&.exclude?(key) ? {} : unfold_procs(record, value, nil) }
8
- when Array
9
- object.map { |o| unfold_procs(record, o, only_keys) }
10
- else
11
- object.is_a?(Proc) ? object.call(record) : object
12
- end
13
- end
14
-
15
- end
16
- end