csv_decision2 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +3 -0
  3. data/.coveralls.yml +2 -0
  4. data/.gitignore +14 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +30 -0
  7. data/.travis.yml +6 -0
  8. data/CHANGELOG.md +85 -0
  9. data/Dockerfile +6 -0
  10. data/Gemfile +7 -0
  11. data/LICENSE +21 -0
  12. data/README.md +356 -0
  13. data/benchmarks/rufus_decision.rb +158 -0
  14. data/csv_decision2.gemspec +38 -0
  15. data/doc/CSVDecision/CellValidationError.html +143 -0
  16. data/doc/CSVDecision/Columns/Default.html +589 -0
  17. data/doc/CSVDecision/Columns/Dictionary.html +801 -0
  18. data/doc/CSVDecision/Columns/Entry.html +508 -0
  19. data/doc/CSVDecision/Columns.html +1259 -0
  20. data/doc/CSVDecision/Constant.html +254 -0
  21. data/doc/CSVDecision/Data.html +479 -0
  22. data/doc/CSVDecision/Decide.html +302 -0
  23. data/doc/CSVDecision/Decision.html +1011 -0
  24. data/doc/CSVDecision/Defaults.html +291 -0
  25. data/doc/CSVDecision/Dictionary/Entry.html +1147 -0
  26. data/doc/CSVDecision/Dictionary.html +426 -0
  27. data/doc/CSVDecision/Error.html +139 -0
  28. data/doc/CSVDecision/FileError.html +143 -0
  29. data/doc/CSVDecision/Function.html +240 -0
  30. data/doc/CSVDecision/Guard.html +245 -0
  31. data/doc/CSVDecision/Header.html +647 -0
  32. data/doc/CSVDecision/Index.html +741 -0
  33. data/doc/CSVDecision/Input.html +404 -0
  34. data/doc/CSVDecision/Load.html +296 -0
  35. data/doc/CSVDecision/Matchers/Constant.html +484 -0
  36. data/doc/CSVDecision/Matchers/Function.html +511 -0
  37. data/doc/CSVDecision/Matchers/Guard.html +503 -0
  38. data/doc/CSVDecision/Matchers/Matcher.html +507 -0
  39. data/doc/CSVDecision/Matchers/Numeric.html +415 -0
  40. data/doc/CSVDecision/Matchers/Pattern.html +491 -0
  41. data/doc/CSVDecision/Matchers/Proc.html +704 -0
  42. data/doc/CSVDecision/Matchers/Range.html +379 -0
  43. data/doc/CSVDecision/Matchers/Symbol.html +426 -0
  44. data/doc/CSVDecision/Matchers.html +1567 -0
  45. data/doc/CSVDecision/Numeric.html +259 -0
  46. data/doc/CSVDecision/Options.html +443 -0
  47. data/doc/CSVDecision/Parse.html +282 -0
  48. data/doc/CSVDecision/Paths.html +742 -0
  49. data/doc/CSVDecision/Result.html +1200 -0
  50. data/doc/CSVDecision/Scan/InputHashes.html +369 -0
  51. data/doc/CSVDecision/Scan.html +313 -0
  52. data/doc/CSVDecision/ScanRow.html +866 -0
  53. data/doc/CSVDecision/Symbol.html +256 -0
  54. data/doc/CSVDecision/Table.html +1470 -0
  55. data/doc/CSVDecision/TableValidationError.html +143 -0
  56. data/doc/CSVDecision/Validate.html +422 -0
  57. data/doc/CSVDecision.html +621 -0
  58. data/doc/_index.html +471 -0
  59. data/doc/class_list.html +51 -0
  60. data/doc/css/common.css +1 -0
  61. data/doc/css/full_list.css +58 -0
  62. data/doc/css/style.css +499 -0
  63. data/doc/file.README.html +421 -0
  64. data/doc/file_list.html +56 -0
  65. data/doc/frames.html +17 -0
  66. data/doc/index.html +421 -0
  67. data/doc/js/app.js +248 -0
  68. data/doc/js/full_list.js +216 -0
  69. data/doc/js/jquery.js +4 -0
  70. data/doc/method_list.html +1163 -0
  71. data/doc/top-level-namespace.html +110 -0
  72. data/docker-compose.yml +13 -0
  73. data/lib/csv_decision/columns.rb +192 -0
  74. data/lib/csv_decision/data.rb +92 -0
  75. data/lib/csv_decision/decision.rb +196 -0
  76. data/lib/csv_decision/defaults.rb +47 -0
  77. data/lib/csv_decision/dictionary.rb +180 -0
  78. data/lib/csv_decision/header.rb +83 -0
  79. data/lib/csv_decision/index.rb +107 -0
  80. data/lib/csv_decision/input.rb +121 -0
  81. data/lib/csv_decision/load.rb +36 -0
  82. data/lib/csv_decision/matchers/constant.rb +74 -0
  83. data/lib/csv_decision/matchers/function.rb +56 -0
  84. data/lib/csv_decision/matchers/guard.rb +142 -0
  85. data/lib/csv_decision/matchers/numeric.rb +44 -0
  86. data/lib/csv_decision/matchers/pattern.rb +94 -0
  87. data/lib/csv_decision/matchers/range.rb +95 -0
  88. data/lib/csv_decision/matchers/symbol.rb +149 -0
  89. data/lib/csv_decision/matchers.rb +220 -0
  90. data/lib/csv_decision/options.rb +124 -0
  91. data/lib/csv_decision/parse.rb +165 -0
  92. data/lib/csv_decision/paths.rb +78 -0
  93. data/lib/csv_decision/result.rb +204 -0
  94. data/lib/csv_decision/scan.rb +117 -0
  95. data/lib/csv_decision/scan_row.rb +142 -0
  96. data/lib/csv_decision/table.rb +101 -0
  97. data/lib/csv_decision/validate.rb +85 -0
  98. data/lib/csv_decision.rb +45 -0
  99. data/spec/csv_decision/columns_spec.rb +251 -0
  100. data/spec/csv_decision/constant_spec.rb +36 -0
  101. data/spec/csv_decision/data_spec.rb +50 -0
  102. data/spec/csv_decision/decision_spec.rb +19 -0
  103. data/spec/csv_decision/examples_spec.rb +242 -0
  104. data/spec/csv_decision/index_spec.rb +58 -0
  105. data/spec/csv_decision/input_spec.rb +55 -0
  106. data/spec/csv_decision/load_spec.rb +28 -0
  107. data/spec/csv_decision/matchers/function_spec.rb +82 -0
  108. data/spec/csv_decision/matchers/guard_spec.rb +170 -0
  109. data/spec/csv_decision/matchers/numeric_spec.rb +47 -0
  110. data/spec/csv_decision/matchers/pattern_spec.rb +183 -0
  111. data/spec/csv_decision/matchers/range_spec.rb +70 -0
  112. data/spec/csv_decision/matchers/symbol_spec.rb +67 -0
  113. data/spec/csv_decision/options_spec.rb +94 -0
  114. data/spec/csv_decision/parse_spec.rb +44 -0
  115. data/spec/csv_decision/table_spec.rb +683 -0
  116. data/spec/csv_decision_spec.rb +7 -0
  117. data/spec/data/invalid/empty.csv +0 -0
  118. data/spec/data/invalid/invalid_header1.csv +4 -0
  119. data/spec/data/invalid/invalid_header2.csv +4 -0
  120. data/spec/data/invalid/invalid_header3.csv +4 -0
  121. data/spec/data/invalid/invalid_header4.csv +4 -0
  122. data/spec/data/valid/benchmark_regexp.csv +10 -0
  123. data/spec/data/valid/index_example.csv +13 -0
  124. data/spec/data/valid/multi_column_index.csv +10 -0
  125. data/spec/data/valid/multi_column_index2.csv +12 -0
  126. data/spec/data/valid/options_in_file1.csv +5 -0
  127. data/spec/data/valid/options_in_file2.csv +5 -0
  128. data/spec/data/valid/options_in_file3.csv +13 -0
  129. data/spec/data/valid/regular_expressions.csv +11 -0
  130. data/spec/data/valid/simple_constants.csv +5 -0
  131. data/spec/data/valid/simple_example.csv +10 -0
  132. data/spec/data/valid/valid.csv +4 -0
  133. data/spec/spec_helper.rb +106 -0
  134. metadata +352 -0
@@ -0,0 +1,443 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: CSVDecision::Options
8
+
9
+ &mdash; Documentation by YARD 0.9.12
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "CSVDecision::Options";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (O)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../CSVDecision.html" title="CSVDecision (module)">CSVDecision</a></span></span>
41
+ &raquo;
42
+ <span class="title">Options</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: CSVDecision::Options
63
+
64
+
65
+ <span class="private note title">Private</span>
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/csv_decision/options.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Overview</h2><div class="docstring">
87
+ <div class="discussion">
88
+ <p class="note private">
89
+ <strong>This module is part of a private API.</strong>
90
+ You should avoid using this module if possible, as it may be removed or be changed in the future.
91
+ </p>
92
+
93
+ <p>Validate and normalize the options values supplied.</p>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+
101
+ </div>
102
+ <h2>Constant Summary</h2>
103
+ <dl class="constants">
104
+
105
+ <dt id="DEFAULT_MATCHERS-constant" class="">DEFAULT_MATCHERS =
106
+ <div class="docstring">
107
+ <div class="discussion">
108
+ <p class="note private">
109
+ <strong>This constant is part of a private API.</strong>
110
+ You should avoid using this constant if possible, as it may be removed or be changed in the future.
111
+ </p>
112
+
113
+ <p>Specialized cell value matchers beyond simple string compares. By default
114
+ all these matchers are tried in the specified order on all input data
115
+ cells.</p>
116
+
117
+
118
+ </div>
119
+ </div>
120
+ <div class="tags">
121
+
122
+
123
+ </div>
124
+ </dt>
125
+ <dd><pre class="code"><span class='lbracket'>[</span>
126
+ <span class='const'><span class='object_link'><a href="Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Matchers/Range.html" title="CSVDecision::Matchers::Range (class)">Range</a></span></span><span class='comma'>,</span>
127
+ <span class='const'><span class='object_link'><a href="Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Matchers/Numeric.html" title="CSVDecision::Matchers::Numeric (class)">Numeric</a></span></span><span class='comma'>,</span>
128
+ <span class='const'><span class='object_link'><a href="Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Matchers/Pattern.html" title="CSVDecision::Matchers::Pattern (class)">Pattern</a></span></span><span class='comma'>,</span>
129
+ <span class='const'><span class='object_link'><a href="Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Matchers/Constant.html" title="CSVDecision::Matchers::Constant (class)">Constant</a></span></span><span class='comma'>,</span>
130
+ <span class='const'><span class='object_link'><a href="Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Matchers/Symbol.html" title="CSVDecision::Matchers::Symbol (class)">Symbol</a></span></span><span class='comma'>,</span>
131
+ <span class='const'><span class='object_link'><a href="Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Matchers/Guard.html" title="CSVDecision::Matchers::Guard (class)">Guard</a></span></span>
132
+ <span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
133
+
134
+ </dl>
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <h2>
144
+ Class Method Summary
145
+ <small><a href="#" class="summary_toggle">collapse</a></small>
146
+ </h2>
147
+
148
+ <ul class="summary">
149
+
150
+ <li class="public ">
151
+ <span class="summary_signature">
152
+
153
+ <a href="#from_csv-class_method" title="from_csv (class method)">.<strong>from_csv</strong>(rows:, options:) &#x21d2; Hash </a>
154
+
155
+
156
+
157
+ </span>
158
+
159
+
160
+
161
+
162
+
163
+
164
+ <span class="private note title">private</span>
165
+
166
+
167
+ <span class="summary_desc"><div class='inline'>
168
+ <p>Read any options supplied in the CSV file placed before the header row.</p>
169
+ </div></span>
170
+
171
+ </li>
172
+
173
+
174
+ <li class="public ">
175
+ <span class="summary_signature">
176
+
177
+ <a href="#normalize-class_method" title="normalize (class method)">.<strong>normalize</strong>(options) &#x21d2; Hash </a>
178
+
179
+
180
+
181
+ </span>
182
+
183
+
184
+
185
+
186
+
187
+
188
+ <span class="private note title">private</span>
189
+
190
+
191
+ <span class="summary_desc"><div class='inline'>
192
+ <p>Validate options and supply default values for any options not explicitly
193
+ set.</p>
194
+ </div></span>
195
+
196
+ </li>
197
+
198
+
199
+ </ul>
200
+
201
+
202
+
203
+
204
+ <div id="class_method_details" class="method_details_list">
205
+ <h2>Class Method Details</h2>
206
+
207
+
208
+ <div class="method_details first">
209
+ <h3 class="signature first" id="from_csv-class_method">
210
+
211
+ .<strong>from_csv</strong>(rows:, options:) &#x21d2; <tt>Hash</tt>
212
+
213
+
214
+
215
+
216
+
217
+ </h3><div class="docstring">
218
+ <div class="discussion">
219
+ <p class="note private">
220
+ <strong>This method is part of a private API.</strong>
221
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
222
+ </p>
223
+
224
+ <p>Read any options supplied in the CSV file placed before the header row.</p>
225
+
226
+
227
+ </div>
228
+ </div>
229
+ <div class="tags">
230
+ <p class="tag_title">Parameters:</p>
231
+ <ul class="param">
232
+
233
+ <li>
234
+
235
+ <span class='name'>rows</span>
236
+
237
+
238
+ <span class='type'>(<tt>Array&lt;Array&lt;String&gt;&gt;</tt>)</span>
239
+
240
+
241
+
242
+ &mdash;
243
+ <div class='inline'>
244
+ <p>Table data rows.</p>
245
+ </div>
246
+
247
+ </li>
248
+
249
+ <li>
250
+
251
+ <span class='name'>options</span>
252
+
253
+
254
+ <span class='type'>(<tt>Hash</tt>)</span>
255
+
256
+
257
+
258
+ &mdash;
259
+ <div class='inline'>
260
+ <p>Input options hash built so far.</p>
261
+ </div>
262
+
263
+ </li>
264
+
265
+ </ul>
266
+
267
+ <p class="tag_title">Returns:</p>
268
+ <ul class="return">
269
+
270
+ <li>
271
+
272
+
273
+ <span class='type'>(<tt>Hash</tt>)</span>
274
+
275
+
276
+
277
+ &mdash;
278
+ <div class='inline'>
279
+ <p>Options hash overridden with any values found in the CSV file.</p>
280
+ </div>
281
+
282
+ </li>
283
+
284
+ </ul>
285
+
286
+ </div><table class="source_code">
287
+ <tr>
288
+ <td>
289
+ <pre class="lines">
290
+
291
+
292
+ 56
293
+ 57
294
+ 58
295
+ 59
296
+ 60
297
+ 61
298
+ 62
299
+ 63
300
+ 64
301
+ 65
302
+ 66
303
+ 67
304
+ 68</pre>
305
+ </td>
306
+ <td>
307
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/options.rb', line 56</span>
308
+
309
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_csv'>from_csv</span><span class='lparen'>(</span><span class='label'>rows:</span><span class='comma'>,</span> <span class='label'>options:</span><span class='rparen'>)</span>
310
+ <span class='id identifier rubyid_row'>row</span> <span class='op'>=</span> <span class='id identifier rubyid_rows'>rows</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
311
+ <span class='kw'>return</span> <span class='id identifier rubyid_options'>options</span> <span class='kw'>if</span> <span class='id identifier rubyid_row'>row</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
312
+
313
+ <span class='comment'># Have we hit the header row?
314
+ </span> <span class='kw'>return</span> <span class='id identifier rubyid_options'>options</span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="Header.html" title="CSVDecision::Header (module)">Header</a></span></span><span class='period'>.</span><span class='id identifier rubyid_row?'><span class='object_link'><a href="Header.html#row%3F-class_method" title="CSVDecision::Header.row? (method)">row?</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
315
+
316
+ <span class='comment'># Scan each cell looking for valid option values
317
+ </span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_scan_cells'>scan_cells</span><span class='lparen'>(</span><span class='label'>row:</span> <span class='id identifier rubyid_row'>row</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
318
+
319
+ <span class='id identifier rubyid_rows'>rows</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
320
+ <span class='id identifier rubyid_from_csv'>from_csv</span><span class='lparen'>(</span><span class='label'>rows:</span> <span class='id identifier rubyid_rows'>rows</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
321
+ <span class='kw'>end</span></pre>
322
+ </td>
323
+ </tr>
324
+ </table>
325
+ </div>
326
+
327
+ <div class="method_details ">
328
+ <h3 class="signature " id="normalize-class_method">
329
+
330
+ .<strong>normalize</strong>(options) &#x21d2; <tt>Hash</tt>
331
+
332
+
333
+
334
+
335
+
336
+ </h3><div class="docstring">
337
+ <div class="discussion">
338
+ <p class="note private">
339
+ <strong>This method is part of a private API.</strong>
340
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
341
+ </p>
342
+
343
+ <p>Validate options and supply default values for any options not explicitly
344
+ set.</p>
345
+
346
+
347
+ </div>
348
+ </div>
349
+ <div class="tags">
350
+ <p class="tag_title">Parameters:</p>
351
+ <ul class="param">
352
+
353
+ <li>
354
+
355
+ <span class='name'>options</span>
356
+
357
+
358
+ <span class='type'>(<tt>Hash</tt>)</span>
359
+
360
+
361
+
362
+ &mdash;
363
+ <div class='inline'>
364
+ <p>Input options hash supplied by the user.</p>
365
+ </div>
366
+
367
+ </li>
368
+
369
+ </ul>
370
+
371
+ <p class="tag_title">Returns:</p>
372
+ <ul class="return">
373
+
374
+ <li>
375
+
376
+
377
+ <span class='type'>(<tt>Hash</tt>)</span>
378
+
379
+
380
+
381
+ &mdash;
382
+ <div class='inline'>
383
+ <p>Options hash filled in with all required values, defaulted if necessary.</p>
384
+ </div>
385
+
386
+ </li>
387
+
388
+ </ul>
389
+ <p class="tag_title">Raises:</p>
390
+ <ul class="raise">
391
+
392
+ <li>
393
+
394
+
395
+ <span class='type'>(<tt><span class='object_link'><a href="CellValidationError.html" title="CSVDecision::CellValidationError (class)">CellValidationError</a></span></tt>)</span>
396
+
397
+
398
+
399
+ &mdash;
400
+ <div class='inline'>
401
+ <p>For invalid option keys.</p>
402
+ </div>
403
+
404
+ </li>
405
+
406
+ </ul>
407
+
408
+ </div><table class="source_code">
409
+ <tr>
410
+ <td>
411
+ <pre class="lines">
412
+
413
+
414
+ 46
415
+ 47
416
+ 48
417
+ 49</pre>
418
+ </td>
419
+ <td>
420
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/options.rb', line 46</span>
421
+
422
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize'>normalize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
423
+ <span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
424
+ <span class='id identifier rubyid_default'>default</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
425
+ <span class='kw'>end</span></pre>
426
+ </td>
427
+ </tr>
428
+ </table>
429
+ </div>
430
+
431
+ </div>
432
+
433
+ </div>
434
+
435
+ <div id="footer">
436
+ Generated on Sun Feb 11 10:26:07 2018 by
437
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
438
+ 0.9.12 (ruby-2.4.0).
439
+ </div>
440
+
441
+ </div>
442
+ </body>
443
+ </html>