csv_decision 0.2.0 → 0.3.0
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 +5 -1
- data/README.md +11 -8
- data/benchmarks/rufus_decision.rb +9 -1
- data/csv_decision.gemspec +1 -1
- data/doc/CSVDecision/CellValidationError.html +1 -1
- data/doc/CSVDecision/Columns/Dictionary.html +29 -29
- data/doc/CSVDecision/Columns.html +394 -47
- data/doc/CSVDecision/Data.html +2 -2
- data/doc/CSVDecision/Decide.html +23 -159
- data/doc/CSVDecision/Decision.html +370 -32
- data/doc/CSVDecision/Defaults.html +1 -1
- data/doc/CSVDecision/Dictionary/Entry.html +157 -55
- data/doc/CSVDecision/Dictionary.html +37 -21
- data/doc/CSVDecision/Error.html +1 -1
- data/doc/CSVDecision/FileError.html +1 -1
- data/doc/CSVDecision/Header.html +142 -1
- data/doc/CSVDecision/Index.html +741 -0
- data/doc/CSVDecision/Input.html +14 -61
- data/doc/CSVDecision/Load.html +1 -1
- data/doc/CSVDecision/Matchers/Constant.html +1 -1
- data/doc/CSVDecision/Matchers/Function.html +1 -1
- data/doc/CSVDecision/Matchers/Guard.html +13 -147
- data/doc/CSVDecision/Matchers/Matcher.html +13 -13
- data/doc/CSVDecision/Matchers/Numeric.html +1 -1
- data/doc/CSVDecision/Matchers/Pattern.html +1 -1
- data/doc/CSVDecision/Matchers/Proc.html +147 -14
- data/doc/CSVDecision/Matchers/Range.html +1 -1
- data/doc/CSVDecision/Matchers/Symbol.html +1 -1
- data/doc/CSVDecision/Matchers.html +55 -162
- data/doc/CSVDecision/Options.html +21 -21
- data/doc/CSVDecision/Parse.html +2 -180
- data/doc/CSVDecision/Result.html +220 -38
- data/doc/CSVDecision/ScanRow.html +69 -325
- data/doc/CSVDecision/Table.html +128 -40
- data/doc/CSVDecision/TableValidationError.html +1 -1
- data/doc/CSVDecision/Validate.html +1 -1
- data/doc/CSVDecision.html +4 -4
- data/doc/_index.html +8 -8
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +13 -11
- data/doc/index.html +13 -11
- data/doc/method_list.html +206 -150
- data/doc/top-level-namespace.html +1 -1
- data/lib/csv_decision/columns.rb +87 -1
- data/lib/csv_decision/decision.rb +54 -29
- data/lib/csv_decision/defaults.rb +1 -1
- data/lib/csv_decision/dictionary.rb +32 -22
- data/lib/csv_decision/header.rb +17 -0
- data/lib/csv_decision/index.rb +107 -0
- data/lib/csv_decision/input.rb +45 -13
- data/lib/csv_decision/matchers/guard.rb +2 -0
- data/lib/csv_decision/matchers.rb +14 -8
- data/lib/csv_decision/options.rb +7 -19
- data/lib/csv_decision/parse.rb +12 -96
- data/lib/csv_decision/result.rb +10 -9
- data/lib/csv_decision/scan_row.rb +20 -44
- data/lib/csv_decision/table.rb +7 -4
- data/lib/csv_decision.rb +1 -1
- data/spec/csv_decision/columns_spec.rb +6 -6
- data/spec/csv_decision/data_spec.rb +0 -5
- data/spec/csv_decision/index_spec.rb +58 -0
- data/spec/csv_decision/input_spec.rb +7 -2
- data/spec/csv_decision/options_spec.rb +16 -1
- data/spec/csv_decision/parse_spec.rb +4 -5
- data/spec/csv_decision/table_spec.rb +70 -0
- data/spec/data/{valid → invalid}/empty.csv +0 -0
- data/spec/data/valid/index_example.csv +12 -0
- data/spec/data/valid/multi_column_index.csv +10 -0
- data/spec/data/valid/multi_column_index2.csv +12 -0
- data/spec/data/valid/options_in_file3.csv +13 -0
- metadata +16 -5
- 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) ⇒ 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'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:) ⇒ 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="#
|
255
|
+
<a href="#match%3F-instance_method" title="#match? (instance method)">#<strong>match?</strong>(row:, scan_cols:, hash:) ⇒ 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
|
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:) ⇒ 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
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
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
|
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> ⇒ <tt>Array<Integer></tt>
|
364
|
+
#<strong>constants</strong> ⇒ <tt>Array<Integer></tt>
|
416
365
|
|
417
366
|
|
418
367
|
|
@@ -457,12 +406,12 @@ hash.</p>
|
|
457
406
|
<pre class="lines">
|
458
407
|
|
459
408
|
|
460
|
-
|
461
|
-
|
462
|
-
|
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
|
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
|
-
|
526
|
-
|
527
|
-
|
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
|
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="
|
497
|
+
<h3 class="signature first" id="scan-class_method">
|
549
498
|
|
550
|
-
.<strong>
|
499
|
+
.<strong>scan</strong>(column:, matchers:, cell:) ⇒ <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>
|
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'>
|
523
|
+
<span class='name'>column</span>
|
576
524
|
|
577
525
|
|
578
|
-
<span class='type'>(<tt
|
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
|
—
|
583
531
|
<div class='inline'>
|
584
|
-
<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
|
-
—
|
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=>Object}</tt>)</span>
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
—
|
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:) ⇒ <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
|
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
|
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'>'</span><span class='tstring_end'>'</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="
|
761
|
-
|
762
|
-
#<strong>match_constants?</strong>(row:, scan_cols:) ⇒ <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=>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<String></tt>)</span>
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
—
|
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
|
-
—
|
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>
|
617
|
+
#<strong>match?</strong>(row:, scan_cols:, hash:) ⇒ <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
|
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 => Hash{Symbol=>Object}, Hash{Integer=>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
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
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
|
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
|
956
|
-
<span class='
|
957
|
-
<span class='id identifier
|
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='
|
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='
|
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
|
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='
|
1095
|
-
|
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'>'</span><span class='tstring_end'>'</span></span> <span class='op'>&&</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
|
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'><<</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
|
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>
|