csv_decision 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +112 -93
  4. data/benchmarks/rufus_decision.rb +9 -1
  5. data/csv_decision.gemspec +6 -6
  6. data/doc/CSVDecision.html +54 -90
  7. data/doc/CSVDecision/CellValidationError.html +1 -1
  8. data/doc/CSVDecision/Columns.html +104 -45
  9. data/doc/CSVDecision/Columns/Dictionary.html +40 -24
  10. data/doc/CSVDecision/Columns/Entry.html +209 -22
  11. data/doc/CSVDecision/Constant.html +9 -50
  12. data/doc/CSVDecision/Data.html +182 -47
  13. data/doc/CSVDecision/Decide.html +97 -93
  14. data/doc/CSVDecision/Decision.html +105 -294
  15. data/doc/CSVDecision/Error.html +1 -1
  16. data/doc/CSVDecision/FileError.html +1 -1
  17. data/doc/CSVDecision/Function.html +18 -7
  18. data/doc/CSVDecision/Guard.html +245 -0
  19. data/doc/CSVDecision/Header.html +58 -50
  20. data/doc/CSVDecision/Input.html +20 -12
  21. data/doc/CSVDecision/Load.html +80 -14
  22. data/doc/CSVDecision/Matchers.html +237 -279
  23. data/doc/CSVDecision/Matchers/Constant.html +280 -13
  24. data/doc/CSVDecision/Matchers/Function.html +188 -19
  25. data/doc/CSVDecision/Matchers/Guard.html +568 -0
  26. data/doc/CSVDecision/Matchers/Matcher.html +200 -14
  27. data/doc/CSVDecision/Matchers/Numeric.html +165 -13
  28. data/doc/CSVDecision/Matchers/Pattern.html +56 -163
  29. data/doc/CSVDecision/Matchers/Range.html +48 -37
  30. data/doc/CSVDecision/Matchers/Symbol.html +161 -16
  31. data/doc/CSVDecision/Numeric.html +4 -4
  32. data/doc/CSVDecision/Options.html +53 -55
  33. data/doc/CSVDecision/Parse.html +23 -13
  34. data/doc/CSVDecision/ScanRow.html +461 -73
  35. data/doc/CSVDecision/Symbol.html +4 -4
  36. data/doc/CSVDecision/Table.html +185 -79
  37. data/doc/_index.html +15 -28
  38. data/doc/class_list.html +1 -1
  39. data/doc/file.README.html +105 -82
  40. data/doc/index.html +105 -82
  41. data/doc/method_list.html +137 -113
  42. data/doc/top-level-namespace.html +1 -1
  43. data/lib/csv_decision.rb +2 -5
  44. data/lib/csv_decision/columns.rb +14 -5
  45. data/lib/csv_decision/data.rb +24 -6
  46. data/lib/csv_decision/decide.rb +18 -20
  47. data/lib/csv_decision/decision.rb +106 -42
  48. data/lib/csv_decision/header.rb +44 -23
  49. data/lib/csv_decision/input.rb +4 -2
  50. data/lib/csv_decision/load.rb +7 -3
  51. data/lib/csv_decision/matchers.rb +49 -41
  52. data/lib/csv_decision/matchers/constant.rb +62 -4
  53. data/lib/csv_decision/matchers/function.rb +33 -2
  54. data/lib/csv_decision/matchers/guard.rb +143 -0
  55. data/lib/csv_decision/matchers/numeric.rb +34 -3
  56. data/lib/csv_decision/matchers/pattern.rb +11 -4
  57. data/lib/csv_decision/matchers/range.rb +34 -26
  58. data/lib/csv_decision/matchers/symbol.rb +71 -5
  59. data/lib/csv_decision/options.rb +31 -20
  60. data/lib/csv_decision/parse.rb +28 -9
  61. data/lib/csv_decision/scan_row.rb +79 -13
  62. data/lib/csv_decision/table.rb +34 -23
  63. data/spec/csv_decision/columns_spec.rb +32 -7
  64. data/spec/csv_decision/constant_spec.rb +2 -26
  65. data/spec/csv_decision/decision_spec.rb +0 -9
  66. data/spec/csv_decision/examples_spec.rb +33 -16
  67. data/spec/csv_decision/matchers/function_spec.rb +1 -1
  68. data/spec/csv_decision/matchers/guard_spec.rb +153 -0
  69. data/spec/csv_decision/matchers/numeric_spec.rb +1 -1
  70. data/spec/csv_decision/matchers/pattern_spec.rb +2 -2
  71. data/spec/csv_decision/matchers/range_spec.rb +2 -2
  72. data/spec/csv_decision/matchers/symbol_spec.rb +1 -1
  73. data/spec/csv_decision/options_spec.rb +3 -3
  74. data/spec/csv_decision/table_spec.rb +96 -12
  75. data/spec/data/valid/benchmark_regexp.csv +10 -0
  76. data/spec/data/valid/regular_expressions.csv +11 -0
  77. metadata +14 -9
  78. data/lib/csv_decision/constant.rb +0 -54
  79. data/lib/csv_decision/function.rb +0 -32
  80. data/lib/csv_decision/numeric.rb +0 -38
  81. data/lib/csv_decision/symbol.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28ed8e5952334ed339cc3bd82c84e554009a9438
4
- data.tar.gz: 88b29b7ec01956f7aa57e91121e1c269084c6199
3
+ metadata.gz: 076055f3dd0219da9a4d8aa3d0032fd26e320741
4
+ data.tar.gz: 7ed7716a9f1285b7ed86e3134321e08c829ae7e5
5
5
  SHA512:
6
- metadata.gz: 1baefe11dfe98db1c4c21a937e280378376a48691d8bb801015ad771edc83a9e191cfff20fe76689390bd61da723a9c50414350bca050b8d805e4bae49843e49
7
- data.tar.gz: 36053a5784980eb95c763556d843bc975247ea3fd28e658360d594e181a5a5f511d349215c35570a4ba1fe5eb90838b2a5eed24ca8e0e102a086021026b50c7a
6
+ metadata.gz: b87561c15e01daca109a562f68628b15b6f5d33a725ee527a10ad74d79733e5ffe7a8495735d8a41f18a930a4d906312f566a3c5d22fad182b9d94621a7c141d
7
+ data.tar.gz: be6922a755c26fea0b3d416ee75729bf76eec40a66d386d664aa4e3944be8f311f95d0bdfb004a314da049e2ebe5f0b39987752ccfbe446f01529f7fd62281ba
data/CHANGELOG.md CHANGED
@@ -1,9 +1,17 @@
1
+ ## v0.0.6, 26 December 2017.
2
+ *Additions*
3
+ - Update YARD documentation.
4
+
5
+ ## v0.0.5, 26 December 2017.
6
+ *Additions*
7
+ - Update YARD documentation.
8
+
1
9
  ## v0.0.4, 26 December 2017.
2
10
  *Additions*
3
11
  - Adds symbol expressions for input columns.
4
12
  - Adds non-string constants for output columns.
5
13
  - Support Ruby 2.5.0
6
- - Include yard documentation.
14
+ - Include YARD documentation.
7
15
 
8
16
  *Changes*
9
17
  - Move `benchmark.rb` to `benchmarks` folder and rename to `rufus_decision.rb`
data/README.md CHANGED
@@ -7,7 +7,7 @@ CSV Decision
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/466a6c52e8f6a3840967/maintainability)](https://codeclimate.com/github/bpvickers/csv_decision/maintainability)
8
8
  [![License](http://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)
9
9
 
10
- ### CSV based Ruby decision tables (a lightweight Hash transformation gem)
10
+ ### CSV based Ruby decision tables
11
11
 
12
12
  `csv_decision` is a RubyGem for CSV (comma separated values) based
13
13
  [decision tables](https://en.wikipedia.org/wiki/Decision_table).
@@ -16,47 +16,24 @@ It accepts decision tables implemented as a
16
16
  which can then be used to execute complex conditional logic against an input hash,
17
17
  producing a decision as an output hash.
18
18
 
19
- ### CSV Decision features
20
- * Fast decision-time performance (see `benchmark.rb`).
21
- * In addition to simple string matching, can match common Ruby constants,
22
- regular expressions, numeric comparisons and Ruby-style ranges.
23
- * Can use column symbols in comparisons for guard conditions -- e.g., > :column.
24
- * Accepts data as a file, CSV string or an array of arrays. (For safety all input data is
25
- force encoded to UTF-8, and non-ascii strings are converted to empty strings.)
26
- * All CSV cells are parsed for correctness, and helpful error messages generated for bad
27
- inputs.
28
- * Either returns the first matching row as a hash, or accumulates all matches as an
29
- array of hashes.
30
-
31
- ### Planned features
32
- `csv_decision` is still a work in progress, and will be enhanced to support
33
- the following features:
34
- * Input columns may be indexed for faster lookup performance.
35
- * May use functions in the output columns to formulate the final decision.
36
- * Input hash values may be conditionally defaulted using a constant or a function call
37
- * Use of column symbol references or built-in guard functions in the input
38
- columns for matching.
39
- * Output columns may use interpolated strings referencing column symbols.
40
- * May be extended with user-defined Ruby functions for tailored logic.
41
- * Can use post-match guard conditions to filter the results of multi-row
42
- decision output.
43
-
44
- ### Why use `csv_decision`?
45
-
46
- Typical "business logic" is notoriously illogical -- full of corner cases and one-off
47
- exceptions.
48
- A decision table can capture data-based decisions in a way that comes more naturally
49
- to subject matter experts, who typically prefer spreadsheet models.
50
- Business logic may then be encapsulated, avoiding the need to write tortuous
51
- conditional expressions in Ruby that draw the ire of `rubocop` and its ilk.
52
-
53
- This gem takes its inspiration from
54
- [rufus/decision](https://github.com/jmettraux/rufus-decision).
55
- (That gem is no longer maintained and has issues with execution performance.)
19
+ ### Why use `csv_decision`?
20
+
21
+ Typical "business logic" is notoriously illogical -- full of corner cases and one-off
22
+ exceptions.
23
+ A decision table can capture data-based decisions in a way that comes more naturally
24
+ to subject matter experts, who typically prefer spreadsheet models.
25
+ Business logic may then be encapsulated, avoiding the need to write tortuous
26
+ conditional expressions in Ruby that draw the ire of `rubocop` and its ilk.
27
+
28
+ This gem and the examples below take inspiration from
29
+ [rufus/decision](https://github.com/jmettraux/rufus-decision).
30
+ (However, that gem is no longer maintained and CSV Decision has better
31
+ decision-time performance for the trade-off of slower table parse times and more memory --
32
+ see `benchmarks/rufus_decision.rb`)
56
33
 
57
- ### Installation
34
+ ### Installation
58
35
 
59
- To get started, just add `csv_decision` to your `Gemfile`, and then run `bundle`:
36
+ To get started, just add `csv_decision` to your `Gemfile`, and then run `bundle`:
60
37
 
61
38
  ```ruby
62
39
  gem 'csv_decision', '~> 0.0.1'
@@ -67,16 +44,11 @@ producing a decision as an output hash.
67
44
  gem install csv_decision
68
45
  ```
69
46
 
70
- ### Simple example
71
-
72
- A decision table may be as simple or as complex as you like (although very complex
73
- tables defeat the whole purpose).
74
- Basic usage will be illustrated by an example taken from:
75
- https://jmettraux.wordpress.com/2009/04/25/rufus-decision-11-ruby-decision-tables/.
76
-
77
- This example considers two input conditions: `topic` and `region`.
78
- These are labeled `in`. Certain combinations yield an output value for `team_member`,
79
- labeled `out`.
47
+ ### Simple example
48
+
49
+ This table considers two input conditions: `topic` and `region`.
50
+ These are labeled `in`. Certain combinations yield an output value for `team_member`,
51
+ labeled `out`.
80
52
 
81
53
  ```
82
54
  in :topic | in :region | out :team_member
@@ -92,18 +64,18 @@ politics | | Henry
92
64
  | | Zach
93
65
  ```
94
66
 
95
- When the topic is `finance` and the region is `Europe` the team member `Donald`
96
- is selected.
97
-
98
- This is a "first match" decision table in that as soon as a match is made execution
99
- stops and a single output value (hash) is returned.
100
-
101
- The ordering of rows matters. `Ernest`, who is in charge of `finance` for the rest of
102
- the world, except for `America` and `Europe`, *must* come after his colleagues
103
- `Charlie` and `Donald`. `Zach` has been placed last, catching all the input combos
104
- not matching any other row.
105
-
106
- Now for some code.
67
+ When the topic is `finance` and the region is `Europe` the team member `Donald`
68
+ is selected.
69
+
70
+ This is a "first match" decision table in that as soon as a match is made execution
71
+ stops and a single output value (hash) is returned.
72
+
73
+ The ordering of rows matters. `Ernest`, who is in charge of `finance` for the rest of
74
+ the world, except for `America` and `Europe`, *must* come after his colleagues
75
+ `Charlie` and `Donald`. `Zach` has been placed last, catching all the input combos
76
+ not matching any other row.
77
+
78
+ Here it is as code:
107
79
 
108
80
  ```ruby
109
81
  # Valid CSV string
@@ -127,36 +99,48 @@ politics | | Henry
127
99
  table.decide(topic: 'culture', region: 'America') # team_member: 'Zach'
128
100
  ```
129
101
 
130
- An empty `in` cell means "matches any value".
131
-
132
- If you have cloned this gem's git repo, then this example can also be run by loading
133
- the table from a CSV file:
102
+ An empty `in` cell means "matches any value", even nils.
103
+
104
+ If you have cloned this gem's git repo, then the example can also be run by loading
105
+ the table from a CSV file:
134
106
 
135
107
  ```ruby
136
108
  table = CSVDecision.parse(Pathname('spec/data/valid/simple_example.csv'))
137
109
  ```
138
110
 
139
- We can also load this same table using the option: `first_match: false`.
111
+ We can also load this same table using the option: `first_match: false`, which means that
112
+ all matching rows will be accumulated into an array of hashes.
140
113
 
141
114
  ```ruby
142
115
  table = CSVDecision.parse(data, first_match: false)
143
116
  table.decide(topic: 'finance', region: 'Europe') # returns team_member: %w[Donald Ernest Zach]
144
117
  ```
145
118
 
119
+ For more examples see `spec/csv_decision/table_spec.rb`.
120
+ Complete documentation of all table parameters is in the code - see
121
+ `lib/csv_decision/parse.rb` and `lib/csv_decision/table.rb`.
146
122
 
147
- For more examples see `spec/csv_decision/table_spec.rb`.
148
- Complete documentation of all table parameters is in the code - see
149
- `lib/csv_decision/parse.rb` and `lib/csv_decision/table.rb`.
150
-
151
- ### Constants other than strings
152
- Although `csv_decision` is string oriented, it does recognise other types of constant
153
- present in the input hash. Specifically, the following classes are recognized:
154
- `Integer`, `BigDecimal`, `NilClass`, `TrueClass` and `FalseClass`.
155
-
156
- This is accomplished by prefixing the value with one of the operators `=`, `==` or `:=`.
157
- (The syntax is intentionally lax.)
158
-
159
- For example:
123
+ ### CSV Decision features
124
+ * Fast decision-time performance (see `benchmarks` folder).
125
+ * In addition to simple string matching, can match common Ruby constants,
126
+ regular expressions, numeric comparisons and Ruby-style ranges.
127
+ * Can use column symbols in comparisons for guard conditions -- e.g., > :column.
128
+ * Accepts data as a file, CSV string or an array of arrays. (For safety all input data is
129
+ force encoded to UTF-8, and non-ascii strings are converted to empty strings.)
130
+ * All CSV cells are parsed for correctness, and helpful error messages generated for bad
131
+ inputs.
132
+ * Either returns the first matching row as a hash, or accumulates all matches as an
133
+ array of hashes.
134
+
135
+ ### Constants other than strings
136
+ Although `csv_decision` is string oriented, it does recognise other types of constant
137
+ present in the input hash. Specifically, the following classes are recognized:
138
+ `Integer`, `BigDecimal`, `NilClass`, `TrueClass` and `FalseClass`.
139
+
140
+ This is accomplished by prefixing the value with one of the operators `=`, `==` or `:=`.
141
+ (The syntax is intentionally lax.)
142
+
143
+ For example:
160
144
  ```ruby
161
145
  data = <<~DATA
162
146
  in :constant, out :value
@@ -173,11 +157,11 @@ table.decide(topic: 'finance', region: 'Europe') # returns team_member: %w[Donal
173
157
  table.decide(constant: BigDecimal('100.0')) # returns value: BigDecimal('100.0')
174
158
  ```
175
159
 
176
- ### Column header symbols
177
- All input and output column names are symbolized, and can be used to form simple
178
- expressions that refer to values in the input hash.
179
-
180
- For example:
160
+ ### Column header symbols
161
+ All input and output column names are symbolized, and can be used to form simple
162
+ expressions that refer to values in the input hash.
163
+
164
+ For example:
181
165
  ```ruby
182
166
  data = <<~DATA
183
167
  in :node, in :parent, out :top?
@@ -190,10 +174,10 @@ table.decide(topic: 'finance', region: 'Europe') # returns team_member: %w[Donal
190
174
  table.decide(node: 1, parent: 0) # returns top?: 'no'
191
175
  ```
192
176
 
193
- Note that there is no need to include an input column for `:node` in the decision
194
- table - it just needs to be present in the input hash. Also, `== :node` can be
195
- shortened to just `:node`, so the above decision table may be simplified to:
196
-
177
+ Note that there is no need to include an input column for `:node` in the decision
178
+ table - it just needs to be present in the input hash. Also, `== :node` can be
179
+ shortened to just `:node`, so the above decision table may be simplified to:
180
+
197
181
  ```ruby
198
182
  data = <<~DATA
199
183
  in :parent, out :top?
@@ -201,10 +185,32 @@ table.decide(topic: 'finance', region: 'Europe') # returns team_member: %w[Donal
201
185
  , no
202
186
  DATA
203
187
  ```
204
- These comparison operators are also supported: `!=`, `>`, `>=`, `<`, `<=`.
205
- For more simple examples see `spec/csv_decision/examples_spec.rb`.
206
-
207
- ### Testing
188
+ These comparison operators are also supported: `!=`, `>`, `>=`, `<`, `<=`.
189
+ For more simple examples see `spec/csv_decision/examples_spec.rb`.
190
+
191
+ ### Column guard conditions
192
+ Sometimes it's more convenient to write guard conditions in a single column specialized for that purpose.
193
+ For example:
194
+
195
+ ```ruby
196
+ data = <<~DATA
197
+ in :country, guard:, out :ID, out :ID_type, out :len
198
+ US, :CUSIP.present?, :CUSIP, CUSIP, :ID.length
199
+ GB, :SEDOL.present?, :SEDOL, SEDOL, :ID.length
200
+ , :ISIN.present?, :ISIN, ISIN, :ID.length
201
+ , :SEDOL.present?, :SEDOL, SEDOL, :ID.length
202
+ , :CUSIP.present?, :CUSIP, CUSIP, :ID.length
203
+ , , := nil, := nil, := nil
204
+ DATA
205
+
206
+ table = CSVDecision.parse(data)
207
+ table.decide(country: 'US', CUSIP: '123456789') #=> { ID: '123456789', ID_type: 'CUSIP', len: 9 }
208
+ table.decide(country: 'EU', CUSIP: '123456789', ISIN:'123456789012')
209
+ #=> { ID: '123456789012', ID_type: 'ISIN', len: 12 }
210
+ ```
211
+ Guard columns may be anonymous, and must contain non-constant expressions.
212
+
213
+ ### Testing
208
214
 
209
215
  `csv_decision` includes thorough [RSpec](http://rspec.info) tests:
210
216
 
@@ -213,3 +219,16 @@ table.decide(topic: 'finance', region: 'Europe') # returns team_member: %w[Donal
213
219
  bundle install
214
220
  rspec
215
221
  ```
222
+
223
+ ### Planned features
224
+ `csv_decision` is still a work in progress, and will be enhanced to support
225
+ the following features:
226
+ * Use of column symbol expressions or built-in guard functions in the input
227
+ columns for matching.
228
+ * Input columns may be indexed for faster lookup performance.
229
+ * May use functions in the output columns to formulate the final decision.
230
+ * Input hash values may be conditionally defaulted using a constant or a function call
231
+ * Output columns may use interpolated strings referencing column symbols.
232
+ * May be extended with a user-supplied library of Ruby functions for tailored logic.
233
+ * Can use post-match guard conditions to filter the results of multi-row
234
+ decision output.
@@ -21,6 +21,14 @@ benchmarks = [
21
21
  # Expected results for first_match and accumulate
22
22
  first_match: { 'team_member' => 'Zach' },
23
23
  accumulate: { 'team_member' => 'Zach' }
24
+ },
25
+ {
26
+ name: 'Regular expressions',
27
+ data: 'benchmark_regexp.csv',
28
+ input: { 'age' => '40', 'trait' => 'cheerful' },
29
+ # Expected results for first_match and accumulate
30
+ first_match: { 'salesperson' => 'Swanson' },
31
+ accumulate: { 'salesperson' => %w[Swanson Korolev] }
24
32
  }
25
33
  ].deep_freeze
26
34
 
@@ -37,7 +45,7 @@ puts ""
37
45
  puts '-' * tag_width
38
46
 
39
47
  csv_options = CSV_OPTIONS.merge(first_match: first_match)
40
- rufus_options = RUFUS_OPTIONS.merge(first_match: first_match)
48
+ rufus_options = RUFUS_OPTIONS.merge(first_match: first_match, accumulate: !first_match)
41
49
 
42
50
  benchmarks.each do |test|
43
51
  name = test[:name]
data/csv_decision.gemspec CHANGED
@@ -5,14 +5,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'csv_decision'
8
- spec.version = '0.0.6'
8
+ spec.version = '0.0.7'
9
9
  spec.authors = ['Brett Vickers']
10
10
  spec.email = ['brett@phillips-vickers.com']
11
11
  spec.description = 'CSV based Ruby decision tables.'
12
12
  spec.summary = <<-DESC
13
- CSV Decision implements CSV file based Ruby decision tables. It accepts decision tables implemented as a
14
- which can then be used to execute complex conditional logic against an input hash,
15
- producing a decision as an output hash.
13
+ CSV Decision implements CSV based Ruby decision tables. It parses and loads
14
+ decision table files which can then be used to execute complex conditional
15
+ logic against an input hash, producing a decision as an output hash.
16
16
  DESC
17
17
  spec.homepage = 'https://github.com/bpvickers/csv_decision.git'
18
18
  spec.license = 'MIT'
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '>= 2.3.0'
26
26
 
27
27
  spec.add_dependency 'activesupport', '~> 5.1'
28
- spec.add_dependency 'ice_nine', '~> 0.11'
29
- spec.add_dependency 'values', '~> 1.8'
28
+ spec.add_dependency 'ice_nine', '~> 0.11'
29
+ spec.add_dependency 'values', '~> 1.8'
30
30
 
31
31
  spec.add_development_dependency 'benchmark-ips', '~> 2.7'
32
32
  spec.add_development_dependency 'benchmark-memory', '~> 0.1'
data/doc/CSVDecision.html CHANGED
@@ -79,7 +79,7 @@
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
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/input.rb,<br /> lib/csv_decision/parse.rb,<br /> lib/csv_decision/table.rb,<br /> lib/csv_decision/decide.rb,<br /> lib/csv_decision/header.rb,<br /> lib/csv_decision/symbol.rb,<br /> lib/csv_decision/columns.rb,<br /> lib/csv_decision/numeric.rb,<br /> lib/csv_decision/options.rb,<br /> lib/csv_decision/constant.rb,<br /> lib/csv_decision/decision.rb,<br /> lib/csv_decision/function.rb,<br /> lib/csv_decision/matchers.rb,<br /> lib/csv_decision/scan_row.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>
82
+ lib/csv_decision/data.rb,<br /> lib/csv_decision/load.rb,<br /> lib/csv_decision/input.rb,<br /> lib/csv_decision/parse.rb,<br /> lib/csv_decision/table.rb,<br /> lib/csv_decision/decide.rb,<br /> lib/csv_decision/header.rb,<br /> lib/csv_decision/columns.rb,<br /> lib/csv_decision/options.rb,<br /> lib/csv_decision/decision.rb,<br /> lib/csv_decision/matchers.rb,<br /> lib/csv_decision/scan_row.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
83
  </dd>
84
84
  </dl>
85
85
 
@@ -88,20 +88,36 @@
88
88
  <h2>Overview</h2><div class="docstring">
89
89
  <div class="discussion">
90
90
 
91
- <p>CSV Decision: CSV based Ruby decision tables. Created December 2017 by
92
- Brett Vickers See LICENSE and README.md for details.</p>
91
+ <p>CSV Decision: CSV based Ruby decision tables. Created December 2017. See
92
+ LICENSE and README.md for details.</p>
93
93
 
94
94
 
95
95
  </div>
96
96
  </div>
97
97
  <div class="tags">
98
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 &lt;brett@phillips-vickers.com&gt;</p>
110
+ </div>
111
+
112
+ </li>
113
+
114
+ </ul>
99
115
 
100
116
  </div><h2>Defined Under Namespace</h2>
101
117
  <p class="children">
102
118
 
103
119
 
104
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="CSVDecision/Constant.html" title="CSVDecision::Constant (module)">Constant</a></span>, <span class='object_link'><a href="CSVDecision/Data.html" title="CSVDecision::Data (module)">Data</a></span>, <span class='object_link'><a href="CSVDecision/Decide.html" title="CSVDecision::Decide (module)">Decide</a></span>, <span class='object_link'><a href="CSVDecision/Function.html" title="CSVDecision::Function (module)">Function</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/Numeric.html" title="CSVDecision::Numeric (module)">Numeric</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/Symbol.html" title="CSVDecision::Symbol (module)">Symbol</a></span>
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/Decide.html" title="CSVDecision::Decide (module)">Decide</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>
105
121
 
106
122
 
107
123
 
@@ -110,75 +126,6 @@ Brett Vickers See LICENSE and README.md for details.</p>
110
126
 
111
127
  </p>
112
128
 
113
- <h2>Constant Summary</h2>
114
- <dl class="constants">
115
-
116
- <dt id="COMMENT_CHARACTER-constant" class="">COMMENT_CHARACTER =
117
-
118
- </dt>
119
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>#</span><span class='tstring_end'>&#39;</span></span></pre></dd>
120
-
121
- <dt id="DEFAULT_MATCHERS-constant" class="">DEFAULT_MATCHERS =
122
- <div class="docstring">
123
- <div class="discussion">
124
-
125
- <p>Specialized cell value matchers beyond simple string compares. By default
126
- all these matchers are tried in the specified order.</p>
127
-
128
-
129
- </div>
130
- </div>
131
- <div class="tags">
132
-
133
-
134
- </div>
135
- </dt>
136
- <dd><pre class="code"><span class='lbracket'>[</span>
137
- <span class='const'><span class='object_link'><a href="CSVDecision/Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="CSVDecision/Matchers/Range.html" title="CSVDecision::Matchers::Range (class)">Range</a></span></span><span class='comma'>,</span>
138
- <span class='const'><span class='object_link'><a href="CSVDecision/Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="CSVDecision/Matchers/Numeric.html" title="CSVDecision::Matchers::Numeric (class)">Numeric</a></span></span><span class='comma'>,</span>
139
- <span class='const'><span class='object_link'><a href="CSVDecision/Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="CSVDecision/Matchers/Pattern.html" title="CSVDecision::Matchers::Pattern (class)">Pattern</a></span></span><span class='comma'>,</span>
140
- <span class='const'><span class='object_link'><a href="CSVDecision/Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="CSVDecision/Matchers/Constant.html" title="CSVDecision::Matchers::Constant (class)">Constant</a></span></span><span class='comma'>,</span>
141
- <span class='const'><span class='object_link'><a href="CSVDecision/Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="CSVDecision/Matchers/Symbol.html" title="CSVDecision::Matchers::Symbol (class)">Symbol</a></span></span>
142
- <span class='comment'># Matchers::Function
143
- </span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
144
-
145
- <dt id="OUTS_MATCHERS-constant" class="">OUTS_MATCHERS =
146
- <div class="docstring">
147
- <div class="discussion">
148
-
149
- <p>Subset of matchers that apply to output cells</p>
150
-
151
-
152
- </div>
153
- </div>
154
- <div class="tags">
155
-
156
-
157
- </div>
158
- </dt>
159
- <dd><pre class="code"><span class='lbracket'>[</span>
160
- <span class='const'><span class='object_link'><a href="CSVDecision/Matchers.html" title="CSVDecision::Matchers (class)">Matchers</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="CSVDecision/Matchers/Constant.html" title="CSVDecision::Matchers::Constant (class)">Constant</a></span></span>
161
- <span class='comment'># Matchers::Function
162
- </span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
163
-
164
- <dt id="Proc-constant" class="">Proc =
165
- <div class="docstring">
166
- <div class="discussion">
167
-
168
- <p>Value object for a cell proc.</p>
169
-
170
-
171
- </div>
172
- </div>
173
- <div class="tags">
174
-
175
-
176
- </div>
177
- </dt>
178
- <dd><pre class="code"><span class='const'>Value</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:type</span><span class='comma'>,</span> <span class='symbol'>:function</span><span class='rparen'>)</span></pre></dd>
179
-
180
- </dl>
181
-
182
129
 
183
130
 
184
131
 
@@ -306,9 +253,8 @@ CSV string or an array of arrays.</p>
306
253
 
307
254
 
308
255
  &mdash;
309
- <div class='inline'><ul><li>
310
- <p>directiory containing CSV files</p>
311
- </li></ul>
256
+ <div class='inline'>
257
+ <p>Directory containing CSV files.</p>
312
258
  </div>
313
259
 
314
260
  </li>
@@ -325,9 +271,8 @@ CSV string or an array of arrays.</p>
325
271
 
326
272
 
327
273
  &mdash;
328
- <div class='inline'><ul><li>
329
- <p>supplied options hash for table creation</p>
330
- </li></ul>
274
+ <div class='inline'>
275
+ <p>Options hash used for table creation.</p>
331
276
  </div>
332
277
 
333
278
  </li>
@@ -344,6 +289,24 @@ CSV string or an array of arrays.</p>
344
289
 
345
290
 
346
291
 
292
+ </li>
293
+
294
+ </ul>
295
+ <p class="tag_title">Raises:</p>
296
+ <ul class="raise">
297
+
298
+ <li>
299
+
300
+
301
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
302
+
303
+
304
+
305
+ &mdash;
306
+ <div class='inline'>
307
+ <p>Invalid folder.</p>
308
+ </div>
309
+
347
310
  </li>
348
311
 
349
312
  </ul>
@@ -354,12 +317,12 @@ CSV string or an array of arrays.</p>
354
317
  <pre class="lines">
355
318
 
356
319
 
357
- 12
358
- 13
359
- 14</pre>
320
+ 14
321
+ 15
322
+ 16</pre>
360
323
  </td>
361
324
  <td>
362
- <pre class="code"><span class="info file"># File 'lib/csv_decision/load.rb', line 12</span>
325
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/load.rb', line 14</span>
363
326
 
364
327
  <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>
365
328
  <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>
@@ -398,7 +361,8 @@ CSV string or an array of arrays.</p>
398
361
  </div></p>
399
362
 
400
363
  <pre class="example code"><code>If you have cloned the gem&#39;s git repo, then you can run:
401
- table = CSVDecision.parse(Pathname(&#39;spec/data/valid/simple_example.csv&#39;)) #=&gt; CSVDecision::Table
364
+ table = CSVDecision.parse(Pathname(&#39;spec/data/valid/simple_example.csv&#39;))
365
+ #=&gt; CSVDecision::Table
402
366
  table.decide(topic: &#39;finance&#39;, region: &#39;Europe&#39;) #=&gt; team_member: &#39;Donald&#39;</code></pre>
403
367
 
404
368
  </div>
@@ -457,7 +421,7 @@ table.decide(topic: &#39;finance&#39;, region: &#39;Europe&#39;) #=&gt; team_mem
457
421
  </span>
458
422
 
459
423
  &mdash; <div class='inline'>
460
- <p>Stop scanning after find the first row match.</p>
424
+ <p>Stop scanning after finding the first row match.</p>
461
425
  </div>
462
426
 
463
427
  </li>
@@ -563,12 +527,12 @@ table.decide(topic: &#39;finance&#39;, region: &#39;Europe&#39;) #=&gt; team_mem
563
527
  <pre class="lines">
564
528
 
565
529
 
566
- 41
567
- 42
568
- 43</pre>
530
+ 46
531
+ 47
532
+ 48</pre>
569
533
  </td>
570
534
  <td>
571
- <pre class="code"><span class="info file"># File 'lib/csv_decision/parse.rb', line 41</span>
535
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/parse.rb', line 46</span>
572
536
 
573
537
  <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>
574
538
  <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>
@@ -642,7 +606,7 @@ table.decide(topic: &#39;finance&#39;, region: &#39;Europe&#39;) #=&gt; team_mem
642
606
  </div>
643
607
 
644
608
  <div id="footer">
645
- Generated on Tue Dec 26 21:20:19 2017 by
609
+ Generated on Sat Dec 30 13:04:04 2017 by
646
610
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
647
611
  0.9.12 (ruby-2.3.0).
648
612
  </div>