csv_decision 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/README.md +11 -8
  4. data/benchmarks/rufus_decision.rb +9 -1
  5. data/csv_decision.gemspec +1 -1
  6. data/doc/CSVDecision/CellValidationError.html +1 -1
  7. data/doc/CSVDecision/Columns/Dictionary.html +29 -29
  8. data/doc/CSVDecision/Columns.html +394 -47
  9. data/doc/CSVDecision/Data.html +2 -2
  10. data/doc/CSVDecision/Decide.html +23 -159
  11. data/doc/CSVDecision/Decision.html +370 -32
  12. data/doc/CSVDecision/Defaults.html +1 -1
  13. data/doc/CSVDecision/Dictionary/Entry.html +157 -55
  14. data/doc/CSVDecision/Dictionary.html +37 -21
  15. data/doc/CSVDecision/Error.html +1 -1
  16. data/doc/CSVDecision/FileError.html +1 -1
  17. data/doc/CSVDecision/Header.html +142 -1
  18. data/doc/CSVDecision/Index.html +741 -0
  19. data/doc/CSVDecision/Input.html +14 -61
  20. data/doc/CSVDecision/Load.html +1 -1
  21. data/doc/CSVDecision/Matchers/Constant.html +1 -1
  22. data/doc/CSVDecision/Matchers/Function.html +1 -1
  23. data/doc/CSVDecision/Matchers/Guard.html +13 -147
  24. data/doc/CSVDecision/Matchers/Matcher.html +13 -13
  25. data/doc/CSVDecision/Matchers/Numeric.html +1 -1
  26. data/doc/CSVDecision/Matchers/Pattern.html +1 -1
  27. data/doc/CSVDecision/Matchers/Proc.html +147 -14
  28. data/doc/CSVDecision/Matchers/Range.html +1 -1
  29. data/doc/CSVDecision/Matchers/Symbol.html +1 -1
  30. data/doc/CSVDecision/Matchers.html +55 -162
  31. data/doc/CSVDecision/Options.html +21 -21
  32. data/doc/CSVDecision/Parse.html +2 -180
  33. data/doc/CSVDecision/Result.html +220 -38
  34. data/doc/CSVDecision/ScanRow.html +69 -325
  35. data/doc/CSVDecision/Table.html +128 -40
  36. data/doc/CSVDecision/TableValidationError.html +1 -1
  37. data/doc/CSVDecision/Validate.html +1 -1
  38. data/doc/CSVDecision.html +4 -4
  39. data/doc/_index.html +8 -8
  40. data/doc/class_list.html +1 -1
  41. data/doc/file.README.html +13 -11
  42. data/doc/index.html +13 -11
  43. data/doc/method_list.html +206 -150
  44. data/doc/top-level-namespace.html +1 -1
  45. data/lib/csv_decision/columns.rb +87 -1
  46. data/lib/csv_decision/decision.rb +54 -29
  47. data/lib/csv_decision/defaults.rb +1 -1
  48. data/lib/csv_decision/dictionary.rb +32 -22
  49. data/lib/csv_decision/header.rb +17 -0
  50. data/lib/csv_decision/index.rb +107 -0
  51. data/lib/csv_decision/input.rb +45 -13
  52. data/lib/csv_decision/matchers/guard.rb +2 -0
  53. data/lib/csv_decision/matchers.rb +14 -8
  54. data/lib/csv_decision/options.rb +7 -19
  55. data/lib/csv_decision/parse.rb +12 -96
  56. data/lib/csv_decision/result.rb +10 -9
  57. data/lib/csv_decision/scan_row.rb +20 -44
  58. data/lib/csv_decision/table.rb +7 -4
  59. data/lib/csv_decision.rb +1 -1
  60. data/spec/csv_decision/columns_spec.rb +6 -6
  61. data/spec/csv_decision/data_spec.rb +0 -5
  62. data/spec/csv_decision/index_spec.rb +58 -0
  63. data/spec/csv_decision/input_spec.rb +7 -2
  64. data/spec/csv_decision/options_spec.rb +16 -1
  65. data/spec/csv_decision/parse_spec.rb +4 -5
  66. data/spec/csv_decision/table_spec.rb +70 -0
  67. data/spec/data/{valid → invalid}/empty.csv +0 -0
  68. data/spec/data/valid/index_example.csv +12 -0
  69. data/spec/data/valid/multi_column_index.csv +10 -0
  70. data/spec/data/valid/multi_column_index2.csv +12 -0
  71. data/spec/data/valid/options_in_file3.csv +13 -0
  72. metadata +16 -5
  73. data/lib/csv_decision/decide.rb +0 -45
@@ -133,8 +133,6 @@
133
133
 
134
134
 
135
135
 
136
- <span class="note title readonly">readonly</span>
137
-
138
136
 
139
137
 
140
138
 
@@ -195,31 +193,6 @@
195
193
  <li class="public ">
196
194
  <span class="summary_signature">
197
195
 
198
- <a href="#eval_matcher-class_method" title="eval_matcher (class method)">.<strong>eval_matcher</strong>(proc:, hash:, value: nil) &#x21d2; Object </a>
199
-
200
-
201
-
202
- </span>
203
-
204
-
205
-
206
-
207
-
208
-
209
- <span class="private note title">private</span>
210
-
211
-
212
- <span class="summary_desc"><div class='inline'>
213
- <p>Evaluate the cell proc against the column&#39;s input value and/or input
214
- hash.</p>
215
- </div></span>
216
-
217
- </li>
218
-
219
-
220
- <li class="public ">
221
- <span class="summary_signature">
222
-
223
196
  <a href="#scan-class_method" title="scan (class method)">.<strong>scan</strong>(column:, matchers:, cell:) &#x21d2; false, Matchers::Proc </a>
224
197
 
225
198
 
@@ -279,7 +252,7 @@ hash.</p>
279
252
  <li class="public ">
280
253
  <span class="summary_signature">
281
254
 
282
- <a href="#match_constants%3F-instance_method" title="#match_constants? (instance method)">#<strong>match_constants?</strong>(row:, scan_cols:) &#x21d2; Boolean </a>
255
+ <a href="#match%3F-instance_method" title="#match? (instance method)">#<strong>match?</strong>(row:, scan_cols:, hash:) &#x21d2; Boolean </a>
283
256
 
284
257
 
285
258
 
@@ -294,31 +267,7 @@ hash.</p>
294
267
 
295
268
 
296
269
  <span class="summary_desc"><div class='inline'>
297
- <p>Match cells containing simple constants.</p>
298
- </div></span>
299
-
300
- </li>
301
-
302
-
303
- <li class="public ">
304
- <span class="summary_signature">
305
-
306
- <a href="#match_procs%3F-instance_method" title="#match_procs? (instance method)">#<strong>match_procs?</strong>(row:, input:) &#x21d2; Boolean </a>
307
-
308
-
309
-
310
- </span>
311
-
312
-
313
-
314
-
315
-
316
-
317
- <span class="private note title">private</span>
318
-
319
-
320
- <span class="summary_desc"><div class='inline'>
321
- <p>Match cells containing a Proc object.</p>
270
+ <p>Match cells in the input hash against a decision table row.</p>
322
271
  </div></span>
323
272
 
324
273
  </li>
@@ -385,13 +334,13 @@ hash.</p>
385
334
  <pre class="lines">
386
335
 
387
336
 
388
- 86
389
- 87
390
- 88
391
- 89</pre>
337
+ 72
338
+ 73
339
+ 74
340
+ 75</pre>
392
341
  </td>
393
342
  <td>
394
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 86</span>
343
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 72</span>
395
344
 
396
345
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
397
346
  <span class='ivar'>@constants</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
@@ -408,11 +357,11 @@ hash.</p>
408
357
  <h2>Instance Attribute Details</h2>
409
358
 
410
359
 
411
- <span id=""></span>
360
+ <span id="constants=-instance_method"></span>
412
361
  <div class="method_details first">
413
362
  <h3 class="signature first" id="constants-instance_method">
414
363
 
415
- #<strong>constants</strong> &#x21d2; <tt>Array&lt;Integer&gt;</tt> <span class="extras">(readonly)</span>
364
+ #<strong>constants</strong> &#x21d2; <tt>Array&lt;Integer&gt;</tt>
416
365
 
417
366
 
418
367
 
@@ -457,12 +406,12 @@ hash.</p>
457
406
  <pre class="lines">
458
407
 
459
408
 
460
- 81
461
- 82
462
- 83</pre>
409
+ 67
410
+ 68
411
+ 69</pre>
463
412
  </td>
464
413
  <td>
465
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 81</span>
414
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 67</span>
466
415
 
467
416
  <span class='kw'>def</span> <span class='id identifier rubyid_constants'>constants</span>
468
417
  <span class='ivar'>@constants</span>
@@ -522,12 +471,12 @@ hash.</p>
522
471
  <pre class="lines">
523
472
 
524
473
 
525
- 84
526
- 85
527
- 86</pre>
474
+ 70
475
+ 71
476
+ 72</pre>
528
477
  </td>
529
478
  <td>
530
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 84</span>
479
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 70</span>
531
480
 
532
481
  <span class='kw'>def</span> <span class='id identifier rubyid_procs'>procs</span>
533
482
  <span class='ivar'>@procs</span>
@@ -545,9 +494,9 @@ hash.</p>
545
494
 
546
495
 
547
496
  <div class="method_details first">
548
- <h3 class="signature first" id="eval_matcher-class_method">
497
+ <h3 class="signature first" id="scan-class_method">
549
498
 
550
- .<strong>eval_matcher</strong>(proc:, hash:, value: nil) &#x21d2; <tt>Object</tt>
499
+ .<strong>scan</strong>(column:, matchers:, cell:) &#x21d2; <tt>false</tt>, <tt><span class='object_link'><a href="Matchers/Proc.html" title="CSVDecision::Matchers::Proc (class)">Matchers::Proc</a></span></tt>
551
500
 
552
501
 
553
502
 
@@ -560,8 +509,7 @@ hash.</p>
560
509
  You should avoid using this method if possible, as it may be removed or be changed in the future.
561
510
  </p>
562
511
 
563
- <p>Evaluate the cell proc against the column&#39;s input value and/or input
564
- hash.</p>
512
+ <p>Scan the table cell against all matches.</p>
565
513
 
566
514
 
567
515
  </div>
@@ -572,113 +520,20 @@ hash.</p>
572
520
 
573
521
  <li>
574
522
 
575
- <span class='name'>proc</span>
523
+ <span class='name'>column</span>
576
524
 
577
525
 
578
- <span class='type'>(<tt>CSVDecision::Proc</tt>)</span>
526
+ <span class='type'>(<tt><span class='object_link'><a href="Dictionary/Entry.html" title="CSVDecision::Dictionary::Entry (class)">Dictionary::Entry</a></span></tt>)</span>
579
527
 
580
528
 
581
529
 
582
530
  &mdash;
583
531
  <div class='inline'>
584
- <p>Proc in the table cell.</p>
532
+ <p>Column dictionary entry.</p>
585
533
  </div>
586
534
 
587
535
  </li>
588
536
 
589
- <li>
590
-
591
- <span class='name'>value</span>
592
-
593
-
594
- <span class='type'>(<tt>Object</tt>)</span>
595
-
596
-
597
-
598
- &mdash;
599
- <div class='inline'>
600
- <p>Value supplied in the input hash corresponding to this column.</p>
601
- </div>
602
-
603
- </li>
604
-
605
- <li>
606
-
607
- <span class='name'>hash</span>
608
-
609
-
610
- <span class='type'>(<tt>{Symbol=&gt;Object}</tt>)</span>
611
-
612
-
613
-
614
- &mdash;
615
- <div class='inline'>
616
- <p>Input hash with symbolized keys.</p>
617
- </div>
618
-
619
- </li>
620
-
621
- </ul>
622
-
623
-
624
- </div><table class="source_code">
625
- <tr>
626
- <td>
627
- <pre class="lines">
628
-
629
-
630
- 35
631
- 36
632
- 37
633
- 38
634
- 39
635
- 40
636
- 41
637
- 42
638
- 43</pre>
639
- </td>
640
- <td>
641
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 35</span>
642
-
643
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_eval_matcher'>eval_matcher</span><span class='lparen'>(</span><span class='label'>proc:</span><span class='comma'>,</span> <span class='label'>hash:</span><span class='comma'>,</span> <span class='label'>value:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
644
- <span class='id identifier rubyid_function'>function</span> <span class='op'>=</span> <span class='id identifier rubyid_proc'>proc</span><span class='period'>.</span><span class='id identifier rubyid_function'>function</span>
645
-
646
- <span class='comment'># A symbol guard expression just needs to be passed the input hash
647
- </span> <span class='kw'>return</span> <span class='id identifier rubyid_function'>function</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_proc'>proc</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:guard</span>
648
-
649
- <span class='comment'># All other procs can take one or two args
650
- </span> <span class='id identifier rubyid_function'>function</span><span class='period'>.</span><span class='id identifier rubyid_arity'>arity</span> <span class='op'>==</span> <span class='int'>1</span> <span class='op'>?</span> <span class='id identifier rubyid_function'>function</span><span class='lbracket'>[</span><span class='id identifier rubyid_value'>value</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_function'>function</span><span class='lbracket'>[</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span>
651
- <span class='kw'>end</span></pre>
652
- </td>
653
- </tr>
654
- </table>
655
- </div>
656
-
657
- <div class="method_details ">
658
- <h3 class="signature " id="scan-class_method">
659
-
660
- .<strong>scan</strong>(column:, matchers:, cell:) &#x21d2; <tt>false</tt>, <tt><span class='object_link'><a href="Matchers/Proc.html" title="CSVDecision::Matchers::Proc (class)">Matchers::Proc</a></span></tt>
661
-
662
-
663
-
664
-
665
-
666
- </h3><div class="docstring">
667
- <div class="discussion">
668
- <p class="note private">
669
- <strong>This method is part of a private API.</strong>
670
- You should avoid using this method if possible, as it may be removed or be changed in the future.
671
- </p>
672
-
673
- <p>Scan the table cell against all matches.</p>
674
-
675
-
676
- </div>
677
- </div>
678
- <div class="tags">
679
- <p class="tag_title">Parameters:</p>
680
- <ul class="param">
681
-
682
537
  <li>
683
538
 
684
539
  <span class='name'>matchers</span>
@@ -723,7 +578,6 @@ hash.</p>
723
578
  <pre class="lines">
724
579
 
725
580
 
726
- 20
727
581
  21
728
582
  22
729
583
  23
@@ -731,10 +585,11 @@ hash.</p>
731
585
  25
732
586
  26
733
587
  27
734
- 28</pre>
588
+ 28
589
+ 29</pre>
735
590
  </td>
736
591
  <td>
737
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 20</span>
592
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 21</span>
738
593
 
739
594
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='label'>column:</span><span class='comma'>,</span> <span class='label'>matchers:</span><span class='comma'>,</span> <span class='label'>cell:</span><span class='rparen'>)</span>
740
595
  <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_cell'>cell</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
@@ -757,111 +612,9 @@ hash.</p>
757
612
 
758
613
 
759
614
  <div class="method_details first">
760
- <h3 class="signature first" id="match_constants?-instance_method">
761
-
762
- #<strong>match_constants?</strong>(row:, scan_cols:) &#x21d2; <tt>Boolean</tt>
763
-
764
-
765
-
766
-
767
-
768
- </h3><div class="docstring">
769
- <div class="discussion">
770
- <p class="note private">
771
- <strong>This method is part of a private API.</strong>
772
- You should avoid using this method if possible, as it may be removed or be changed in the future.
773
- </p>
774
-
775
- <p>Match cells containing simple constants.</p>
776
-
777
-
778
- </div>
779
- </div>
780
- <div class="tags">
781
- <p class="tag_title">Parameters:</p>
782
- <ul class="param">
783
-
784
- <li>
785
-
786
- <span class='name'>scan_cols</span>
787
-
788
-
789
- <span class='type'>(<tt>Hash{Integer=&gt;Object}</tt>)</span>
790
-
791
-
792
-
793
- </li>
794
-
795
- <li>
796
-
797
- <span class='name'>row</span>
798
-
799
-
800
- <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
801
-
802
-
803
-
804
- &mdash;
805
- <div class='inline'>
806
- <p>Data row - still just all string constants.</p>
807
- </div>
808
-
809
- </li>
810
-
811
- </ul>
812
-
813
- <p class="tag_title">Returns:</p>
814
- <ul class="return">
815
-
816
- <li>
817
-
818
-
819
- <span class='type'>(<tt>Boolean</tt>)</span>
820
-
821
-
822
-
823
- &mdash;
824
- <div class='inline'>
825
- <p>True for a match, false otherwise.</p>
826
- </div>
827
-
828
- </li>
829
-
830
- </ul>
831
-
832
- </div><table class="source_code">
833
- <tr>
834
- <td>
835
- <pre class="lines">
836
-
837
-
838
- 119
839
- 120
840
- 121
841
- 122
842
- 123
843
- 124
844
- 125</pre>
845
- </td>
846
- <td>
847
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 119</span>
848
-
849
- <span class='kw'>def</span> <span class='id identifier rubyid_match_constants?'>match_constants?</span><span class='lparen'>(</span><span class='label'>row:</span><span class='comma'>,</span> <span class='label'>scan_cols:</span><span class='rparen'>)</span>
850
- <span class='id identifier rubyid_constants'>constants</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_col'>col</span><span class='op'>|</span>
851
- <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span>
852
- <span class='kw'>end</span>
853
-
854
- <span class='kw'>true</span>
855
- <span class='kw'>end</span></pre>
856
- </td>
857
- </tr>
858
- </table>
859
- </div>
860
-
861
- <div class="method_details ">
862
- <h3 class="signature " id="match_procs?-instance_method">
615
+ <h3 class="signature first" id="match?-instance_method">
863
616
 
864
- #<strong>match_procs?</strong>(row:, input:) &#x21d2; <tt>Boolean</tt>
617
+ #<strong>match?</strong>(row:, scan_cols:, hash:) &#x21d2; <tt>Boolean</tt>
865
618
 
866
619
 
867
620
 
@@ -874,7 +627,7 @@ hash.</p>
874
627
  You should avoid using this method if possible, as it may be removed or be changed in the future.
875
628
  </p>
876
629
 
877
- <p>Match cells containing a Proc object.</p>
630
+ <p>Match cells in the input hash against a decision table row.</p>
878
631
 
879
632
 
880
633
  </div>
@@ -883,17 +636,6 @@ hash.</p>
883
636
  <p class="tag_title">Parameters:</p>
884
637
  <ul class="param">
885
638
 
886
- <li>
887
-
888
- <span class='name'>input</span>
889
-
890
-
891
- <span class='type'>(<tt>Hash{Symbol =&gt; Hash{Symbol=&gt;Object}, Hash{Integer=&gt;Object}}</tt>)</span>
892
-
893
-
894
-
895
- </li>
896
-
897
639
  <li>
898
640
 
899
641
  <span class='name'>row</span>
@@ -937,31 +679,27 @@ hash.</p>
937
679
  <pre class="lines">
938
680
 
939
681
 
940
- 131
941
- 132
942
- 133
943
- 134
944
- 135
945
- 136
946
- 137
947
- 138
948
- 139
949
- 140
950
- 141</pre>
682
+ 108
683
+ 109
684
+ 110
685
+ 111
686
+ 112
687
+ 113
688
+ 114
689
+ 115
690
+ 116</pre>
951
691
  </td>
952
692
  <td>
953
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 131</span>
693
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 108</span>
954
694
 
955
- <span class='kw'>def</span> <span class='id identifier rubyid_match_procs?'>match_procs?</span><span class='lparen'>(</span><span class='label'>row:</span><span class='comma'>,</span> <span class='label'>input:</span><span class='rparen'>)</span>
956
- <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span>
957
- <span class='id identifier rubyid_scan_cols'>scan_cols</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span><span class='lbracket'>[</span><span class='symbol'>:scan_cols</span><span class='rbracket'>]</span>
695
+ <span class='kw'>def</span> <span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='label'>row:</span><span class='comma'>,</span> <span class='label'>scan_cols:</span><span class='comma'>,</span> <span class='label'>hash:</span><span class='rparen'>)</span>
696
+ <span class='comment'># Check any table row cell constants first, and maybe fail fast...
697
+ </span> <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='ivar'>@constants</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_col'>col</span><span class='op'>|</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
958
698
 
959
- <span class='id identifier rubyid_procs'>procs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_col'>col</span><span class='op'>|</span>
960
- <span class='id identifier rubyid_match'>match</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="CSVDecision::ScanRow (class)">ScanRow</a></span></span><span class='period'>.</span><span class='id identifier rubyid_eval_matcher'><span class='object_link'><a href="#eval_matcher-class_method" title="CSVDecision::ScanRow.eval_matcher (method)">eval_matcher</a></span></span><span class='lparen'>(</span><span class='label'>proc:</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>value:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
961
- <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_match'>match</span>
962
- <span class='kw'>end</span>
699
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@procs</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
963
700
 
964
- <span class='kw'>true</span>
701
+ <span class='comment'># These table row cells are Proc objects which need evaluating
702
+ </span> <span class='ivar'>@procs</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_col'>col</span><span class='op'>|</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='label'>value:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
965
703
  <span class='kw'>end</span></pre>
966
704
  </td>
967
705
  </tr>
@@ -1070,35 +808,41 @@ non-string constant.</p>
1070
808
  <pre class="lines">
1071
809
 
1072
810
 
811
+ 85
812
+ 86
813
+ 87
814
+ 88
815
+ 89
816
+ 90
817
+ 91
818
+ 92
819
+ 93
820
+ 94
821
+ 95
822
+ 96
823
+ 97
824
+ 98
1073
825
  99
1074
826
  100
1075
827
  101
1076
- 102
1077
- 103
1078
- 104
1079
- 105
1080
- 106
1081
- 107
1082
- 108
1083
- 109
1084
- 110
1085
- 111
1086
- 112
1087
- 113</pre>
828
+ 102</pre>
1088
829
  </td>
1089
830
  <td>
1090
- <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 99</span>
831
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/scan_row.rb', line 85</span>
1091
832
 
1092
833
  <span class='kw'>def</span> <span class='id identifier rubyid_scan_columns'>scan_columns</span><span class='lparen'>(</span><span class='label'>row:</span><span class='comma'>,</span> <span class='label'>columns:</span><span class='comma'>,</span> <span class='label'>matchers:</span><span class='rparen'>)</span>
1093
834
  <span class='id identifier rubyid_columns'>columns</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_col'>col</span><span class='comma'>,</span> <span class='id identifier rubyid_column'>column</span><span class='op'>|</span>
1094
- <span class='comment'># An empty input cell matches everything, and so never needs to be scanned
1095
- </span> <span class='kw'>next</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_cell'>cell</span> <span class='op'>=</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_ins?'>ins?</span>
835
+ <span class='id identifier rubyid_cell'>cell</span> <span class='op'>=</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span>
836
+
837
+ <span class='comment'># An empty input cell matches everything, and so never needs to be scanned,
838
+ </span> <span class='comment'># but it cannot be indexed either.
839
+ </span> <span class='kw'>next</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_indexed'>indexed</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_cell'>cell</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_ins?'>ins?</span>
1096
840
 
1097
- <span class='comment'># If the column is text only then no special matchers need be invoked
841
+ <span class='comment'># If the column is text only then no special matchers need be used.
1098
842
  </span> <span class='kw'>next</span> <span class='ivar'>@constants</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_col'>col</span> <span class='kw'>if</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_eval'>eval</span> <span class='op'>==</span> <span class='kw'>false</span>
1099
843
 
1100
844
  <span class='comment'># Need to scan the cell against all matchers, and possibly overwrite
1101
- </span> <span class='comment'># the cell contents with a Matchers::Proc.
845
+ </span> <span class='comment'># the cell contents with a Matchers::Proc value.
1102
846
  </span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_col'>col</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_scan_cell'>scan_cell</span><span class='lparen'>(</span><span class='label'>column:</span> <span class='id identifier rubyid_column'>column</span><span class='comma'>,</span> <span class='label'>col:</span> <span class='id identifier rubyid_col'>col</span><span class='comma'>,</span> <span class='label'>matchers:</span> <span class='id identifier rubyid_matchers'>matchers</span><span class='comma'>,</span> <span class='label'>cell:</span> <span class='id identifier rubyid_cell'>cell</span><span class='rparen'>)</span>
1103
847
  <span class='kw'>end</span>
1104
848
 
@@ -1114,7 +858,7 @@ non-string constant.</p>
1114
858
  </div>
1115
859
 
1116
860
  <div id="footer">
1117
- Generated on Sat Jan 13 10:02:47 2018 by
861
+ Generated on Sat Jan 20 15:44:35 2018 by
1118
862
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1119
863
  0.9.12 (ruby-2.4.0).
1120
864
  </div>