csv_decision2 0.5.1
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 +7 -0
- data/.codeclimate.yml +3 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +30 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +85 -0
- data/Dockerfile +6 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +356 -0
- data/benchmarks/rufus_decision.rb +158 -0
- data/csv_decision2.gemspec +38 -0
- data/doc/CSVDecision/CellValidationError.html +143 -0
- data/doc/CSVDecision/Columns/Default.html +589 -0
- data/doc/CSVDecision/Columns/Dictionary.html +801 -0
- data/doc/CSVDecision/Columns/Entry.html +508 -0
- data/doc/CSVDecision/Columns.html +1259 -0
- data/doc/CSVDecision/Constant.html +254 -0
- data/doc/CSVDecision/Data.html +479 -0
- data/doc/CSVDecision/Decide.html +302 -0
- data/doc/CSVDecision/Decision.html +1011 -0
- data/doc/CSVDecision/Defaults.html +291 -0
- data/doc/CSVDecision/Dictionary/Entry.html +1147 -0
- data/doc/CSVDecision/Dictionary.html +426 -0
- data/doc/CSVDecision/Error.html +139 -0
- data/doc/CSVDecision/FileError.html +143 -0
- data/doc/CSVDecision/Function.html +240 -0
- data/doc/CSVDecision/Guard.html +245 -0
- data/doc/CSVDecision/Header.html +647 -0
- data/doc/CSVDecision/Index.html +741 -0
- data/doc/CSVDecision/Input.html +404 -0
- data/doc/CSVDecision/Load.html +296 -0
- data/doc/CSVDecision/Matchers/Constant.html +484 -0
- data/doc/CSVDecision/Matchers/Function.html +511 -0
- data/doc/CSVDecision/Matchers/Guard.html +503 -0
- data/doc/CSVDecision/Matchers/Matcher.html +507 -0
- data/doc/CSVDecision/Matchers/Numeric.html +415 -0
- data/doc/CSVDecision/Matchers/Pattern.html +491 -0
- data/doc/CSVDecision/Matchers/Proc.html +704 -0
- data/doc/CSVDecision/Matchers/Range.html +379 -0
- data/doc/CSVDecision/Matchers/Symbol.html +426 -0
- data/doc/CSVDecision/Matchers.html +1567 -0
- data/doc/CSVDecision/Numeric.html +259 -0
- data/doc/CSVDecision/Options.html +443 -0
- data/doc/CSVDecision/Parse.html +282 -0
- data/doc/CSVDecision/Paths.html +742 -0
- data/doc/CSVDecision/Result.html +1200 -0
- data/doc/CSVDecision/Scan/InputHashes.html +369 -0
- data/doc/CSVDecision/Scan.html +313 -0
- data/doc/CSVDecision/ScanRow.html +866 -0
- data/doc/CSVDecision/Symbol.html +256 -0
- data/doc/CSVDecision/Table.html +1470 -0
- data/doc/CSVDecision/TableValidationError.html +143 -0
- data/doc/CSVDecision/Validate.html +422 -0
- data/doc/CSVDecision.html +621 -0
- data/doc/_index.html +471 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +499 -0
- data/doc/file.README.html +421 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +421 -0
- data/doc/js/app.js +248 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1163 -0
- data/doc/top-level-namespace.html +110 -0
- data/docker-compose.yml +13 -0
- data/lib/csv_decision/columns.rb +192 -0
- data/lib/csv_decision/data.rb +92 -0
- data/lib/csv_decision/decision.rb +196 -0
- data/lib/csv_decision/defaults.rb +47 -0
- data/lib/csv_decision/dictionary.rb +180 -0
- data/lib/csv_decision/header.rb +83 -0
- data/lib/csv_decision/index.rb +107 -0
- data/lib/csv_decision/input.rb +121 -0
- data/lib/csv_decision/load.rb +36 -0
- data/lib/csv_decision/matchers/constant.rb +74 -0
- data/lib/csv_decision/matchers/function.rb +56 -0
- data/lib/csv_decision/matchers/guard.rb +142 -0
- data/lib/csv_decision/matchers/numeric.rb +44 -0
- data/lib/csv_decision/matchers/pattern.rb +94 -0
- data/lib/csv_decision/matchers/range.rb +95 -0
- data/lib/csv_decision/matchers/symbol.rb +149 -0
- data/lib/csv_decision/matchers.rb +220 -0
- data/lib/csv_decision/options.rb +124 -0
- data/lib/csv_decision/parse.rb +165 -0
- data/lib/csv_decision/paths.rb +78 -0
- data/lib/csv_decision/result.rb +204 -0
- data/lib/csv_decision/scan.rb +117 -0
- data/lib/csv_decision/scan_row.rb +142 -0
- data/lib/csv_decision/table.rb +101 -0
- data/lib/csv_decision/validate.rb +85 -0
- data/lib/csv_decision.rb +45 -0
- data/spec/csv_decision/columns_spec.rb +251 -0
- data/spec/csv_decision/constant_spec.rb +36 -0
- data/spec/csv_decision/data_spec.rb +50 -0
- data/spec/csv_decision/decision_spec.rb +19 -0
- data/spec/csv_decision/examples_spec.rb +242 -0
- data/spec/csv_decision/index_spec.rb +58 -0
- data/spec/csv_decision/input_spec.rb +55 -0
- data/spec/csv_decision/load_spec.rb +28 -0
- data/spec/csv_decision/matchers/function_spec.rb +82 -0
- data/spec/csv_decision/matchers/guard_spec.rb +170 -0
- data/spec/csv_decision/matchers/numeric_spec.rb +47 -0
- data/spec/csv_decision/matchers/pattern_spec.rb +183 -0
- data/spec/csv_decision/matchers/range_spec.rb +70 -0
- data/spec/csv_decision/matchers/symbol_spec.rb +67 -0
- data/spec/csv_decision/options_spec.rb +94 -0
- data/spec/csv_decision/parse_spec.rb +44 -0
- data/spec/csv_decision/table_spec.rb +683 -0
- data/spec/csv_decision_spec.rb +7 -0
- data/spec/data/invalid/empty.csv +0 -0
- data/spec/data/invalid/invalid_header1.csv +4 -0
- data/spec/data/invalid/invalid_header2.csv +4 -0
- data/spec/data/invalid/invalid_header3.csv +4 -0
- data/spec/data/invalid/invalid_header4.csv +4 -0
- data/spec/data/valid/benchmark_regexp.csv +10 -0
- data/spec/data/valid/index_example.csv +13 -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_file1.csv +5 -0
- data/spec/data/valid/options_in_file2.csv +5 -0
- data/spec/data/valid/options_in_file3.csv +13 -0
- data/spec/data/valid/regular_expressions.csv +11 -0
- data/spec/data/valid/simple_constants.csv +5 -0
- data/spec/data/valid/simple_example.csv +10 -0
- data/spec/data/valid/valid.csv +4 -0
- data/spec/spec_helper.rb +106 -0
- metadata +352 -0
@@ -0,0 +1,621 @@
|
|
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
|
8
|
+
|
9
|
+
— 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";
|
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 (C)</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">CSVDecision</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
|
63
|
+
|
64
|
+
|
65
|
+
|
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.rb<span class="defines">,<br />
|
82
|
+
lib/csv_decision/data.rb,<br /> lib/csv_decision/load.rb,<br /> lib/csv_decision/scan.rb,<br /> lib/csv_decision/index.rb,<br /> lib/csv_decision/input.rb,<br /> lib/csv_decision/parse.rb,<br /> lib/csv_decision/paths.rb,<br /> lib/csv_decision/table.rb,<br /> lib/csv_decision/header.rb,<br /> lib/csv_decision/result.rb,<br /> lib/csv_decision/columns.rb,<br /> lib/csv_decision/options.rb,<br /> lib/csv_decision/decision.rb,<br /> lib/csv_decision/defaults.rb,<br /> lib/csv_decision/matchers.rb,<br /> lib/csv_decision/scan_row.rb,<br /> lib/csv_decision/validate.rb,<br /> lib/csv_decision/dictionary.rb,<br /> lib/csv_decision/matchers/guard.rb,<br /> lib/csv_decision/matchers/range.rb,<br /> lib/csv_decision/matchers/symbol.rb,<br /> lib/csv_decision/matchers/numeric.rb,<br /> lib/csv_decision/matchers/pattern.rb,<br /> lib/csv_decision/matchers/constant.rb,<br /> lib/csv_decision/matchers/function.rb</span>
|
83
|
+
</dd>
|
84
|
+
</dl>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Overview</h2><div class="docstring">
|
89
|
+
<div class="discussion">
|
90
|
+
|
91
|
+
<p>CSV Decision: CSV based Ruby decision tables. Created December 2017. See
|
92
|
+
LICENSE and README.md for details.</p>
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
<div class="tags">
|
98
|
+
|
99
|
+
<p class="tag_title">Author:</p>
|
100
|
+
<ul class="author">
|
101
|
+
|
102
|
+
<li>
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<div class='inline'>
|
109
|
+
<p>Brett Vickers <brett@phillips-vickers.com></p>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
</li>
|
113
|
+
|
114
|
+
</ul>
|
115
|
+
|
116
|
+
</div><h2>Defined Under Namespace</h2>
|
117
|
+
<p class="children">
|
118
|
+
|
119
|
+
|
120
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="CSVDecision/Data.html" title="CSVDecision::Data (module)">Data</a></span>, <span class='object_link'><a href="CSVDecision/Defaults.html" title="CSVDecision::Defaults (module)">Defaults</a></span>, <span class='object_link'><a href="CSVDecision/Dictionary.html" title="CSVDecision::Dictionary (module)">Dictionary</a></span>, <span class='object_link'><a href="CSVDecision/Header.html" title="CSVDecision::Header (module)">Header</a></span>, <span class='object_link'><a href="CSVDecision/Input.html" title="CSVDecision::Input (module)">Input</a></span>, <span class='object_link'><a href="CSVDecision/Load.html" title="CSVDecision::Load (module)">Load</a></span>, <span class='object_link'><a href="CSVDecision/Options.html" title="CSVDecision::Options (module)">Options</a></span>, <span class='object_link'><a href="CSVDecision/Parse.html" title="CSVDecision::Parse (module)">Parse</a></span>, <span class='object_link'><a href="CSVDecision/Validate.html" title="CSVDecision::Validate (module)">Validate</a></span>
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="CSVDecision/CellValidationError.html" title="CSVDecision::CellValidationError (class)">CellValidationError</a></span>, <span class='object_link'><a href="CSVDecision/Columns.html" title="CSVDecision::Columns (class)">Columns</a></span>, <span class='object_link'><a href="CSVDecision/Decision.html" title="CSVDecision::Decision (class)">Decision</a></span>, <span class='object_link'><a href="CSVDecision/Error.html" title="CSVDecision::Error (class)">Error</a></span>, <span class='object_link'><a href="CSVDecision/FileError.html" title="CSVDecision::FileError (class)">FileError</a></span>, <span class='object_link'><a href="CSVDecision/Index.html" title="CSVDecision::Index (class)">Index</a></span>, <span class='object_link'><a href="CSVDecision/Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span>, <span class='object_link'><a href="CSVDecision/Paths.html" title="CSVDecision::Paths (class)">Paths</a></span>, <span class='object_link'><a href="CSVDecision/Result.html" title="CSVDecision::Result (class)">Result</a></span>, <span class='object_link'><a href="CSVDecision/Scan.html" title="CSVDecision::Scan (class)">Scan</a></span>, <span class='object_link'><a href="CSVDecision/ScanRow.html" title="CSVDecision::ScanRow (class)">ScanRow</a></span>, <span class='object_link'><a href="CSVDecision/Table.html" title="CSVDecision::Table (class)">Table</a></span>, <span class='object_link'><a href="CSVDecision/TableValidationError.html" title="CSVDecision::TableValidationError (class)">TableValidationError</a></span>
|
125
|
+
|
126
|
+
|
127
|
+
</p>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
<h2>
|
137
|
+
Class Method Summary
|
138
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
139
|
+
</h2>
|
140
|
+
|
141
|
+
<ul class="summary">
|
142
|
+
|
143
|
+
<li class="public ">
|
144
|
+
<span class="summary_signature">
|
145
|
+
|
146
|
+
<a href="#load-class_method" title="load (class method)">.<strong>load</strong>(path, options = {}) ⇒ Hash{Symbol=><CSVDecision::Table>} </a>
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
</span>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
<span class="summary_desc"><div class='inline'>
|
161
|
+
<p>Load all the CSV files located in the designated folder path.</p>
|
162
|
+
</div></span>
|
163
|
+
|
164
|
+
</li>
|
165
|
+
|
166
|
+
|
167
|
+
<li class="public ">
|
168
|
+
<span class="summary_signature">
|
169
|
+
|
170
|
+
<a href="#parse-class_method" title="parse (class method)">.<strong>parse</strong>(data, options = {}) ⇒ CSVDecision::Table </a>
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
</span>
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<span class="summary_desc"><div class='inline'>
|
185
|
+
<p>Builds a decision table from the input data - which may either be a file,
|
186
|
+
CSV string or an array of arrays.</p>
|
187
|
+
</div></span>
|
188
|
+
|
189
|
+
</li>
|
190
|
+
|
191
|
+
|
192
|
+
<li class="public ">
|
193
|
+
<span class="summary_signature">
|
194
|
+
|
195
|
+
<a href="#root-class_method" title="root (class method)">.<strong>root</strong> ⇒ String </a>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
</span>
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
<span class="summary_desc"><div class='inline'>
|
210
|
+
<p>Gem project's root directory.</p>
|
211
|
+
</div></span>
|
212
|
+
|
213
|
+
</li>
|
214
|
+
|
215
|
+
|
216
|
+
</ul>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<div id="class_method_details" class="method_details_list">
|
222
|
+
<h2>Class Method Details</h2>
|
223
|
+
|
224
|
+
|
225
|
+
<div class="method_details first">
|
226
|
+
<h3 class="signature first" id="load-class_method">
|
227
|
+
|
228
|
+
.<strong>load</strong>(path, options = {}) ⇒ <tt>Hash{Symbol=><<span class='object_link'><a href="CSVDecision/Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span>>}</tt>
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
</h3><div class="docstring">
|
235
|
+
<div class="discussion">
|
236
|
+
|
237
|
+
<p>Load all the CSV files located in the designated folder path.</p>
|
238
|
+
|
239
|
+
|
240
|
+
</div>
|
241
|
+
</div>
|
242
|
+
<div class="tags">
|
243
|
+
<p class="tag_title">Parameters:</p>
|
244
|
+
<ul class="param">
|
245
|
+
|
246
|
+
<li>
|
247
|
+
|
248
|
+
<span class='name'>path</span>
|
249
|
+
|
250
|
+
|
251
|
+
<span class='type'>(<tt>Pathname</tt>)</span>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
—
|
256
|
+
<div class='inline'>
|
257
|
+
<p>Directory containing CSV decision table files.</p>
|
258
|
+
</div>
|
259
|
+
|
260
|
+
</li>
|
261
|
+
|
262
|
+
<li>
|
263
|
+
|
264
|
+
<span class='name'>options</span>
|
265
|
+
|
266
|
+
|
267
|
+
<span class='type'>(<tt>Hash{Symbol=>Object}</tt>)</span>
|
268
|
+
|
269
|
+
|
270
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
271
|
+
|
272
|
+
|
273
|
+
—
|
274
|
+
<div class='inline'>
|
275
|
+
<p>Options hash controlling how the table is parsed and interpreted.</p>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
</li>
|
279
|
+
|
280
|
+
</ul>
|
281
|
+
|
282
|
+
<p class="tag_title">Returns:</p>
|
283
|
+
<ul class="return">
|
284
|
+
|
285
|
+
<li>
|
286
|
+
|
287
|
+
|
288
|
+
<span class='type'>(<tt>Hash{Symbol=><<span class='object_link'><a href="CSVDecision/Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span>>}</tt>)</span>
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
—
|
293
|
+
<div class='inline'>
|
294
|
+
<p>Hash of decision tables keyed by the CSV file's symbolized base name.</p>
|
295
|
+
</div>
|
296
|
+
|
297
|
+
</li>
|
298
|
+
|
299
|
+
</ul>
|
300
|
+
<p class="tag_title">Raises:</p>
|
301
|
+
<ul class="raise">
|
302
|
+
|
303
|
+
<li>
|
304
|
+
|
305
|
+
|
306
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
—
|
311
|
+
<div class='inline'>
|
312
|
+
<p>Invalid path name or folder.</p>
|
313
|
+
</div>
|
314
|
+
|
315
|
+
</li>
|
316
|
+
|
317
|
+
</ul>
|
318
|
+
|
319
|
+
</div><table class="source_code">
|
320
|
+
<tr>
|
321
|
+
<td>
|
322
|
+
<pre class="lines">
|
323
|
+
|
324
|
+
|
325
|
+
15
|
326
|
+
16
|
327
|
+
17</pre>
|
328
|
+
</td>
|
329
|
+
<td>
|
330
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/load.rb', line 15</span>
|
331
|
+
|
332
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
333
|
+
<span class='const'><span class='object_link'><a href="CSVDecision/Load.html" title="CSVDecision::Load (module)">Load</a></span></span><span class='period'>.</span><span class='id identifier rubyid_path'><span class='object_link'><a href="CSVDecision/Load.html#path-class_method" title="CSVDecision::Load.path (method)">path</a></span></span><span class='lparen'>(</span><span class='label'>path:</span> <span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
334
|
+
<span class='kw'>end</span></pre>
|
335
|
+
</td>
|
336
|
+
</tr>
|
337
|
+
</table>
|
338
|
+
</div>
|
339
|
+
|
340
|
+
<div class="method_details ">
|
341
|
+
<h3 class="signature " id="parse-class_method">
|
342
|
+
|
343
|
+
.<strong>parse</strong>(data, options = {}) ⇒ <tt><span class='object_link'><a href="CSVDecision/Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span></tt>
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
</h3><div class="docstring">
|
350
|
+
<div class="discussion">
|
351
|
+
|
352
|
+
<p>Builds a decision table from the input data - which may either be a file,
|
353
|
+
CSV string or an array of arrays.</p>
|
354
|
+
|
355
|
+
|
356
|
+
</div>
|
357
|
+
</div>
|
358
|
+
<div class="tags">
|
359
|
+
|
360
|
+
<div class="examples">
|
361
|
+
<p class="tag_title">Examples:</p>
|
362
|
+
|
363
|
+
|
364
|
+
<p class="example_title"><div class='inline'>
|
365
|
+
<p>Simple Example</p>
|
366
|
+
</div></p>
|
367
|
+
|
368
|
+
<pre class="example code"><code>If you have cloned the gem's git repo, then you can run:
|
369
|
+
table = CSVDecision.parse(Pathname('spec/data/valid/simple_example.csv'))
|
370
|
+
#=> CSVDecision::Table
|
371
|
+
table.decide(topic: 'finance', region: 'Europe') #=> team_member: 'Donald'</code></pre>
|
372
|
+
|
373
|
+
</div>
|
374
|
+
<p class="tag_title">Parameters:</p>
|
375
|
+
<ul class="param">
|
376
|
+
|
377
|
+
<li>
|
378
|
+
|
379
|
+
<span class='name'>data</span>
|
380
|
+
|
381
|
+
|
382
|
+
<span class='type'>(<tt>Pathname</tt>, <tt>File</tt>, <tt>Array<Array<String>></tt>, <tt>String</tt>)</span>
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
—
|
387
|
+
<div class='inline'>
|
388
|
+
<p>input data given as a CSV file, array of arrays or CSV string.</p>
|
389
|
+
</div>
|
390
|
+
|
391
|
+
</li>
|
392
|
+
|
393
|
+
<li>
|
394
|
+
|
395
|
+
<span class='name'>options</span>
|
396
|
+
|
397
|
+
|
398
|
+
<span class='type'>(<tt>Hash{Symbol=>Object}</tt>)</span>
|
399
|
+
|
400
|
+
|
401
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
402
|
+
|
403
|
+
|
404
|
+
—
|
405
|
+
<div class='inline'>
|
406
|
+
<p>Options hash controlling how the table is parsed and interpreted.</p>
|
407
|
+
</div>
|
408
|
+
|
409
|
+
</li>
|
410
|
+
|
411
|
+
</ul>
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
<p class="tag_title">Options Hash (<tt>options</tt>):</p>
|
419
|
+
<ul class="option">
|
420
|
+
|
421
|
+
<li>
|
422
|
+
<span class="name">:first_match</span>
|
423
|
+
<span class="type">(<tt>Boolean</tt>)</span>
|
424
|
+
<span class="default">
|
425
|
+
|
426
|
+
</span>
|
427
|
+
|
428
|
+
— <div class='inline'>
|
429
|
+
<p>Stop scanning after finding the first row match.</p>
|
430
|
+
</div>
|
431
|
+
|
432
|
+
</li>
|
433
|
+
|
434
|
+
<li>
|
435
|
+
<span class="name">:regexp_implicit</span>
|
436
|
+
<span class="type">(<tt>Boolean</tt>)</span>
|
437
|
+
<span class="default">
|
438
|
+
|
439
|
+
</span>
|
440
|
+
|
441
|
+
— <div class='inline'>
|
442
|
+
<p>Make regular expressions implicit rather than requiring the comparator =~.
|
443
|
+
(Use with care.)</p>
|
444
|
+
</div>
|
445
|
+
|
446
|
+
</li>
|
447
|
+
|
448
|
+
<li>
|
449
|
+
<span class="name">:text_only</span>
|
450
|
+
<span class="type">(<tt>Boolean</tt>)</span>
|
451
|
+
<span class="default">
|
452
|
+
|
453
|
+
</span>
|
454
|
+
|
455
|
+
— <div class='inline'>
|
456
|
+
<p>All cells treated as simple strings by turning off all special matchers.</p>
|
457
|
+
</div>
|
458
|
+
|
459
|
+
</li>
|
460
|
+
|
461
|
+
<li>
|
462
|
+
<span class="name">:matchers</span>
|
463
|
+
<span class="type">(<tt>Array<<span class='object_link'><a href="CSVDecision/Matchers/Matcher.html" title="CSVDecision::Matchers::Matcher (class)">Matchers::Matcher</a></span>></tt>)</span>
|
464
|
+
<span class="default">
|
465
|
+
|
466
|
+
</span>
|
467
|
+
|
468
|
+
— <div class='inline'>
|
469
|
+
<p>May be used to control the inclusion and ordering of special matchers.
|
470
|
+
(Advanced feature, use with care.)</p>
|
471
|
+
</div>
|
472
|
+
|
473
|
+
</li>
|
474
|
+
|
475
|
+
</ul>
|
476
|
+
|
477
|
+
|
478
|
+
<p class="tag_title">Returns:</p>
|
479
|
+
<ul class="return">
|
480
|
+
|
481
|
+
<li>
|
482
|
+
|
483
|
+
|
484
|
+
<span class='type'>(<tt><span class='object_link'><a href="CSVDecision/Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span></tt>)</span>
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
—
|
489
|
+
<div class='inline'>
|
490
|
+
<p>Resulting decision table.</p>
|
491
|
+
</div>
|
492
|
+
|
493
|
+
</li>
|
494
|
+
|
495
|
+
</ul>
|
496
|
+
<p class="tag_title">Raises:</p>
|
497
|
+
<ul class="raise">
|
498
|
+
|
499
|
+
<li>
|
500
|
+
|
501
|
+
|
502
|
+
<span class='type'>(<tt><span class='object_link'><a href="CSVDecision/CellValidationError.html" title="CSVDecision::CellValidationError (class)">CSVDecision::CellValidationError</a></span></tt>)</span>
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
—
|
507
|
+
<div class='inline'>
|
508
|
+
<p>Table parsing cell validation error.</p>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
</li>
|
512
|
+
|
513
|
+
<li>
|
514
|
+
|
515
|
+
|
516
|
+
<span class='type'>(<tt><span class='object_link'><a href="CSVDecision/FileError.html" title="CSVDecision::FileError (class)">CSVDecision::FileError</a></span></tt>)</span>
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
—
|
521
|
+
<div class='inline'>
|
522
|
+
<p>Table parsing error for a named CSV file.</p>
|
523
|
+
</div>
|
524
|
+
|
525
|
+
</li>
|
526
|
+
|
527
|
+
</ul>
|
528
|
+
|
529
|
+
</div><table class="source_code">
|
530
|
+
<tr>
|
531
|
+
<td>
|
532
|
+
<pre class="lines">
|
533
|
+
|
534
|
+
|
535
|
+
47
|
536
|
+
48
|
537
|
+
49</pre>
|
538
|
+
</td>
|
539
|
+
<td>
|
540
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/parse.rb', line 47</span>
|
541
|
+
|
542
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
543
|
+
<span class='const'><span class='object_link'><a href="CSVDecision/Parse.html" title="CSVDecision::Parse (module)">Parse</a></span></span><span class='period'>.</span><span class='id identifier rubyid_table'><span class='object_link'><a href="CSVDecision/Parse.html#table-class_method" title="CSVDecision::Parse.table (method)">table</a></span></span><span class='lparen'>(</span><span class='label'>data:</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='const'><span class='object_link'><a href="CSVDecision/Options.html" title="CSVDecision::Options (module)">Options</a></span></span><span class='period'>.</span><span class='id identifier rubyid_normalize'><span class='object_link'><a href="CSVDecision/Options.html#normalize-class_method" title="CSVDecision::Options.normalize (method)">normalize</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
544
|
+
<span class='kw'>end</span></pre>
|
545
|
+
</td>
|
546
|
+
</tr>
|
547
|
+
</table>
|
548
|
+
</div>
|
549
|
+
|
550
|
+
<div class="method_details ">
|
551
|
+
<h3 class="signature " id="root-class_method">
|
552
|
+
|
553
|
+
.<strong>root</strong> ⇒ <tt>String</tt>
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
</h3><div class="docstring">
|
560
|
+
<div class="discussion">
|
561
|
+
|
562
|
+
<p>Returns gem project's root directory</p>
|
563
|
+
|
564
|
+
|
565
|
+
</div>
|
566
|
+
</div>
|
567
|
+
<div class="tags">
|
568
|
+
|
569
|
+
<p class="tag_title">Returns:</p>
|
570
|
+
<ul class="return">
|
571
|
+
|
572
|
+
<li>
|
573
|
+
|
574
|
+
|
575
|
+
<span class='type'>(<tt>String</tt>)</span>
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
—
|
580
|
+
<div class='inline'>
|
581
|
+
<p>gem project's root directory</p>
|
582
|
+
</div>
|
583
|
+
|
584
|
+
</li>
|
585
|
+
|
586
|
+
</ul>
|
587
|
+
|
588
|
+
</div><table class="source_code">
|
589
|
+
<tr>
|
590
|
+
<td>
|
591
|
+
<pre class="lines">
|
592
|
+
|
593
|
+
|
594
|
+
12
|
595
|
+
13
|
596
|
+
14</pre>
|
597
|
+
</td>
|
598
|
+
<td>
|
599
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision.rb', line 12</span>
|
600
|
+
|
601
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_root'><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">root</a></span></span>
|
602
|
+
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span> <span class='id identifier rubyid___dir__'>__dir__</span>
|
603
|
+
<span class='kw'>end</span></pre>
|
604
|
+
</td>
|
605
|
+
</tr>
|
606
|
+
</table>
|
607
|
+
</div>
|
608
|
+
|
609
|
+
</div>
|
610
|
+
|
611
|
+
</div>
|
612
|
+
|
613
|
+
<div id="footer">
|
614
|
+
Generated on Sun Feb 11 10:26:07 2018 by
|
615
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
616
|
+
0.9.12 (ruby-2.4.0).
|
617
|
+
</div>
|
618
|
+
|
619
|
+
</div>
|
620
|
+
</body>
|
621
|
+
</html>
|