schemacop 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +11 -6
  4. data/VERSION +1 -1
  5. data/doc/Schemacop.html +1 -1
  6. data/doc/Schemacop/ArrayValidator.html +1 -1
  7. data/doc/Schemacop/BooleanValidator.html +1 -1
  8. data/doc/Schemacop/Collector.html +206 -30
  9. data/doc/Schemacop/Exceptions.html +1 -1
  10. data/doc/Schemacop/Exceptions/InvalidSchemaError.html +1 -1
  11. data/doc/Schemacop/Exceptions/ValidationError.html +1 -1
  12. data/doc/Schemacop/FieldNode.html +1 -1
  13. data/doc/Schemacop/FloatValidator.html +1 -1
  14. data/doc/Schemacop/HashValidator.html +1 -1
  15. data/doc/Schemacop/IntegerValidator.html +1 -1
  16. data/doc/Schemacop/NilValidator.html +1 -1
  17. data/doc/Schemacop/Node.html +1 -1
  18. data/doc/Schemacop/NodeResolver.html +1 -1
  19. data/doc/Schemacop/NodeSupportingField.html +1 -1
  20. data/doc/Schemacop/NodeSupportingType.html +1 -1
  21. data/doc/Schemacop/NodeWithBlock.html +1 -1
  22. data/doc/Schemacop/NumberValidator.html +1 -1
  23. data/doc/Schemacop/ObjectValidator.html +18 -8
  24. data/doc/Schemacop/RootNode.html +1 -1
  25. data/doc/Schemacop/Schema.html +2 -2
  26. data/doc/Schemacop/StringValidator.html +1 -1
  27. data/doc/Schemacop/SymbolValidator.html +1 -1
  28. data/doc/ScopedEnv.html +1 -1
  29. data/doc/_index.html +1 -1
  30. data/doc/file.README.html +25 -18
  31. data/doc/index.html +25 -18
  32. data/doc/method_list.html +19 -3
  33. data/doc/top-level-namespace.html +1 -1
  34. data/lib/schemacop/collector.rb +21 -2
  35. data/lib/schemacop/node_supporting_field.rb +0 -2
  36. data/lib/schemacop/schema.rb +1 -1
  37. data/lib/schemacop/validator/object_validator.rb +7 -1
  38. data/schemacop.gemspec +5 -5
  39. data/test/collector_test.rb +45 -0
  40. data/test/short_forms_test.rb +15 -0
  41. data/test/validator_object_test.rb +18 -0
  42. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 553c564f36cf2b16bd1bc72f48f75abcaef6d66e
4
- data.tar.gz: 9546f609f7e8e58db4012efd82ca4dee1ae21788
3
+ metadata.gz: 2a881f50a99b3649b5c14fa9abf22c9710bdde01
4
+ data.tar.gz: 4024af09852c2778bc001b48c535fadf37e9aea2
5
5
  SHA512:
6
- metadata.gz: c033fe31d11708a6f499869d9736b4b42081c02860270e48776ac86e9181f0522668dd3fa18ab80f31f2621453a3ac32493fab6e2da1502d61d028a58a621f25
7
- data.tar.gz: 219c873fbeac36c803011553d34a88d073da8c30b61119cf0647f8fc3347cc736f8ad4306411a23173a79043592c4a697b3f984134cc91a0ac5f7c02b37817f1
6
+ metadata.gz: 28d55b6ee46e777552d5a666d20e79d1ed6e2867c00b7540c8d2c07195ba3968617430d2b1ea50151e00e6ddf3007548ed2ecdf97b67e36db775ead8331c3ff1
7
+ data.tar.gz: e24a7f4e3edc58582c7289aa1f8497c2f96211e3b5f1e76c86fd896ef3dde56fcdb584c0f57f903904fec656c879a582d81fcaf651c02a077f38cf5e558da9d4
@@ -10,6 +10,24 @@
10
10
  ### Changes
11
11
  -->
12
12
 
13
+ ## 2.3.0 (2017-05-18)
14
+
15
+ ### New features
16
+
17
+ * Option `strict` for the Type `:object`
18
+
19
+ This option, which defaults to true, ensures that instance classes are checked
20
+ strictly. If set to false, instances of derived classes are also allowed.
21
+
22
+ ### Bug fixes
23
+
24
+ * Removed '/root' from the paths in the error messages
25
+
26
+ ### Changes
27
+
28
+ * Added tests for the Collector paths to ensure correct behavior
29
+ * Added symbol Type to the short forms test
30
+
13
31
  ## 2.2.0 (2017-05-17)
14
32
 
15
33
  ### Changes
data/README.md CHANGED
@@ -79,7 +79,7 @@ end
79
79
  At runtime:
80
80
 
81
81
  ```ruby
82
- my_shema.validate!(
82
+ my_schema.validate!(
83
83
  # Your data goes here
84
84
  )
85
85
  ```
@@ -332,11 +332,16 @@ The following types are supported by Schemacop by default:
332
332
 
333
333
  * `:object` accepts an arbitrary Ruby object (any object if no option is given).
334
334
 
335
- - supported option: `classes`: Ruby class (or an array of them) that will be
336
- the only recognized filters. Unlike other options, this one affects not the
337
- validation but the type recognition, meaning that you can have multiple Type
338
- Lines with different `classes` option for the same field, each having its
339
- own validation (e.g. through the option `check`).
335
+ Supported options:
336
+
337
+ - `classes`: Ruby class (or an array of them) that will be the only recognized
338
+ filters. Unlike other options, this one affects not the validation but the
339
+ type recognition, meaning that you can have multiple Type Lines with
340
+ different `classes` option for the same field, each having its own
341
+ validation (e.g. through the option `check`).
342
+
343
+ - `strict`: Boolean option, defaults to true. If set to false, the validator
344
+ also allows derived classes of those specified with `classes`.
340
345
 
341
346
  * `:array` accepts a Ruby Array.
342
347
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.3.0
@@ -109,7 +109,7 @@
109
109
  </div>
110
110
 
111
111
  <div id="footer">
112
- Generated on Wed May 17 10:53:58 2017 by
112
+ Generated on Thu May 18 13:17:23 2017 by
113
113
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
114
114
  0.9.9 (ruby-2.3.1).
115
115
  </div>
@@ -319,7 +319,7 @@
319
319
  </div>
320
320
 
321
321
  <div id="footer">
322
- Generated on Wed May 17 10:53:58 2017 by
322
+ Generated on Thu May 18 13:17:23 2017 by
323
323
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
324
324
  0.9.9 (ruby-2.3.1).
325
325
  </div>
@@ -135,7 +135,7 @@
135
135
  </div>
136
136
 
137
137
  <div id="footer">
138
- Generated on Wed May 17 10:53:58 2017 by
138
+ Generated on Thu May 18 13:17:23 2017 by
139
139
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
140
140
  0.9.9 (ruby-2.3.1).
141
141
  </div>
@@ -131,6 +131,34 @@
131
131
  <span class="summary_desc"><div class='inline'><p>Returns the value of attribute current_path.</p>
132
132
  </div></span>
133
133
 
134
+ </li>
135
+
136
+
137
+ <li class="public ">
138
+ <span class="summary_signature">
139
+
140
+ <a href="#exceptions-instance_method" title="#exceptions (instance method)">#<strong>exceptions</strong> &#x21d2; Object </a>
141
+
142
+
143
+
144
+ </span>
145
+
146
+
147
+
148
+
149
+ <span class="note title readonly">readonly</span>
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute exceptions.</p>
160
+ </div></span>
161
+
134
162
  </li>
135
163
 
136
164
 
@@ -188,6 +216,29 @@
188
216
 
189
217
  <span class="summary_desc"><div class='inline'></div></span>
190
218
 
219
+ </li>
220
+
221
+
222
+ <li class="public ">
223
+ <span class="summary_signature">
224
+
225
+ <a href="#ignore_next_segment-instance_method" title="#ignore_next_segment (instance method)">#<strong>ignore_next_segment</strong> &#x21d2; Schemacop::Collector </a>
226
+
227
+
228
+
229
+ </span>
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+ <span class="summary_desc"><div class='inline'><p>Does not include the path segment next time path is called.</p>
240
+ </div></span>
241
+
191
242
  </li>
192
243
 
193
244
 
@@ -233,7 +284,8 @@
233
284
 
234
285
 
235
286
 
236
- <span class="summary_desc"><div class='inline'></div></span>
287
+ <span class="summary_desc"><div class='inline'><p>Construct the current path.</p>
288
+ </div></span>
237
289
 
238
290
  </li>
239
291
 
@@ -291,17 +343,19 @@
291
343
  <pre class="lines">
292
344
 
293
345
 
294
- 5
295
346
  6
296
347
  7
297
- 8</pre>
348
+ 8
349
+ 9
350
+ 10</pre>
298
351
  </td>
299
352
  <td>
300
- <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 5</span>
353
+ <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 6</span>
301
354
 
302
355
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
303
356
  <span class='ivar'>@exceptions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
304
357
  <span class='ivar'>@current_path</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
358
+ <span class='ivar'>@ignore_next_segment</span> <span class='op'>=</span> <span class='kw'>false</span>
305
359
  <span class='kw'>end</span></pre>
306
360
  </td>
307
361
  </tr>
@@ -355,6 +409,48 @@
355
409
  </table>
356
410
  </div>
357
411
 
412
+
413
+ <span id=""></span>
414
+ <div class="method_details ">
415
+ <h3 class="signature " id="exceptions-instance_method">
416
+
417
+ #<strong>exceptions</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
418
+
419
+
420
+
421
+
422
+
423
+ </h3><div class="docstring">
424
+ <div class="discussion">
425
+ <p>Returns the value of attribute exceptions</p>
426
+
427
+
428
+ </div>
429
+ </div>
430
+ <div class="tags">
431
+
432
+
433
+ </div><table class="source_code">
434
+ <tr>
435
+ <td>
436
+ <pre class="lines">
437
+
438
+
439
+ 4
440
+ 5
441
+ 6</pre>
442
+ </td>
443
+ <td>
444
+ <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 4</span>
445
+
446
+ <span class='kw'>def</span> <span class='id identifier rubyid_exceptions'>exceptions</span>
447
+ <span class='ivar'>@exceptions</span>
448
+ <span class='kw'>end</span></pre>
449
+ </td>
450
+ </tr>
451
+ </table>
452
+ </div>
453
+
358
454
  </div>
359
455
 
360
456
 
@@ -377,15 +473,15 @@
377
473
  <pre class="lines">
378
474
 
379
475
 
380
- 27
381
- 28
382
- 29
383
- 30
384
- 31
385
- 32</pre>
476
+ 37
477
+ 38
478
+ 39
479
+ 40
480
+ 41
481
+ 42</pre>
386
482
  </td>
387
483
  <td>
388
- <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 27</span>
484
+ <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 37</span>
389
485
 
390
486
  <span class='kw'>def</span> <span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='id identifier rubyid_error_msg'>error_msg</span><span class='rparen'>)</span>
391
487
  <span class='ivar'>@exceptions</span> <span class='op'>&lt;&lt;</span> <span class='lbrace'>{</span>
@@ -413,14 +509,14 @@
413
509
  <pre class="lines">
414
510
 
415
511
 
416
- 21
417
- 22
418
- 23
419
- 24
420
- 25</pre>
512
+ 31
513
+ 32
514
+ 33
515
+ 34
516
+ 35</pre>
421
517
  </td>
422
518
  <td>
423
- <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 21</span>
519
+ <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 31</span>
424
520
 
425
521
  <span class='kw'>def</span> <span class='id identifier rubyid_exception_message'>exception_message</span>
426
522
  <span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Schemacop validation failed:\n</span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span> <span class='ivar'>@exceptions</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_e'>e</span><span class='op'>|</span>
@@ -430,6 +526,62 @@
430
526
  </td>
431
527
  </tr>
432
528
  </table>
529
+ </div>
530
+
531
+ <div class="method_details ">
532
+ <h3 class="signature " id="ignore_next_segment-instance_method">
533
+
534
+ #<strong>ignore_next_segment</strong> &#x21d2; <tt><span class='object_link'><a href="" title="Schemacop::Collector (class)">Schemacop::Collector</a></span></tt>
535
+
536
+
537
+
538
+
539
+
540
+ </h3><div class="docstring">
541
+ <div class="discussion">
542
+ <p>Does not include the path segment next time path is
543
+ called.</p>
544
+
545
+
546
+ </div>
547
+ </div>
548
+ <div class="tags">
549
+
550
+ <p class="tag_title">Returns:</p>
551
+ <ul class="return">
552
+
553
+ <li>
554
+
555
+
556
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Schemacop::Collector (class)">Schemacop::Collector</a></span></tt>)</span>
557
+
558
+
559
+
560
+ </li>
561
+
562
+ </ul>
563
+
564
+ </div><table class="source_code">
565
+ <tr>
566
+ <td>
567
+ <pre class="lines">
568
+
569
+
570
+ 48
571
+ 49
572
+ 50
573
+ 51</pre>
574
+ </td>
575
+ <td>
576
+ <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 48</span>
577
+
578
+ <span class='kw'>def</span> <span class='id identifier rubyid_ignore_next_segment'>ignore_next_segment</span>
579
+ <span class='ivar'>@ignore_next_segment</span> <span class='op'>=</span> <span class='kw'>true</span>
580
+ <span class='kw'>return</span> <span class='kw'>self</span>
581
+ <span class='kw'>end</span></pre>
582
+ </td>
583
+ </tr>
584
+ </table>
433
585
  </div>
434
586
 
435
587
  <div class="method_details ">
@@ -441,27 +593,51 @@
441
593
 
442
594
 
443
595
 
444
- </h3><table class="source_code">
596
+ </h3><div class="docstring">
597
+ <div class="discussion">
598
+ <p>Construct the current path</p>
599
+
600
+
601
+ </div>
602
+ </div>
603
+ <div class="tags">
604
+
605
+
606
+ </div><table class="source_code">
445
607
  <tr>
446
608
  <td>
447
609
  <pre class="lines">
448
610
 
449
611
 
450
- 14
451
- 15
452
- 16
453
612
  17
454
613
  18
455
- 19</pre>
614
+ 19
615
+ 20
616
+ 21
617
+ 22
618
+ 23
619
+ 24
620
+ 25
621
+ 26
622
+ 27
623
+ 28
624
+ 29</pre>
456
625
  </td>
457
626
  <td>
458
- <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 14</span>
627
+ <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 17</span>
459
628
 
460
629
  <span class='kw'>def</span> <span class='id identifier rubyid_path'>path</span><span class='lparen'>(</span><span class='id identifier rubyid_segment'>segment</span><span class='rparen'>)</span>
461
- <span class='ivar'>@current_path</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_segment'>segment</span>
630
+ <span class='id identifier rubyid_ignore_this_segment'>ignore_this_segment</span> <span class='op'>=</span> <span class='kw'>false</span>
631
+ <span class='kw'>if</span> <span class='ivar'>@ignore_next_segment</span>
632
+ <span class='id identifier rubyid_ignore_this_segment'>ignore_this_segment</span> <span class='op'>=</span> <span class='kw'>true</span>
633
+ <span class='ivar'>@ignore_next_segment</span> <span class='op'>=</span> <span class='kw'>false</span>
634
+ <span class='kw'>end</span>
635
+
636
+ <span class='ivar'>@current_path</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_segment'>segment</span> <span class='kw'>unless</span> <span class='id identifier rubyid_ignore_this_segment'>ignore_this_segment</span>
637
+
462
638
  <span class='kw'>yield</span>
463
639
  <span class='kw'>ensure</span>
464
- <span class='ivar'>@current_path</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span>
640
+ <span class='ivar'>@current_path</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span> <span class='kw'>unless</span> <span class='id identifier rubyid_ignore_this_segment'>ignore_this_segment</span>
465
641
  <span class='kw'>end</span></pre>
466
642
  </td>
467
643
  </tr>
@@ -505,12 +681,12 @@
505
681
  <pre class="lines">
506
682
 
507
683
 
508
- 10
509
- 11
510
- 12</pre>
684
+ 12
685
+ 13
686
+ 14</pre>
511
687
  </td>
512
688
  <td>
513
- <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 10</span>
689
+ <pre class="code"><span class="info file"># File 'lib/schemacop/collector.rb', line 12</span>
514
690
 
515
691
  <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span>
516
692
  <span class='ivar'>@exceptions</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
@@ -525,7 +701,7 @@
525
701
  </div>
526
702
 
527
703
  <div id="footer">
528
- Generated on Wed May 17 10:53:58 2017 by
704
+ Generated on Thu May 18 13:17:23 2017 by
529
705
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
530
706
  0.9.9 (ruby-2.3.1).
531
707
  </div>
@@ -105,7 +105,7 @@
105
105
  </div>
106
106
 
107
107
  <div id="footer">
108
- Generated on Wed May 17 10:53:58 2017 by
108
+ Generated on Thu May 18 13:17:23 2017 by
109
109
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
110
  0.9.9 (ruby-2.3.1).
111
111
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Wed May 17 10:53:58 2017 by
117
+ Generated on Thu May 18 13:17:23 2017 by
118
118
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.9 (ruby-2.3.1).
120
120
  </div>