csv_decision2 0.5.1 → 0.5.2
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/Dockerfile +1 -1
- data/README.md +16 -16
- data/benchmarks/rufus_decision.rb +5 -7
- data/csv_decision2.gemspec +2 -2
- data/doc/CSVDecision/CellValidationError.html +117 -110
- data/doc/CSVDecision/Columns/Default.html +537 -508
- data/doc/CSVDecision/Columns/Dictionary.html +729 -686
- data/doc/CSVDecision/Columns/Entry.html +457 -433
- data/doc/CSVDecision/Columns.html +1134 -1051
- data/doc/CSVDecision/Constant.html +205 -191
- data/doc/CSVDecision/Data.html +423 -398
- data/doc/CSVDecision/Decide.html +236 -225
- data/doc/CSVDecision/Decision.html +872 -825
- data/doc/CSVDecision/Defaults.html +243 -230
- data/doc/CSVDecision/Dictionary/Entry.html +1026 -964
- data/doc/CSVDecision/Dictionary.html +377 -355
- data/doc/CSVDecision/Error.html +116 -105
- data/doc/CSVDecision/FileError.html +117 -110
- data/doc/CSVDecision/Function.html +181 -168
- data/doc/CSVDecision/Guard.html +200 -185
- data/doc/CSVDecision/Header.html +557 -523
- data/doc/CSVDecision/Index.html +652 -617
- data/doc/CSVDecision/Input.html +329 -312
- data/doc/CSVDecision/Load.html +232 -220
- data/doc/CSVDecision/Matchers/Constant.html +432 -399
- data/doc/CSVDecision/Matchers/Function.html +451 -415
- data/doc/CSVDecision/Matchers/Guard.html +459 -424
- data/doc/CSVDecision/Matchers/Matcher.html +470 -426
- data/doc/CSVDecision/Matchers/Numeric.html +375 -346
- data/doc/CSVDecision/Matchers/Pattern.html +429 -396
- data/doc/CSVDecision/Matchers/Proc.html +617 -575
- data/doc/CSVDecision/Matchers/Range.html +331 -302
- data/doc/CSVDecision/Matchers/Symbol.html +386 -353
- data/doc/CSVDecision/Matchers.html +1509 -1393
- data/doc/CSVDecision/Numeric.html +201 -188
- data/doc/CSVDecision/Options.html +376 -357
- data/doc/CSVDecision/Parse.html +217 -204
- data/doc/CSVDecision/Paths.html +664 -629
- data/doc/CSVDecision/Result.html +1076 -1005
- data/doc/CSVDecision/Scan/InputHashes.html +305 -288
- data/doc/CSVDecision/Scan.html +262 -249
- data/doc/CSVDecision/ScanRow.html +749 -705
- data/doc/CSVDecision/Symbol.html +204 -191
- data/doc/CSVDecision/Table.html +1391 -1305
- data/doc/CSVDecision/TableValidationError.html +117 -110
- data/doc/CSVDecision/Validate.html +353 -337
- data/doc/CSVDecision.html +623 -552
- data/doc/_index.html +488 -448
- data/doc/class_list.html +250 -45
- data/doc/file.README.html +304 -278
- data/doc/index.html +304 -278
- data/doc/method_list.html +1159 -1017
- data/doc/top-level-namespace.html +79 -75
- data/lib/{csv_decision → csv_decision2}/columns.rb +7 -7
- data/lib/{csv_decision → csv_decision2}/data.rb +1 -1
- data/lib/{csv_decision → csv_decision2}/decision.rb +5 -5
- data/lib/{csv_decision → csv_decision2}/defaults.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/dictionary.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/header.rb +5 -5
- data/lib/{csv_decision → csv_decision2}/index.rb +5 -5
- data/lib/{csv_decision → csv_decision2}/input.rb +3 -3
- data/lib/{csv_decision → csv_decision2}/load.rb +6 -6
- data/lib/{csv_decision → csv_decision2}/matchers/constant.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/matchers/function.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/matchers/guard.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/matchers/numeric.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/matchers/pattern.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/matchers/range.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/matchers/symbol.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/matchers.rb +5 -5
- data/lib/{csv_decision → csv_decision2}/options.rb +3 -3
- data/lib/{csv_decision → csv_decision2}/parse.rb +14 -14
- data/lib/{csv_decision → csv_decision2}/paths.rb +5 -5
- data/lib/{csv_decision → csv_decision2}/result.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/scan.rb +3 -3
- data/lib/{csv_decision → csv_decision2}/scan_row.rb +2 -2
- data/lib/{csv_decision → csv_decision2}/table.rb +8 -8
- data/lib/{csv_decision → csv_decision2}/validate.rb +2 -2
- data/lib/csv_decision2.rb +45 -0
- data/spec/{csv_decision → csv_decision2}/columns_spec.rb +44 -44
- data/spec/{csv_decision → csv_decision2}/constant_spec.rb +4 -4
- data/spec/{csv_decision → csv_decision2}/data_spec.rb +11 -11
- data/spec/{csv_decision → csv_decision2}/decision_spec.rb +6 -6
- data/spec/{csv_decision → csv_decision2}/examples_spec.rb +14 -14
- data/spec/{csv_decision → csv_decision2}/index_spec.rb +8 -8
- data/spec/{csv_decision → csv_decision2}/input_spec.rb +9 -9
- data/spec/{csv_decision → csv_decision2}/load_spec.rb +8 -8
- data/spec/{csv_decision → csv_decision2}/matchers/function_spec.rb +7 -7
- data/spec/{csv_decision → csv_decision2}/matchers/guard_spec.rb +14 -14
- data/spec/{csv_decision → csv_decision2}/matchers/numeric_spec.rb +5 -5
- data/spec/{csv_decision → csv_decision2}/matchers/pattern_spec.rb +6 -6
- data/spec/{csv_decision → csv_decision2}/matchers/range_spec.rb +5 -5
- data/spec/{csv_decision → csv_decision2}/matchers/symbol_spec.rb +6 -6
- data/spec/{csv_decision → csv_decision2}/options_spec.rb +18 -18
- data/spec/csv_decision2/parse_spec.rb +44 -0
- data/spec/{csv_decision → csv_decision2}/table_spec.rb +17 -17
- data/spec/csv_decision2_spec.rb +7 -0
- metadata +64 -64
- data/lib/csv_decision.rb +0 -45
- data/spec/csv_decision/parse_spec.rb +0 -44
- data/spec/csv_decision_spec.rb +0 -7
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<meta
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>
|
|
8
|
+
Top Level Namespace
|
|
9
|
+
|
|
9
10
|
— Documentation by YARD 0.9.12
|
|
10
|
-
|
|
11
|
-
</title>
|
|
11
|
+
|
|
12
|
+
</title>
|
|
12
13
|
|
|
13
14
|
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
|
14
15
|
|
|
15
16
|
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
|
16
17
|
|
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
</script>
|
|
18
|
+
<script type="text/javascript" charset="utf-8">
|
|
19
|
+
pathId = "";
|
|
20
|
+
relpath = '';
|
|
21
|
+
</script>
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
|
@@ -25,71 +26,71 @@
|
|
|
25
26
|
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
|
26
27
|
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
</head>
|
|
30
|
+
|
|
31
|
+
<body>
|
|
32
|
+
<div class="nav_wrap">
|
|
33
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
|
34
|
+
<div id="resizer"></div>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div id="main" tabindex="-1">
|
|
38
|
+
<div id="header">
|
|
39
|
+
<div id="menu">
|
|
40
|
+
|
|
41
|
+
<a href="_index.html">Index</a> »
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
<span class="title">Top Level Namespace</span>
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div id="search">
|
|
49
|
+
|
|
50
|
+
<a class="full_list_link" id="class_list_link" href="class_list.html">
|
|
51
|
+
|
|
52
|
+
<svg width="24" height="24">
|
|
53
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
54
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
55
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
56
|
+
</svg>
|
|
57
|
+
</a>
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
<div class="clear"></div>
|
|
33
61
|
</div>
|
|
34
62
|
|
|
35
|
-
<div id="
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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>
|
|
63
|
+
<div id="content">
|
|
64
|
+
<h1>Top Level Namespace
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
</h1>
|
|
69
|
+
<div class="box_info">
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
60
81
|
</div>
|
|
61
82
|
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
</h1>
|
|
67
|
-
<div class="box_info">
|
|
68
|
-
|
|
83
|
+
<h2>Defined Under Namespace</h2>
|
|
84
|
+
<p class="children">
|
|
69
85
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
86
|
|
|
76
|
-
|
|
87
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="CSVDecision2.html"
|
|
88
|
+
title="CSVDecision (module)">CSVDecision</a></span>
|
|
77
89
|
|
|
78
|
-
|
|
79
|
-
</div>
|
|
80
90
|
|
|
81
|
-
<h2>Defined Under Namespace</h2>
|
|
82
|
-
<p class="children">
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="CSVDecision.html" title="CSVDecision (module)">CSVDecision</a></span>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</p>
|
|
91
91
|
|
|
92
92
|
|
|
93
|
+
</p>
|
|
93
94
|
|
|
94
95
|
|
|
95
96
|
|
|
@@ -97,14 +98,17 @@
|
|
|
97
98
|
|
|
98
99
|
|
|
99
100
|
|
|
100
|
-
</div>
|
|
101
101
|
|
|
102
|
-
<div id="footer">
|
|
103
|
-
Generated on Sun Feb 11 10:26:07 2018 by
|
|
104
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
105
|
-
0.9.12 (ruby-2.4.0).
|
|
106
|
-
</div>
|
|
107
102
|
|
|
108
103
|
</div>
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
|
|
105
|
+
<div id="footer">
|
|
106
|
+
Generated on Sun Feb 11 10:26:07 2018 by
|
|
107
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
108
|
+
0.9.12 (ruby-2.4.0).
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
</div>
|
|
112
|
+
</body>
|
|
113
|
+
|
|
114
|
+
</html>
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Dictionary of all this table's columns - inputs, outputs etc.
|
|
9
9
|
# @api private
|
|
10
10
|
class Columns
|
|
11
|
-
# @param columns [
|
|
11
|
+
# @param columns [CSVDecision2::Columns] Table's columns dictionary.
|
|
12
12
|
# @param row [Array] Data row.
|
|
13
13
|
# @return [void]
|
|
14
14
|
def self.outs_dictionary(columns:, row:)
|
|
@@ -17,14 +17,14 @@ module CSVDecision
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# @param columns [
|
|
20
|
+
# @param columns [CSVDecision2::Columns] Table's columns dictionary.
|
|
21
21
|
# @param row [Array] Data row.
|
|
22
22
|
# @return [void]
|
|
23
23
|
def self.ins_dictionary(columns:, row:)
|
|
24
24
|
row.each { |cell| ins_cell_dictionary(columns: columns, cell: cell) }
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
# @param columns [
|
|
27
|
+
# @param columns [CSVDecision2::Columns] Table's columns dictionary.
|
|
28
28
|
# @param cell [Object] Data row cell.
|
|
29
29
|
# @return [void]
|
|
30
30
|
def self.ins_cell_dictionary(columns:, cell:)
|
|
@@ -86,7 +86,7 @@ module CSVDecision
|
|
|
86
86
|
|
|
87
87
|
def self.add_ins_symbols(columns:, cell:)
|
|
88
88
|
Array(cell.symbols).each do |symbol|
|
|
89
|
-
|
|
89
|
+
CSVDecision2::Dictionary.add_name(columns: columns, name: symbol)
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
private_class_method :add_ins_symbols
|
|
@@ -184,9 +184,9 @@ module CSVDecision
|
|
|
184
184
|
raise TableValidationError, 'table has no header row' unless row
|
|
185
185
|
|
|
186
186
|
# Build a dictionary of all valid data columns from the header row.
|
|
187
|
-
@dictionary =
|
|
187
|
+
@dictionary = CSVDecision2::Dictionary.build(header: row, dictionary: Dictionary.new)
|
|
188
188
|
|
|
189
189
|
freeze
|
|
190
190
|
end
|
|
191
191
|
end
|
|
192
|
-
end
|
|
192
|
+
end
|
|
@@ -6,7 +6,7 @@ require 'csv'
|
|
|
6
6
|
# Created December 2017.
|
|
7
7
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
8
8
|
# See LICENSE and README.md for details..
|
|
9
|
-
module
|
|
9
|
+
module CSVDecision2
|
|
10
10
|
# All cells starting with this character are comments, and treated as a blank cell.
|
|
11
11
|
COMMENT_CHARACTER = '#'
|
|
12
12
|
private_constant :COMMENT_CHARACTER
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Accumulate the matching row(s) and calculate the final result.
|
|
9
9
|
# @api private
|
|
10
10
|
class Decision
|
|
11
11
|
# Main method for making decisions without a path.
|
|
12
12
|
#
|
|
13
|
-
# @param table [
|
|
13
|
+
# @param table [CSVDecision2::Table] Decision table.
|
|
14
14
|
# @param input [Hash] Input hash (keys may or may not be symbolized)
|
|
15
15
|
# @param symbolize_keys [Boolean] Set to false if keys are symbolized and it's
|
|
16
16
|
# OK to mutate the input hash. Otherwise a copy of the input hash is symbolized.
|
|
@@ -27,10 +27,10 @@ module CSVDecision
|
|
|
27
27
|
# @return [Boolean] True if a first match decision table.
|
|
28
28
|
attr_reader :first_match
|
|
29
29
|
|
|
30
|
-
# @return [
|
|
30
|
+
# @return [CSVDecision2::Table] Decision table object.
|
|
31
31
|
attr_reader :table
|
|
32
32
|
|
|
33
|
-
# @param table [
|
|
33
|
+
# @param table [CSVDecision2::Table] Decision table being processed.
|
|
34
34
|
def initialize(table:)
|
|
35
35
|
# The result object is a hash of values, and each value will be an array if this is
|
|
36
36
|
# a multi-row result for the +first_match: false+ option.
|
|
@@ -193,4 +193,4 @@ module CSVDecision
|
|
|
193
193
|
result
|
|
194
194
|
end
|
|
195
195
|
end
|
|
196
|
-
end
|
|
196
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers.
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Parse the default row beneath the header row if present
|
|
9
9
|
# @api private
|
|
10
10
|
module Defaults
|
|
@@ -44,4 +44,4 @@ module CSVDecision
|
|
|
44
44
|
end
|
|
45
45
|
private_class_method :parse_cell
|
|
46
46
|
end
|
|
47
|
-
end
|
|
47
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Parse the CSV file's header row. These methods are only required at table load time.
|
|
9
9
|
# @api private
|
|
10
10
|
module Dictionary
|
|
@@ -177,4 +177,4 @@ module CSVDecision
|
|
|
177
177
|
end
|
|
178
178
|
private_class_method :input_entry
|
|
179
179
|
end
|
|
180
|
-
end
|
|
180
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Parse the CSV file's header row. These methods are only required at table load time.
|
|
9
9
|
# @api private
|
|
10
10
|
module Header
|
|
@@ -53,12 +53,12 @@ module CSVDecision
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# Parse the header row, and the defaults row if present.
|
|
56
|
-
# @param table [
|
|
56
|
+
# @param table [CSVDecision2::Table] Decision table being parsed.
|
|
57
57
|
# @param matchers [Array<Matchers::Matcher>] Array of special cell matchers.
|
|
58
|
-
# @return [
|
|
58
|
+
# @return [CSVDecision2::Columns] Table columns object.
|
|
59
59
|
def self.parse(table:, matchers:)
|
|
60
60
|
# Parse the header row
|
|
61
|
-
table.columns =
|
|
61
|
+
table.columns = CSVDecision2::Columns.new(table)
|
|
62
62
|
|
|
63
63
|
# Parse the defaults row if present
|
|
64
64
|
return table.columns if table.columns.defaults.blank?
|
|
@@ -80,4 +80,4 @@ module CSVDecision
|
|
|
80
80
|
end
|
|
81
81
|
private_class_method :empty_columns?
|
|
82
82
|
end
|
|
83
|
-
end
|
|
83
|
+
end
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers.
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Build an index for a decision table with one or more input columns
|
|
9
9
|
# designated as keys
|
|
10
10
|
# @api private
|
|
11
11
|
class Index
|
|
12
12
|
# Build the index on the designated number of input columns.
|
|
13
13
|
#
|
|
14
|
-
# @param table [
|
|
15
|
-
# @return [
|
|
14
|
+
# @param table [CSVDecision2::Table] Decision table being indexed.
|
|
15
|
+
# @return [CSVDecision2::Index] The built index.
|
|
16
16
|
def self.build(table:)
|
|
17
17
|
# Do we even have an index?
|
|
18
18
|
key_cols = index_columns(columns: table.columns.ins)
|
|
@@ -74,7 +74,7 @@ module CSVDecision
|
|
|
74
74
|
# @return [Array<Integer>] Array of column indices
|
|
75
75
|
attr_reader :columns
|
|
76
76
|
|
|
77
|
-
# @param table [
|
|
77
|
+
# @param table [CSVDecision2::Table] Decision table.
|
|
78
78
|
# @param columns [Array<Index>] Array of column indexes to be indexed.
|
|
79
79
|
def initialize(table:, columns:)
|
|
80
80
|
@columns = columns
|
|
@@ -104,4 +104,4 @@ module CSVDecision
|
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
-
end
|
|
107
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Parse the input hash.
|
|
9
9
|
# @api private
|
|
10
10
|
module Input
|
|
@@ -20,7 +20,7 @@ module CSVDecision
|
|
|
20
20
|
parsed_input
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
# @param table [
|
|
23
|
+
# @param table [CSVDecision2::Table] Decision table.
|
|
24
24
|
# @param input [Hash] Input hash (keys may or may not be symbolized)
|
|
25
25
|
# @return [Hash{Symbol=>Object}]
|
|
26
26
|
def self.parse_data(table:, input:)
|
|
@@ -118,4 +118,4 @@ module CSVDecision
|
|
|
118
118
|
end
|
|
119
119
|
private_class_method :eval_default
|
|
120
120
|
end
|
|
121
|
-
end
|
|
121
|
+
end
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Load all the CSV files located in the designated folder path.
|
|
9
9
|
#
|
|
10
10
|
# @param path [Pathname] Directory containing CSV decision table files.
|
|
11
|
-
# @param options (see
|
|
12
|
-
# @return [Hash{Symbol=><
|
|
11
|
+
# @param options (see CSVDecision2.parse)
|
|
12
|
+
# @return [Hash{Symbol=><CSVDecision2::Table>}] Hash of decision tables keyed by the CSV
|
|
13
13
|
# file's symbolized base name.
|
|
14
14
|
# @raise [ArgumentError] Invalid path name or folder.
|
|
15
15
|
def self.load(path, options = {})
|
|
@@ -19,7 +19,7 @@ module CSVDecision
|
|
|
19
19
|
# Load all CSV files located in the specified folder.
|
|
20
20
|
# @api private
|
|
21
21
|
module Load
|
|
22
|
-
# (see
|
|
22
|
+
# (see CSVDecision2.load)
|
|
23
23
|
def self.path(path:, options:)
|
|
24
24
|
raise ArgumentError, 'path argument must be a Pathname' unless path.is_a?(Pathname)
|
|
25
25
|
raise ArgumentError, 'path argument not a valid folder' unless path.directory?
|
|
@@ -27,10 +27,10 @@ module CSVDecision
|
|
|
27
27
|
tables = {}
|
|
28
28
|
Dir[path.join('*.csv')].each do |file_name|
|
|
29
29
|
table_name = File.basename(file_name, '.csv').to_sym
|
|
30
|
-
tables[table_name] =
|
|
30
|
+
tables[table_name] = CSVDecision2.parse(Pathname(file_name), options)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
tables.freeze
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
-
end
|
|
36
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Methods to assign a matcher to data cells
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -71,4 +71,4 @@ module CSVDecision
|
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
|
-
end
|
|
74
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Methods to assign a matcher to data cells
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -53,4 +53,4 @@ module CSVDecision
|
|
|
53
53
|
# end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
|
-
end
|
|
56
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Recognise expressions in table data cells.
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -139,4 +139,4 @@ module CSVDecision
|
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
|
-
end
|
|
142
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Methods to assign a matcher to data cells.
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -41,4 +41,4 @@ module CSVDecision
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
|
-
end
|
|
44
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Methods to assign a matcher to data cells
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -91,4 +91,4 @@ module CSVDecision
|
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
|
-
end
|
|
94
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Methods to assign a matcher to data cells.
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -92,4 +92,4 @@ module CSVDecision
|
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
|
-
end
|
|
95
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Recognise expressions in table data cells.
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -146,4 +146,4 @@ module CSVDecision
|
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
|
-
end
|
|
149
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers.
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Match table data cells against a valid decision table expression or a simple constant.
|
|
9
9
|
# @api private
|
|
10
10
|
class Matchers
|
|
@@ -163,7 +163,7 @@ module CSVDecision
|
|
|
163
163
|
# @return [Array<Matchers::Matcher>] Matchers for the output columns.
|
|
164
164
|
attr_reader :outs
|
|
165
165
|
|
|
166
|
-
# @param options (see
|
|
166
|
+
# @param options (see CSVDecision2.parse)
|
|
167
167
|
def initialize(options)
|
|
168
168
|
matchers = options[:matchers].collect { |klass| klass.new(options) }
|
|
169
169
|
@ins = matchers.select(&:ins?)
|
|
@@ -195,8 +195,8 @@ module CSVDecision
|
|
|
195
195
|
# Determine if the input cell string is recognised by this Matcher.
|
|
196
196
|
#
|
|
197
197
|
# @param cell [String] Data row cell.
|
|
198
|
-
# @return [false,
|
|
199
|
-
# returns the +
|
|
198
|
+
# @return [false, CSVDecision2::Proc] Returns false if this cell is not a match; otherwise
|
|
199
|
+
# returns the +CSVDecision2::Proc+ object indicating if this is a constant or some type of
|
|
200
200
|
# function.
|
|
201
201
|
def matches?(cell); end
|
|
202
202
|
|
|
@@ -217,4 +217,4 @@ module CSVDecision
|
|
|
217
217
|
end
|
|
218
218
|
end
|
|
219
219
|
end
|
|
220
|
-
end
|
|
220
|
+
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Created December 2017.
|
|
5
5
|
# @author Brett Vickers <brett@phillips-vickers.com>
|
|
6
6
|
# See LICENSE and README.md for details.
|
|
7
|
-
module
|
|
7
|
+
module CSVDecision2
|
|
8
8
|
# Validate and normalize the options values supplied.
|
|
9
9
|
# @api private
|
|
10
10
|
module Options
|
|
@@ -20,7 +20,7 @@ module CSVDecision
|
|
|
20
20
|
Matchers::Guard
|
|
21
21
|
].freeze
|
|
22
22
|
|
|
23
|
-
# All valid
|
|
23
|
+
# All valid CSVDecision2::parse options with their default values.
|
|
24
24
|
VALID = {
|
|
25
25
|
first_match: true,
|
|
26
26
|
regexp_implicit: false,
|
|
@@ -121,4 +121,4 @@ module CSVDecision
|
|
|
121
121
|
end
|
|
122
122
|
private_class_method :validate
|
|
123
123
|
end
|
|
124
|
-
end
|
|
124
|
+
end
|