csv_decision 0.0.3 → 0.0.4
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/.codeclimate.yml +2 -0
- data/.gitignore +2 -1
- data/.travis.yml +2 -3
- data/CHANGELOG.md +19 -1
- data/README.md +49 -16
- data/{benchmark.rb → benchmarks/rufus_decision.rb} +1 -1
- data/csv_decision.gemspec +1 -1
- data/doc/CSVDecision/CellValidationError.html +143 -0
- data/doc/CSVDecision/Columns/Default.html +409 -0
- data/doc/CSVDecision/Columns/Dictionary.html +410 -0
- data/doc/CSVDecision/Columns/Entry.html +321 -0
- data/doc/CSVDecision/Columns.html +476 -0
- data/doc/CSVDecision/Constant.html +295 -0
- data/doc/CSVDecision/Data.html +344 -0
- data/doc/CSVDecision/Decide.html +434 -0
- data/doc/CSVDecision/Decision.html +604 -0
- data/doc/CSVDecision/Error.html +139 -0
- data/doc/CSVDecision/FileError.html +143 -0
- data/doc/CSVDecision/Function.html +229 -0
- data/doc/CSVDecision/Header.html +520 -0
- data/doc/CSVDecision/Input.html +305 -0
- data/doc/CSVDecision/Load.html +225 -0
- data/doc/CSVDecision/Matchers/Constant.html +242 -0
- data/doc/CSVDecision/Matchers/Function.html +342 -0
- data/doc/CSVDecision/Matchers/Matcher.html +325 -0
- data/doc/CSVDecision/Matchers/Numeric.html +277 -0
- data/doc/CSVDecision/Matchers/Pattern.html +600 -0
- data/doc/CSVDecision/Matchers/Range.html +413 -0
- data/doc/CSVDecision/Matchers/Symbol.html +280 -0
- data/doc/CSVDecision/Matchers.html +1529 -0
- data/doc/CSVDecision/Numeric.html +259 -0
- data/doc/CSVDecision/Options.html +445 -0
- data/doc/CSVDecision/Parse.html +270 -0
- data/doc/CSVDecision/ScanRow.html +746 -0
- data/doc/CSVDecision/Symbol.html +256 -0
- data/doc/CSVDecision/Table.html +1115 -0
- data/doc/CSVDecision.html +652 -0
- data/doc/_index.html +410 -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 +264 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +264 -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 +683 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/csv_decision/columns.rb +15 -12
- data/lib/csv_decision/constant.rb +54 -0
- data/lib/csv_decision/decide.rb +5 -5
- data/lib/csv_decision/decision.rb +3 -1
- data/lib/csv_decision/function.rb +32 -0
- data/lib/csv_decision/header.rb +27 -18
- data/lib/csv_decision/input.rb +11 -8
- data/lib/csv_decision/matchers/constant.rb +18 -0
- data/lib/csv_decision/matchers/function.rb +11 -44
- data/lib/csv_decision/matchers/numeric.rb +5 -33
- data/lib/csv_decision/matchers/pattern.rb +26 -11
- data/lib/csv_decision/matchers/range.rb +21 -5
- data/lib/csv_decision/matchers/symbol.rb +20 -0
- data/lib/csv_decision/matchers.rb +85 -20
- data/lib/csv_decision/numeric.rb +38 -0
- data/lib/csv_decision/options.rb +36 -27
- data/lib/csv_decision/parse.rb +46 -39
- data/lib/csv_decision/scan_row.rb +19 -7
- data/lib/csv_decision/symbol.rb +73 -0
- data/lib/csv_decision/table.rb +24 -18
- data/lib/csv_decision.rb +25 -18
- data/spec/csv_decision/columns_spec.rb +1 -1
- data/spec/csv_decision/constant_spec.rb +60 -0
- data/spec/csv_decision/examples_spec.rb +119 -0
- data/spec/csv_decision/matchers/function_spec.rb +48 -28
- data/spec/csv_decision/matchers/numeric_spec.rb +4 -41
- data/spec/csv_decision/matchers/range_spec.rb +31 -61
- data/spec/csv_decision/matchers/symbol_spec.rb +65 -0
- data/spec/csv_decision/options_spec.rb +14 -2
- data/spec/csv_decision/parse_spec.rb +10 -0
- data/spec/csv_decision/table_spec.rb +112 -6
- data/spec/data/valid/simple_constants.csv +3 -3
- metadata +62 -7
- data/spec/csv_decision/simple_example_spec.rb +0 -75
- /data/spec/{csv_decision.rb → csv_decision_spec.rb} +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
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::Parse
|
|
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::Parse";
|
|
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 (P)</a> »
|
|
40
|
+
<span class='title'><span class='object_link'><a href="../CSVDecision.html" title="CSVDecision (module)">CSVDecision</a></span></span>
|
|
41
|
+
»
|
|
42
|
+
<span class="title">Parse</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::Parse
|
|
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/parse.rb</dd>
|
|
82
|
+
</dl>
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<h2>Overview</h2><div class="docstring">
|
|
87
|
+
<div class="discussion">
|
|
88
|
+
|
|
89
|
+
<p>Methods to parse the decision table and return CSVDecision::Table object.</p>
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="tags">
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
<h2>
|
|
106
|
+
Class Method Summary
|
|
107
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
108
|
+
</h2>
|
|
109
|
+
|
|
110
|
+
<ul class="summary">
|
|
111
|
+
|
|
112
|
+
<li class="public ">
|
|
113
|
+
<span class="summary_signature">
|
|
114
|
+
|
|
115
|
+
<a href="#table-class_method" title="table (class method)">.<strong>table</strong>(data:, options:) ⇒ CSVDecision::Table </a>
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
</span>
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
<span class="summary_desc"><div class='inline'>
|
|
130
|
+
<p>Parse the CSV file or input data and create a new decision table object.</p>
|
|
131
|
+
</div></span>
|
|
132
|
+
|
|
133
|
+
</li>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
</ul>
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
<div id="class_method_details" class="method_details_list">
|
|
142
|
+
<h2>Class Method Details</h2>
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
<div class="method_details first">
|
|
146
|
+
<h3 class="signature first" id="table-class_method">
|
|
147
|
+
|
|
148
|
+
.<strong>table</strong>(data:, options:) ⇒ <tt><span class='object_link'><a href="Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span></tt>
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
</h3><div class="docstring">
|
|
155
|
+
<div class="discussion">
|
|
156
|
+
|
|
157
|
+
<p>Parse the CSV file or input data and create a new decision table object.</p>
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
<div class="tags">
|
|
163
|
+
<p class="tag_title">Parameters:</p>
|
|
164
|
+
<ul class="param">
|
|
165
|
+
|
|
166
|
+
<li>
|
|
167
|
+
|
|
168
|
+
<span class='name'>data</span>
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
<span class='type'>(<tt>Pathname</tt>, <tt>File</tt>, <tt>Array<Array<String>></tt>, <tt>String</tt>)</span>
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
—
|
|
176
|
+
<div class='inline'>
|
|
177
|
+
<p>input data given as a CSV file, array of arrays or CSV string.</p>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
</li>
|
|
181
|
+
|
|
182
|
+
<li>
|
|
183
|
+
|
|
184
|
+
<span class='name'>options</span>
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
—
|
|
192
|
+
<div class='inline'>
|
|
193
|
+
<p>Options hash supplied by the user.</p>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
</li>
|
|
197
|
+
|
|
198
|
+
</ul>
|
|
199
|
+
|
|
200
|
+
<p class="tag_title">Returns:</p>
|
|
201
|
+
<ul class="return">
|
|
202
|
+
|
|
203
|
+
<li>
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
<span class='type'>(<tt><span class='object_link'><a href="Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span></tt>)</span>
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
—
|
|
211
|
+
<div class='inline'>
|
|
212
|
+
<p>Resulting decision table.</p>
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
</li>
|
|
216
|
+
|
|
217
|
+
</ul>
|
|
218
|
+
|
|
219
|
+
</div><table class="source_code">
|
|
220
|
+
<tr>
|
|
221
|
+
<td>
|
|
222
|
+
<pre class="lines">
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
51
|
|
226
|
+
52
|
|
227
|
+
53
|
|
228
|
+
54
|
|
229
|
+
55
|
|
230
|
+
56
|
|
231
|
+
57
|
|
232
|
+
58
|
|
233
|
+
59
|
|
234
|
+
60
|
|
235
|
+
61
|
|
236
|
+
62</pre>
|
|
237
|
+
</td>
|
|
238
|
+
<td>
|
|
239
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/parse.rb', line 51</span>
|
|
240
|
+
|
|
241
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table'>table</span><span class='lparen'>(</span><span class='label'>data:</span><span class='comma'>,</span> <span class='label'>options:</span><span class='rparen'>)</span>
|
|
242
|
+
<span class='id identifier rubyid_table'>table</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../CSVDecision.html" title="CSVDecision (module)">CSVDecision</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Table.html" title="CSVDecision::Table (class)">Table</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Table.html#initialize-instance_method" title="CSVDecision::Table#initialize (method)">new</a></span></span>
|
|
243
|
+
|
|
244
|
+
<span class='comment'># In most cases the decision table will be loaded from a CSV file.
|
|
245
|
+
</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="Data.html" title="CSVDecision::Data (module)">Data</a></span></span><span class='period'>.</span><span class='id identifier rubyid_input_file?'><span class='object_link'><a href="Data.html#input_file%3F-class_method" title="CSVDecision::Data.input_file? (method)">input_file?</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
|
|
246
|
+
|
|
247
|
+
<span class='id identifier rubyid_parse_table'>parse_table</span><span class='lparen'>(</span><span class='label'>table:</span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>input:</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='label'>options:</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
248
|
+
|
|
249
|
+
<span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
|
250
|
+
<span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="../CSVDecision.html" title="CSVDecision (module)">CSVDecision</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Error.html" title="CSVDecision::Error (class)">Error</a></span></span> <span class='op'>=></span> <span class='id identifier rubyid_exp'>exp</span>
|
|
251
|
+
<span class='id identifier rubyid_raise_error'>raise_error</span><span class='lparen'>(</span><span class='label'>file:</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_file'>file</span><span class='comma'>,</span> <span class='label'>exception:</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
|
|
252
|
+
<span class='kw'>end</span></pre>
|
|
253
|
+
</td>
|
|
254
|
+
</tr>
|
|
255
|
+
</table>
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<div id="footer">
|
|
263
|
+
Generated on Tue Dec 26 18:31:37 2017 by
|
|
264
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
265
|
+
0.9.12 (ruby-2.3.0).
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
</div>
|
|
269
|
+
</body>
|
|
270
|
+
</html>
|