active_storage_validations 1.2.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -22
  3. data/config/locales/da.yml +1 -2
  4. data/config/locales/de.yml +1 -1
  5. data/config/locales/en.yml +1 -1
  6. data/config/locales/es.yml +1 -1
  7. data/config/locales/fr.yml +1 -1
  8. data/config/locales/it.yml +1 -1
  9. data/config/locales/ja.yml +1 -1
  10. data/config/locales/nl.yml +1 -1
  11. data/config/locales/pl.yml +1 -1
  12. data/config/locales/pt-BR.yml +1 -1
  13. data/config/locales/ru.yml +1 -1
  14. data/config/locales/sv.yml +1 -1
  15. data/config/locales/tr.yml +1 -1
  16. data/config/locales/uk.yml +1 -1
  17. data/config/locales/vi.yml +1 -1
  18. data/config/locales/zh-CN.yml +1 -1
  19. data/lib/active_storage_validations/aspect_ratio_validator.rb +57 -66
  20. data/lib/active_storage_validations/attached_validator.rb +5 -3
  21. data/lib/active_storage_validations/base_size_validator.rb +4 -1
  22. data/lib/active_storage_validations/concerns/active_storageable.rb +28 -0
  23. data/lib/active_storage_validations/concerns/attachable.rb +134 -0
  24. data/lib/active_storage_validations/concerns/errorable.rb +4 -4
  25. data/lib/active_storage_validations/concerns/loggable.rb +9 -0
  26. data/lib/active_storage_validations/concerns/optionable.rb +27 -0
  27. data/lib/active_storage_validations/content_type_spoof_detector.rb +94 -0
  28. data/lib/active_storage_validations/content_type_validator.rb +113 -39
  29. data/lib/active_storage_validations/dimension_validator.rb +32 -52
  30. data/lib/active_storage_validations/limit_validator.rb +8 -5
  31. data/lib/active_storage_validations/marcel_extensor.rb +5 -0
  32. data/lib/active_storage_validations/matchers/concerns/attachable.rb +27 -9
  33. data/lib/active_storage_validations/matchers/concerns/messageable.rb +1 -1
  34. data/lib/active_storage_validations/matchers/content_type_validator_matcher.rb +7 -0
  35. data/lib/active_storage_validations/matchers/limit_validator_matcher.rb +127 -0
  36. data/lib/active_storage_validations/matchers/total_size_validator_matcher.rb +1 -10
  37. data/lib/active_storage_validations/matchers.rb +4 -15
  38. data/lib/active_storage_validations/metadata.rb +22 -26
  39. data/lib/active_storage_validations/processable_image_validator.rb +17 -32
  40. data/lib/active_storage_validations/size_validator.rb +3 -7
  41. data/lib/active_storage_validations/total_size_validator.rb +4 -8
  42. data/lib/active_storage_validations/version.rb +1 -1
  43. data/lib/active_storage_validations.rb +2 -1
  44. metadata +67 -21
  45. 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.2.0
4
+ version: 1.3.1
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-09-23 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -16,56 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
19
+ version: 6.1.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.0
26
+ version: 6.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 5.2.0
33
+ version: 6.1.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 5.2.0
40
+ version: 6.1.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activestorage
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 5.2.0
47
+ version: 6.1.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 5.2.0
54
+ version: 6.1.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 5.2.0
61
+ version: 6.1.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 5.2.0
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: '0'
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: '0'
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,12 +262,18 @@ 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
265
+ - lib/active_storage_validations/concerns/active_storageable.rb
266
+ - lib/active_storage_validations/concerns/attachable.rb
225
267
  - lib/active_storage_validations/concerns/errorable.rb
268
+ - lib/active_storage_validations/concerns/loggable.rb
269
+ - lib/active_storage_validations/concerns/optionable.rb
226
270
  - lib/active_storage_validations/concerns/symbolizable.rb
271
+ - lib/active_storage_validations/content_type_spoof_detector.rb
227
272
  - lib/active_storage_validations/content_type_validator.rb
228
273
  - lib/active_storage_validations/dimension_validator.rb
229
274
  - lib/active_storage_validations/engine.rb
230
275
  - lib/active_storage_validations/limit_validator.rb
276
+ - lib/active_storage_validations/marcel_extensor.rb
231
277
  - lib/active_storage_validations/matchers.rb
232
278
  - lib/active_storage_validations/matchers/aspect_ratio_validator_matcher.rb
233
279
  - lib/active_storage_validations/matchers/attached_validator_matcher.rb
@@ -241,11 +287,11 @@ files:
241
287
  - lib/active_storage_validations/matchers/concerns/validatable.rb
242
288
  - lib/active_storage_validations/matchers/content_type_validator_matcher.rb
243
289
  - lib/active_storage_validations/matchers/dimension_validator_matcher.rb
290
+ - lib/active_storage_validations/matchers/limit_validator_matcher.rb
244
291
  - lib/active_storage_validations/matchers/processable_image_validator_matcher.rb
245
292
  - lib/active_storage_validations/matchers/size_validator_matcher.rb
246
293
  - lib/active_storage_validations/matchers/total_size_validator_matcher.rb
247
294
  - lib/active_storage_validations/metadata.rb
248
- - lib/active_storage_validations/option_proc_unfolding.rb
249
295
  - lib/active_storage_validations/processable_image_validator.rb
250
296
  - lib/active_storage_validations/railtie.rb
251
297
  - lib/active_storage_validations/size_validator.rb
@@ -272,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
318
  - !ruby/object:Gem::Version
273
319
  version: '0'
274
320
  requirements: []
275
- rubygems_version: 3.5.11
321
+ rubygems_version: 3.5.16
276
322
  signing_key:
277
323
  specification_version: 4
278
324
  summary: Validations for Active Storage
@@ -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