schemacop 2.4.0 → 2.4.1
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/doc/Schemacop.html +1 -1
- data/doc/Schemacop/ArrayValidator.html +1 -1
- data/doc/Schemacop/BooleanValidator.html +1 -1
- data/doc/Schemacop/Caster.html +2 -2
- data/doc/Schemacop/Collector.html +1 -1
- data/doc/Schemacop/Exceptions.html +1 -1
- data/doc/Schemacop/Exceptions/InvalidSchemaError.html +1 -1
- data/doc/Schemacop/Exceptions/ValidationError.html +1 -1
- data/doc/Schemacop/FieldNode.html +1 -1
- data/doc/Schemacop/FloatValidator.html +1 -1
- data/doc/Schemacop/HashValidator.html +1 -1
- data/doc/Schemacop/IntegerValidator.html +1 -1
- data/doc/Schemacop/NilValidator.html +1 -1
- data/doc/Schemacop/Node.html +1 -1
- data/doc/Schemacop/NodeResolver.html +3 -3
- data/doc/Schemacop/NodeSupportingField.html +1 -1
- data/doc/Schemacop/NodeSupportingType.html +1 -1
- data/doc/Schemacop/NodeWithBlock.html +1 -1
- data/doc/Schemacop/NumberValidator.html +1 -1
- data/doc/Schemacop/ObjectValidator.html +1 -1
- data/doc/Schemacop/RootNode.html +1 -1
- data/doc/Schemacop/Schema.html +1 -1
- data/doc/Schemacop/StringValidator.html +1 -1
- data/doc/Schemacop/SymbolValidator.html +1 -1
- data/doc/ScopedEnv.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/schemacop/caster.rb +1 -1
- data/lib/schemacop/field_node.rb +4 -5
- data/lib/schemacop/node_resolver.rb +2 -2
- data/lib/schemacop/node_supporting_type.rb +11 -13
- data/schemacop.gemspec +2 -2
- data/test/casting_test.rb +1 -1
- data/test/defaults_test.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecc0bb69ecb7c86b6c507928ff2568a3fc0e5a5927d414eaf34a3817accbcd1b
|
|
4
|
+
data.tar.gz: fbe0e82379f5f330b60a71717ebcefa4bd1280c59a61e7de8e4ccfad137852c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c6406092916323732d4b99972bd77e5ab87b6cc45331dce34d72f0f666bdb6a526b35df900a393bf0c2e6164771f91509c42d97b29a7f0a9f60d75b0ca1a25b9
|
|
7
|
+
data.tar.gz: f30be0a5a40a75812b8f75a2d298019bbd99022479261365210933b1038768512da1f03925d930e9fe80696a104da98c5f826e83b7fad2140cb4b0781b9d201d
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.4.
|
|
1
|
+
2.4.1
|
data/doc/Schemacop.html
CHANGED
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
</div>
|
|
137
137
|
|
|
138
138
|
<div id="footer">
|
|
139
|
-
Generated on Mon Oct 28 16:
|
|
139
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
140
140
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
141
141
|
0.9.20 (ruby-2.6.2).
|
|
142
142
|
</div>
|
|
@@ -319,7 +319,7 @@
|
|
|
319
319
|
</div>
|
|
320
320
|
|
|
321
321
|
<div id="footer">
|
|
322
|
-
Generated on Mon Oct 28 16:
|
|
322
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
323
323
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
324
324
|
0.9.20 (ruby-2.6.2).
|
|
325
325
|
</div>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
</div>
|
|
136
136
|
|
|
137
137
|
<div id="footer">
|
|
138
|
-
Generated on Mon Oct 28 16:
|
|
138
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
140
140
|
0.9.20 (ruby-2.6.2).
|
|
141
141
|
</div>
|
data/doc/Schemacop/Caster.html
CHANGED
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
<span class='kw'>elsif</span> <span class='id identifier rubyid_casts'>casts</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
|
|
252
252
|
<span class='id identifier rubyid_from_types'>from_types</span> <span class='op'>=</span> <span class='id identifier rubyid_casts'>casts</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
|
|
253
253
|
<span class='kw'>else</span>
|
|
254
|
-
<span class='id identifier rubyid_fail'>fail</span> <span class='const'><span class='object_link'><a href="Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Exceptions/InvalidSchemaError.html" title="Schemacop::Exceptions::InvalidSchemaError (class)">InvalidSchemaError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'
|
|
254
|
+
<span class='id identifier rubyid_fail'>fail</span> <span class='const'><span class='object_link'><a href="Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Exceptions/InvalidSchemaError.html" title="Schemacop::Exceptions::InvalidSchemaError (class)">InvalidSchemaError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Option `cast` must be either an array or a hash.</span><span class='tstring_end'>'</span></span>
|
|
255
255
|
<span class='kw'>end</span>
|
|
256
256
|
|
|
257
257
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_from_types'>from_types</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rparen'>)</span>
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
</div>
|
|
370
370
|
|
|
371
371
|
<div id="footer">
|
|
372
|
-
Generated on Mon Oct 28 16:
|
|
372
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
373
373
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
374
374
|
0.9.20 (ruby-2.6.2).
|
|
375
375
|
</div>
|
|
@@ -777,7 +777,7 @@ called.</p>
|
|
|
777
777
|
</div>
|
|
778
778
|
|
|
779
779
|
<div id="footer">
|
|
780
|
-
Generated on Mon Oct 28 16:
|
|
780
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
781
781
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
782
782
|
0.9.20 (ruby-2.6.2).
|
|
783
783
|
</div>
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
</div>
|
|
106
106
|
|
|
107
107
|
<div id="footer">
|
|
108
|
-
Generated on Mon Oct 28 16:
|
|
108
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
110
110
|
0.9.20 (ruby-2.6.2).
|
|
111
111
|
</div>
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
</div>
|
|
115
115
|
|
|
116
116
|
<div id="footer">
|
|
117
|
-
Generated on Mon Oct 28 16:
|
|
117
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
119
119
|
0.9.20 (ruby-2.6.2).
|
|
120
120
|
</div>
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
</div>
|
|
115
115
|
|
|
116
116
|
<div id="footer">
|
|
117
|
-
Generated on Mon Oct 28 16:
|
|
117
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
119
119
|
0.9.20 (ruby-2.6.2).
|
|
120
120
|
</div>
|
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
</div>
|
|
412
412
|
|
|
413
413
|
<div id="footer">
|
|
414
|
-
Generated on Mon Oct 28 16:
|
|
414
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
415
415
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
416
416
|
0.9.20 (ruby-2.6.2).
|
|
417
417
|
</div>
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
</div>
|
|
149
149
|
|
|
150
150
|
<div id="footer">
|
|
151
|
-
Generated on Mon Oct 28 16:
|
|
151
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
152
152
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
153
153
|
0.9.20 (ruby-2.6.2).
|
|
154
154
|
</div>
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
</div>
|
|
280
280
|
|
|
281
281
|
<div id="footer">
|
|
282
|
-
Generated on Mon Oct 28 16:
|
|
282
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
283
283
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
284
284
|
0.9.20 (ruby-2.6.2).
|
|
285
285
|
</div>
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
</div>
|
|
149
149
|
|
|
150
150
|
<div id="footer">
|
|
151
|
-
Generated on Mon Oct 28 16:
|
|
151
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
152
152
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
153
153
|
0.9.20 (ruby-2.6.2).
|
|
154
154
|
</div>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
</div>
|
|
136
136
|
|
|
137
137
|
<div id="footer">
|
|
138
|
-
Generated on Mon Oct 28 16:
|
|
138
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
140
140
|
0.9.20 (ruby-2.6.2).
|
|
141
141
|
</div>
|
data/doc/Schemacop/Node.html
CHANGED
|
@@ -1428,7 +1428,7 @@
|
|
|
1428
1428
|
</div>
|
|
1429
1429
|
|
|
1430
1430
|
<div id="footer">
|
|
1431
|
-
Generated on Mon Oct 28 16:
|
|
1431
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
1432
1432
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1433
1433
|
0.9.20 (ruby-2.6.2).
|
|
1434
1434
|
</div>
|
|
@@ -199,11 +199,11 @@
|
|
|
199
199
|
|
|
200
200
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_register'>register</span><span class='lparen'>(</span><span class='id identifier rubyid_node_class'>node_class</span><span class='comma'>,</span> <span class='label'>before:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
201
201
|
<span class='kw'>if</span> <span class='id identifier rubyid_before'>before</span>
|
|
202
|
-
<span class='kw'>unless</span> <span class='lparen'>(</span><span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='
|
|
202
|
+
<span class='kw'>unless</span> <span class='lparen'>(</span><span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='id identifier rubyid_node_classes'>node_classes</span><span class='period'>.</span><span class='id identifier rubyid_find_index'>find_index</span><span class='lparen'>(</span><span class='id identifier rubyid_before'>before</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
203
203
|
<span class='id identifier rubyid_fail'>fail</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot insert before class </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_before'>before</span><span class='embexpr_end'>}</span><span class='tstring_content'> which has not been registered yet.</span><span class='tstring_end'>"</span></span>
|
|
204
204
|
<span class='kw'>end</span>
|
|
205
205
|
|
|
206
|
-
<span class='
|
|
206
|
+
<span class='id identifier rubyid_node_classes'>node_classes</span><span class='period'>.</span><span class='id identifier rubyid_insert'>insert</span><span class='lparen'>(</span><span class='id identifier rubyid_index'>index</span><span class='comma'>,</span> <span class='id identifier rubyid_node_class'>node_class</span><span class='rparen'>)</span>
|
|
207
207
|
<span class='kw'>else</span>
|
|
208
208
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_node_classes'>node_classes</span> <span class='op'>+=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_node_class'>node_class</span><span class='rbracket'>]</span>
|
|
209
209
|
<span class='kw'>end</span>
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
</div>
|
|
249
249
|
|
|
250
250
|
<div id="footer">
|
|
251
|
-
Generated on Mon Oct 28 16:
|
|
251
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
252
252
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
253
253
|
0.9.20 (ruby-2.6.2).
|
|
254
254
|
</div>
|
|
@@ -580,7 +580,7 @@
|
|
|
580
580
|
</div>
|
|
581
581
|
|
|
582
582
|
<div id="footer">
|
|
583
|
-
Generated on Mon Oct 28 16:
|
|
583
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
584
584
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
585
585
|
0.9.20 (ruby-2.6.2).
|
|
586
586
|
</div>
|
|
@@ -602,7 +602,7 @@ as it formerly was the case in the constructor.</p>
|
|
|
602
602
|
</div>
|
|
603
603
|
|
|
604
604
|
<div id="footer">
|
|
605
|
-
Generated on Mon Oct 28 16:
|
|
605
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
606
606
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
607
607
|
0.9.20 (ruby-2.6.2).
|
|
608
608
|
</div>
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
</div>
|
|
280
280
|
|
|
281
281
|
<div id="footer">
|
|
282
|
-
Generated on Mon Oct 28 16:
|
|
282
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
283
283
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
284
284
|
0.9.20 (ruby-2.6.2).
|
|
285
285
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Mon Oct 28 16:
|
|
225
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
226
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.20 (ruby-2.6.2).
|
|
228
228
|
</div>
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
</div>
|
|
289
289
|
|
|
290
290
|
<div id="footer">
|
|
291
|
-
Generated on Mon Oct 28 16:
|
|
291
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
292
292
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
293
293
|
0.9.20 (ruby-2.6.2).
|
|
294
294
|
</div>
|
data/doc/Schemacop/RootNode.html
CHANGED
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
</div>
|
|
162
162
|
|
|
163
163
|
<div id="footer">
|
|
164
|
-
Generated on Mon Oct 28 16:
|
|
164
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
165
165
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
166
166
|
0.9.20 (ruby-2.6.2).
|
|
167
167
|
</div>
|
data/doc/Schemacop/Schema.html
CHANGED
|
@@ -687,7 +687,7 @@ this exception is thrown.</p>
|
|
|
687
687
|
</div>
|
|
688
688
|
|
|
689
689
|
<div id="footer">
|
|
690
|
-
Generated on Mon Oct 28 16:
|
|
690
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
691
691
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
692
692
|
0.9.20 (ruby-2.6.2).
|
|
693
693
|
</div>
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
</div>
|
|
286
286
|
|
|
287
287
|
<div id="footer">
|
|
288
|
-
Generated on Mon Oct 28 16:
|
|
288
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
289
289
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
290
290
|
0.9.20 (ruby-2.6.2).
|
|
291
291
|
</div>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
</div>
|
|
136
136
|
|
|
137
137
|
<div id="footer">
|
|
138
|
-
Generated on Mon Oct 28 16:
|
|
138
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
140
140
|
0.9.20 (ruby-2.6.2).
|
|
141
141
|
</div>
|
data/doc/ScopedEnv.html
CHANGED
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
</div>
|
|
342
342
|
|
|
343
343
|
<div id="footer">
|
|
344
|
-
Generated on Mon Oct 28 16:
|
|
344
|
+
Generated on Mon Oct 28 16:25:04 2019 by
|
|
345
345
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
346
346
|
0.9.20 (ruby-2.6.2).
|
|
347
347
|
</div>
|
data/doc/_index.html
CHANGED
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
</div>
|
|
355
355
|
|
|
356
356
|
<div id="footer">
|
|
357
|
-
Generated on Mon Oct 28 16:
|
|
357
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
358
358
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
359
359
|
0.9.20 (ruby-2.6.2).
|
|
360
360
|
</div>
|
data/doc/file.README.html
CHANGED
|
@@ -816,7 +816,7 @@ to <a href="http://www.subgit.com/">SubGit</a> for their great open source licen
|
|
|
816
816
|
</div></div>
|
|
817
817
|
|
|
818
818
|
<div id="footer">
|
|
819
|
-
Generated on Mon Oct 28 16:
|
|
819
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
820
820
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
821
821
|
0.9.20 (ruby-2.6.2).
|
|
822
822
|
</div>
|
data/doc/index.html
CHANGED
|
@@ -816,7 +816,7 @@ to <a href="http://www.subgit.com/">SubGit</a> for their great open source licen
|
|
|
816
816
|
</div></div>
|
|
817
817
|
|
|
818
818
|
<div id="footer">
|
|
819
|
-
Generated on Mon Oct 28 16:
|
|
819
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
820
820
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
821
821
|
0.9.20 (ruby-2.6.2).
|
|
822
822
|
</div>
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
</div>
|
|
103
103
|
|
|
104
104
|
<div id="footer">
|
|
105
|
-
Generated on Mon Oct 28 16:
|
|
105
|
+
Generated on Mon Oct 28 16:25:03 2019 by
|
|
106
106
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
107
107
|
0.9.20 (ruby-2.6.2).
|
|
108
108
|
</div>
|
data/lib/schemacop/caster.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Schemacop
|
|
|
11
11
|
elsif casts.is_a?(Hash)
|
|
12
12
|
from_types = casts.keys
|
|
13
13
|
else
|
|
14
|
-
fail Exceptions::InvalidSchemaError,
|
|
14
|
+
fail Exceptions::InvalidSchemaError, 'Option `cast` must be either an array or a hash.'
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
return unless from_types.include?(data.class)
|
data/lib/schemacop/field_node.rb
CHANGED
|
@@ -35,11 +35,10 @@ module Schemacop
|
|
|
35
35
|
return data, false unless data.nil?
|
|
36
36
|
|
|
37
37
|
@types.each do |type|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
38
|
+
next unless type.option?(:default)
|
|
39
|
+
default = type.option(:default)
|
|
40
|
+
collector.override_value(default)
|
|
41
|
+
return default, true
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
return nil, false
|
|
@@ -5,11 +5,11 @@ module Schemacop
|
|
|
5
5
|
|
|
6
6
|
def self.register(node_class, before: nil)
|
|
7
7
|
if before
|
|
8
|
-
unless (index =
|
|
8
|
+
unless (index = node_classes.find_index(before))
|
|
9
9
|
fail "Cannot insert before class #{before} which has not been registered yet."
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
node_classes.insert(index, node_class)
|
|
13
13
|
else
|
|
14
14
|
self.node_classes += [node_class]
|
|
15
15
|
end
|
|
@@ -100,19 +100,17 @@ module Schemacop
|
|
|
100
100
|
|
|
101
101
|
def cast!(data, collector)
|
|
102
102
|
@types.each do |type|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
end
|
|
115
|
-
end
|
|
103
|
+
next unless type.option?(:cast) && !type.type_matches?(data) && type.type_filter_matches?(data)
|
|
104
|
+
caster = Caster.new(type.option(:cast), data, type.class.klasses.first)
|
|
105
|
+
|
|
106
|
+
next unless caster.castable?
|
|
107
|
+
begin
|
|
108
|
+
data = caster.cast
|
|
109
|
+
collector.override_value(data)
|
|
110
|
+
return data
|
|
111
|
+
rescue Exceptions::InvalidSchemaError => e
|
|
112
|
+
collector.error e.message
|
|
113
|
+
end
|
|
116
114
|
end
|
|
117
115
|
|
|
118
116
|
return data
|
data/schemacop.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: schemacop 2.4.
|
|
2
|
+
# stub: schemacop 2.4.1 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "schemacop".freeze
|
|
6
|
-
s.version = "2.4.
|
|
6
|
+
s.version = "2.4.1"
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
data/test/casting_test.rb
CHANGED
data/test/defaults_test.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Schemacop
|
|
|
18
18
|
|
|
19
19
|
input = { foo: nil }
|
|
20
20
|
output = s.validate!(input)
|
|
21
|
-
assert_equal({ foo: 'bar'}, output)
|
|
21
|
+
assert_equal({ foo: 'bar' }, output)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def test_missing_hash_key
|
|
@@ -28,7 +28,7 @@ module Schemacop
|
|
|
28
28
|
|
|
29
29
|
input = {}
|
|
30
30
|
output = s.validate!(input)
|
|
31
|
-
assert_equal({ foo: 'bar'}, output)
|
|
31
|
+
assert_equal({ foo: 'bar' }, output)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def test_entire_hash
|
|
@@ -48,7 +48,7 @@ module Schemacop
|
|
|
48
48
|
|
|
49
49
|
def test_entire_array
|
|
50
50
|
s = Schema.new do
|
|
51
|
-
opt :foo, :array, default: [{ bar: 42}] do
|
|
51
|
+
opt :foo, :array, default: [{ bar: 42 }] do
|
|
52
52
|
req :bar
|
|
53
53
|
end
|
|
54
54
|
end
|