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.
- 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
data/doc/CSVDecision/Result.html
CHANGED
@@ -177,6 +177,64 @@ which eventually get evaluated and removed.</p>
|
|
177
177
|
<p>Returns true if this is a multi-row result.</p>
|
178
178
|
</div></span>
|
179
179
|
|
180
|
+
</li>
|
181
|
+
|
182
|
+
|
183
|
+
<li class="public ">
|
184
|
+
<span class="summary_signature">
|
185
|
+
|
186
|
+
<a href="#outs-instance_method" title="#outs (instance method)">#<strong>outs</strong> ⇒ Hash{Index=>Dictionary::Entry} </a>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
</span>
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<span class="note title readonly">readonly</span>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
<span class="private note title">private</span>
|
203
|
+
|
204
|
+
|
205
|
+
<span class="summary_desc"><div class='inline'>
|
206
|
+
<p>Output columns.</p>
|
207
|
+
</div></span>
|
208
|
+
|
209
|
+
</li>
|
210
|
+
|
211
|
+
|
212
|
+
<li class="public ">
|
213
|
+
<span class="summary_signature">
|
214
|
+
|
215
|
+
<a href="#outs_functions-instance_method" title="#outs_functions (instance method)">#<strong>outs_functions</strong> ⇒ nil, true </a>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
</span>
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
<span class="note title readonly">readonly</span>
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<span class="private note title">private</span>
|
232
|
+
|
233
|
+
|
234
|
+
<span class="summary_desc"><div class='inline'>
|
235
|
+
<p>Set to true if the table has output functions.</p>
|
236
|
+
</div></span>
|
237
|
+
|
180
238
|
</li>
|
181
239
|
|
182
240
|
|
@@ -405,12 +463,6 @@ result, along with the partial result required to evaluate functions.</p>
|
|
405
463
|
<pre class="lines">
|
406
464
|
|
407
465
|
|
408
|
-
19
|
409
|
-
20
|
410
|
-
21
|
411
|
-
22
|
412
|
-
23
|
413
|
-
24
|
414
466
|
25
|
415
467
|
26
|
416
468
|
27
|
@@ -422,13 +474,17 @@ result, along with the partial result required to evaluate functions.</p>
|
|
422
474
|
33
|
423
475
|
34
|
424
476
|
35
|
425
|
-
36
|
477
|
+
36
|
478
|
+
37
|
479
|
+
38
|
480
|
+
39</pre>
|
426
481
|
</td>
|
427
482
|
<td>
|
428
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line
|
483
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 25</span>
|
429
484
|
|
430
485
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>table:</span><span class='comma'>,</span> <span class='label'>input:</span><span class='rparen'>)</span>
|
431
486
|
<span class='ivar'>@outs</span> <span class='op'>=</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_columns'>columns</span><span class='period'>.</span><span class='id identifier rubyid_outs'>outs</span>
|
487
|
+
<span class='ivar'>@outs_functions</span> <span class='op'>=</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_outs_functions'>outs_functions</span>
|
432
488
|
<span class='ivar'>@if_columns</span> <span class='op'>=</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_columns'>columns</span><span class='period'>.</span><span class='id identifier rubyid_ifs'>ifs</span>
|
433
489
|
|
434
490
|
<span class='comment'># Partial result always copies in the input hash for calculating output functions.
|
@@ -436,14 +492,10 @@ result, along with the partial result required to evaluate functions.</p>
|
|
436
492
|
</span> <span class='comment'># have the same symbol as an input hash key.
|
437
493
|
</span> <span class='comment'># However, the rest of this hash is mutated as output column evaluation results
|
438
494
|
</span> <span class='comment'># are accumulated.
|
439
|
-
</span> <span class='ivar'>@partial_result</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span><span class='
|
495
|
+
</span> <span class='ivar'>@partial_result</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span><span class='op'>&.</span><span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_columns'>columns</span><span class='period'>.</span><span class='id identifier rubyid_input_keys'>input_keys</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@outs_functions</span>
|
440
496
|
|
441
497
|
<span class='comment'># Attributes hash contains the output decision key value pairs
|
442
498
|
</span> <span class='ivar'>@attributes</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
443
|
-
|
444
|
-
<span class='comment'># Set to true if the result has more than one row.
|
445
|
-
</span> <span class='comment'># Only possible for the first_match: false option.
|
446
|
-
</span> <span class='ivar'>@multi_result</span> <span class='op'>=</span> <span class='kw'>false</span>
|
447
499
|
<span class='kw'>end</span></pre>
|
448
500
|
</td>
|
449
501
|
</tr>
|
@@ -572,6 +624,71 @@ which eventually get evaluated and removed.</p>
|
|
572
624
|
<pre class="lines">
|
573
625
|
|
574
626
|
|
627
|
+
22
|
628
|
+
23
|
629
|
+
24</pre>
|
630
|
+
</td>
|
631
|
+
<td>
|
632
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 22</span>
|
633
|
+
|
634
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_multi_result'>multi_result</span>
|
635
|
+
<span class='ivar'>@multi_result</span>
|
636
|
+
<span class='kw'>end</span></pre>
|
637
|
+
</td>
|
638
|
+
</tr>
|
639
|
+
</table>
|
640
|
+
</div>
|
641
|
+
|
642
|
+
|
643
|
+
<span id=""></span>
|
644
|
+
<div class="method_details ">
|
645
|
+
<h3 class="signature " id="outs-instance_method">
|
646
|
+
|
647
|
+
#<strong>outs</strong> ⇒ <tt>Hash{<span class='object_link'><a href="Index.html" title="CSVDecision::Index (class)">Index</a></span>=><span class='object_link'><a href="Dictionary/Entry.html" title="CSVDecision::Dictionary::Entry (class)">Dictionary::Entry</a></span>}</tt> <span class="extras">(readonly)</span>
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
|
652
|
+
|
653
|
+
</h3><div class="docstring">
|
654
|
+
<div class="discussion">
|
655
|
+
<p class="note private">
|
656
|
+
<strong>This method is part of a private API.</strong>
|
657
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
658
|
+
</p>
|
659
|
+
|
660
|
+
<p>Returns Output columns.</p>
|
661
|
+
|
662
|
+
|
663
|
+
</div>
|
664
|
+
</div>
|
665
|
+
<div class="tags">
|
666
|
+
|
667
|
+
<p class="tag_title">Returns:</p>
|
668
|
+
<ul class="return">
|
669
|
+
|
670
|
+
<li>
|
671
|
+
|
672
|
+
|
673
|
+
<span class='type'>(<tt>Hash{<span class='object_link'><a href="Index.html" title="CSVDecision::Index (class)">Index</a></span>=><span class='object_link'><a href="Dictionary/Entry.html" title="CSVDecision::Dictionary::Entry (class)">Dictionary::Entry</a></span>}</tt>)</span>
|
674
|
+
|
675
|
+
|
676
|
+
|
677
|
+
—
|
678
|
+
<div class='inline'>
|
679
|
+
<p>Output columns.</p>
|
680
|
+
</div>
|
681
|
+
|
682
|
+
</li>
|
683
|
+
|
684
|
+
</ul>
|
685
|
+
|
686
|
+
</div><table class="source_code">
|
687
|
+
<tr>
|
688
|
+
<td>
|
689
|
+
<pre class="lines">
|
690
|
+
|
691
|
+
|
575
692
|
16
|
576
693
|
17
|
577
694
|
18</pre>
|
@@ -579,8 +696,73 @@ which eventually get evaluated and removed.</p>
|
|
579
696
|
<td>
|
580
697
|
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 16</span>
|
581
698
|
|
582
|
-
<span class='kw'>def</span> <span class='id identifier
|
583
|
-
<span class='ivar'>@
|
699
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_outs'>outs</span>
|
700
|
+
<span class='ivar'>@outs</span>
|
701
|
+
<span class='kw'>end</span></pre>
|
702
|
+
</td>
|
703
|
+
</tr>
|
704
|
+
</table>
|
705
|
+
</div>
|
706
|
+
|
707
|
+
|
708
|
+
<span id=""></span>
|
709
|
+
<div class="method_details ">
|
710
|
+
<h3 class="signature " id="outs_functions-instance_method">
|
711
|
+
|
712
|
+
#<strong>outs_functions</strong> ⇒ <tt>nil</tt>, <tt>true</tt> <span class="extras">(readonly)</span>
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
</h3><div class="docstring">
|
719
|
+
<div class="discussion">
|
720
|
+
<p class="note private">
|
721
|
+
<strong>This method is part of a private API.</strong>
|
722
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
723
|
+
</p>
|
724
|
+
|
725
|
+
<p>Returns Set to true if the table has output functions.</p>
|
726
|
+
|
727
|
+
|
728
|
+
</div>
|
729
|
+
</div>
|
730
|
+
<div class="tags">
|
731
|
+
|
732
|
+
<p class="tag_title">Returns:</p>
|
733
|
+
<ul class="return">
|
734
|
+
|
735
|
+
<li>
|
736
|
+
|
737
|
+
|
738
|
+
<span class='type'>(<tt>nil</tt>, <tt>true</tt>)</span>
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
—
|
743
|
+
<div class='inline'>
|
744
|
+
<p>Set to true if the table has output functions.</p>
|
745
|
+
</div>
|
746
|
+
|
747
|
+
</li>
|
748
|
+
|
749
|
+
</ul>
|
750
|
+
|
751
|
+
</div><table class="source_code">
|
752
|
+
<tr>
|
753
|
+
<td>
|
754
|
+
<pre class="lines">
|
755
|
+
|
756
|
+
|
757
|
+
19
|
758
|
+
20
|
759
|
+
21</pre>
|
760
|
+
</td>
|
761
|
+
<td>
|
762
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 19</span>
|
763
|
+
|
764
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_outs_functions'>outs_functions</span>
|
765
|
+
<span class='ivar'>@outs_functions</span>
|
584
766
|
<span class='kw'>end</span></pre>
|
585
767
|
</td>
|
586
768
|
</tr>
|
@@ -639,12 +821,12 @@ which eventually get evaluated and removed.</p>
|
|
639
821
|
<pre class="lines">
|
640
822
|
|
641
823
|
|
642
|
-
|
643
|
-
|
644
|
-
|
824
|
+
52
|
825
|
+
53
|
826
|
+
54</pre>
|
645
827
|
</td>
|
646
828
|
<td>
|
647
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line
|
829
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 52</span>
|
648
830
|
|
649
831
|
<span class='kw'>def</span> <span class='id identifier rubyid_accumulate_outs'>accumulate_outs</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
|
650
832
|
<span class='ivar'>@outs</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='lbrace'>{</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> <span class='id identifier rubyid_add_cell'>add_cell</span><span class='lparen'>(</span><span class='label'>column_name:</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>cell:</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='rbrace'>}</span>
|
@@ -700,12 +882,12 @@ values to the final result hash.</p>
|
|
700
882
|
<pre class="lines">
|
701
883
|
|
702
884
|
|
703
|
-
|
704
|
-
|
705
|
-
|
885
|
+
45
|
886
|
+
46
|
887
|
+
47</pre>
|
706
888
|
</td>
|
707
889
|
<td>
|
708
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line
|
890
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 45</span>
|
709
891
|
|
710
892
|
<span class='kw'>def</span> <span class='id identifier rubyid_add_outs'>add_outs</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
|
711
893
|
<span class='ivar'>@outs</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='lbrace'>{</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> <span class='ivar'>@attributes</span><span class='lbracket'>[</span><span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</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='rbrace'>}</span>
|
@@ -782,12 +964,12 @@ values to the final result hash.</p>
|
|
782
964
|
<pre class="lines">
|
783
965
|
|
784
966
|
|
785
|
-
|
786
|
-
|
787
|
-
|
967
|
+
85
|
968
|
+
86
|
969
|
+
87</pre>
|
788
970
|
</td>
|
789
971
|
<td>
|
790
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line
|
972
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 85</span>
|
791
973
|
|
792
974
|
<span class='kw'>def</span> <span class='id identifier rubyid_eval_cell_proc'>eval_cell_proc</span><span class='lparen'>(</span><span class='label'>proc:</span><span class='comma'>,</span> <span class='label'>column_name:</span><span class='comma'>,</span> <span class='label'>index:</span><span class='rparen'>)</span>
|
793
975
|
<span class='ivar'>@attributes</span><span class='lbracket'>[</span><span class='id identifier rubyid_column_name'>column_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_index'>index</span><span class='rbracket'>]</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><span class='lbracket'>[</span><span class='id identifier rubyid_partial_result'>partial_result</span><span class='lparen'>(</span><span class='id identifier rubyid_index'>index</span><span class='rparen'>)</span><span class='rbracket'>]</span>
|
@@ -856,18 +1038,18 @@ result, along with the partial result required to evaluate functions.</p>
|
|
856
1038
|
<pre class="lines">
|
857
1039
|
|
858
1040
|
|
859
|
-
67
|
860
|
-
68
|
861
|
-
69
|
862
1041
|
70
|
863
1042
|
71
|
864
1043
|
72
|
865
1044
|
73
|
866
1045
|
74
|
867
|
-
75
|
1046
|
+
75
|
1047
|
+
76
|
1048
|
+
77
|
1049
|
+
78</pre>
|
868
1050
|
</td>
|
869
1051
|
<td>
|
870
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line
|
1052
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 70</span>
|
871
1053
|
|
872
1054
|
<span class='kw'>def</span> <span class='id identifier rubyid_eval_outs'>eval_outs</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
|
873
1055
|
<span class='comment'># Set the constants first, in case the functions refer to them
|
@@ -926,15 +1108,15 @@ result, along with the partial result required to evaluate functions.</p>
|
|
926
1108
|
<pre class="lines">
|
927
1109
|
|
928
1110
|
|
929
|
-
55
|
930
|
-
56
|
931
|
-
57
|
932
1111
|
58
|
933
1112
|
59
|
934
|
-
60
|
1113
|
+
60
|
1114
|
+
61
|
1115
|
+
62
|
1116
|
+
63</pre>
|
935
1117
|
</td>
|
936
1118
|
<td>
|
937
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line
|
1119
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/result.rb', line 58</span>
|
938
1120
|
|
939
1121
|
<span class='kw'>def</span> <span class='id identifier rubyid_final'>final</span>
|
940
1122
|
<span class='comment'># If there are no if: columns, then nothing needs to be filtered out of this result hash.
|
@@ -952,7 +1134,7 @@ result, along with the partial result required to evaluate functions.</p>
|
|
952
1134
|
</div>
|
953
1135
|
|
954
1136
|
<div id="footer">
|
955
|
-
Generated on Sat Jan
|
1137
|
+
Generated on Sat Jan 20 15:44:35 2018 by
|
956
1138
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
957
1139
|
0.9.12 (ruby-2.4.0).
|
958
1140
|
</div>
|