Skip to content

Commit

Permalink
Update documents.
Browse files Browse the repository at this point in the history
  • Loading branch information
bpvickers committed Feb 11, 2018
1 parent 9a41f51 commit d2d6522
Show file tree
Hide file tree
Showing 42 changed files with 3,188 additions and 624 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,35 @@ table.decide(ISIN: '123456789012', country: 'GB', class: 'private') #=> {PAID: '

```

#### Input `path` columns

For hashes that contain sub-hashes, it's possible to specify a path for the purposes
of matching. (Arrays are currently not supported.)

```ruby
data = <<~DATA
path:, path:, out :value
header, , :source_name
header, metrics, :service_name
payload, , :amount
payload, ref_data, :account_id
DATA
table = CSVDecision.parse(data, first_match: false)

input = {
header: {
id: 1, type_cd: 'BUY', source_name: 'Client', client_name: 'AAPL',
metrics: { service_name: 'Trading', receive_time: '12:00' }
},
payload: {
tran_id: 9, amount: '100.00',
ref_data: { account_id: '5010', type_id: 'BUYL' }
}
}

table.decide(input) #=> { value: %w[Client Trading 100.00 5010] }
```

### Testing

`csv_decision` includes thorough [RSpec](http://rspec.info) tests:
Expand Down
12 changes: 6 additions & 6 deletions doc/CSVDecision.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dl>
<dt>Defined in:</dt>
<dd>lib/csv_decision.rb<span class="defines">,<br />
lib/csv_decision/data.rb,<br /> lib/csv_decision/load.rb,<br /> lib/csv_decision/index.rb,<br /> lib/csv_decision/input.rb,<br /> lib/csv_decision/parse.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>
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>
</dd>
</dl>

Expand Down Expand Up @@ -121,7 +121,7 @@ <h2>Overview</h2><div class="docstring">



<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/Result.html" title="CSVDecision::Result (class)">Result</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>
<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>


</p>
Expand Down Expand Up @@ -532,12 +532,12 @@ <h3 class="signature " id="parse-class_method">
<pre class="lines">


46
47
48</pre>
48
49</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/parse.rb', line 46</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/parse.rb', line 47</span>

<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>
<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>
Expand Down Expand Up @@ -611,7 +611,7 @@ <h3 class="signature " id="root-class_method">
</div>

<div id="footer">
Generated on Sun Jan 28 14:41:48 2018 by
Generated on Sun Feb 11 10:26:07 2018 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.12 (ruby-2.4.0).
</div>
Expand Down
2 changes: 1 addition & 1 deletion doc/CSVDecision/CellValidationError.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ <h2>Overview</h2><div class="docstring">
</div>

<div id="footer">
Generated on Sun Jan 28 14:41:48 2018 by
Generated on Sun Feb 11 10:26:07 2018 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.12 (ruby-2.4.0).
</div>
Expand Down
166 changes: 124 additions & 42 deletions doc/CSVDecision/Columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,30 @@ <h2>
<p>Output columns hash keyed by column index.</p>
</div></span>

</li>


<li class="public ">
<span class="summary_signature">

<a href="#paths-instance_method" title="#paths (instance method)">#<strong>paths</strong> &#x21d2; Hash{Index=&gt;Entry} </a>



</span>






<span class="private note title">private</span>


<span class="summary_desc"><div class='inline'>
<p>path: columns hash keyed by column index.</p>
</div></span>

</li>


Expand Down Expand Up @@ -477,22 +501,22 @@ <h3 class="signature first" id="initialize-instance_method">
<pre class="lines">


167
168
169
170
171
172
173
174
175
176
177
178
179</pre>
179
180
181
182
183
184
185
186
187
188
189
190</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 167</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 178</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='rparen'>)</span>
<span class='comment'># If a column does not have a valid header cell, then it&#39;s empty of data.
Expand Down Expand Up @@ -802,12 +826,12 @@ <h3 class="signature first" id="defaults-instance_method">
<pre class="lines">


128
129
130</pre>
133
134
135</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 128</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 133</span>

<span class='kw'>def</span> <span class='id identifier rubyid_defaults'>defaults</span>
<span class='ivar'>@dictionary</span><span class='op'>&amp;.</span><span class='id identifier rubyid_defaults'>defaults</span>
Expand Down Expand Up @@ -847,12 +871,12 @@ <h3 class="signature " id="defaults=-instance_method">
<pre class="lines">


133
134
135</pre>
138
139
140</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 133</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 138</span>

<span class='kw'>def</span> <span class='id identifier rubyid_defaults='>defaults=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_defaults'>defaults</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
Expand Down Expand Up @@ -910,12 +934,12 @@ <h3 class="signature " id="dictionary-instance_method">
<pre class="lines">


139
140
141</pre>
144
145
146</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 139</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 144</span>

<span class='kw'>def</span> <span class='id identifier rubyid_dictionary'>dictionary</span>
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_columns'>columns</span>
Expand Down Expand Up @@ -968,12 +992,12 @@ <h3 class="signature " id="ifs-instance_method">
<pre class="lines">


157
158
159</pre>
162
163
164</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 157</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 162</span>

<span class='kw'>def</span> <span class='id identifier rubyid_ifs'>ifs</span>
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_ifs'>ifs</span>
Expand Down Expand Up @@ -1031,12 +1055,12 @@ <h3 class="signature " id="input_keys-instance_method">
<pre class="lines">


162
163
164</pre>
173
174
175</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 162</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 173</span>

<span class='kw'>def</span> <span class='id identifier rubyid_input_keys'>input_keys</span>
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_columns'>columns</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__k'>_k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>==</span> <span class='symbol'>:in</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
Expand Down Expand Up @@ -1089,12 +1113,12 @@ <h3 class="signature " id="ins-instance_method">
<pre class="lines">


145
146
147</pre>
150
151
152</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 145</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 150</span>

<span class='kw'>def</span> <span class='id identifier rubyid_ins'>ins</span>
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_ins'>ins</span>
Expand Down Expand Up @@ -1147,27 +1171,85 @@ <h3 class="signature " id="outs-instance_method">
<pre class="lines">


151
152
153</pre>
156
157
158</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 151</span>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 156</span>

<span class='kw'>def</span> <span class='id identifier rubyid_outs'>outs</span>
<span class='ivar'>@dictionary</span><span class='op'>&amp;.</span><span class='id identifier rubyid_outs'>outs</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>

<div class="method_details ">
<h3 class="signature " id="paths-instance_method">

#<strong>paths</strong> &#x21d2; <tt>Hash{<span class='object_link'><a href="Index.html" title="CSVDecision::Index (class)">Index</a></span>=&gt;Entry}</tt>





</h3><div class="docstring">
<div class="discussion">
<p class="note private">
<strong>This method is part of a private API.</strong>
You should avoid using this method if possible, as it may be removed or be changed in the future.
</p>

<p>path: columns hash keyed by column index.</p>


</div>
</div>
<div class="tags">

<p class="tag_title">Returns:</p>
<ul class="return">

<li>


<span class='type'>(<tt>Hash{<span class='object_link'><a href="Index.html" title="CSVDecision::Index (class)">Index</a></span>=&gt;Entry}</tt>)</span>



</li>

</ul>

</div><table class="source_code">
<tr>
<td>
<pre class="lines">


168
169
170</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 168</span>

<span class='kw'>def</span> <span class='id identifier rubyid_paths'>paths</span>
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_paths'>paths</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>

</div>

</div>

<div id="footer">
Generated on Sun Jan 28 14:41:49 2018 by
Generated on Sun Feb 11 10:26:08 2018 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.12 (ruby-2.4.0).
</div>
Expand Down
Loading

0 comments on commit d2d6522

Please sign in to comment.