csv_decision 0.1.0 → 0.2.0
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/CHANGELOG.md +4 -0
 - data/README.md +26 -2
 - data/csv_decision.gemspec +1 -1
 - data/doc/CSVDecision/CellValidationError.html +2 -2
 - data/doc/CSVDecision/Columns/Default.html +203 -23
 - data/doc/CSVDecision/Columns/Dictionary.html +118 -25
 - data/doc/CSVDecision/Columns.html +213 -31
 - data/doc/CSVDecision/Data.html +1 -1
 - data/doc/CSVDecision/Decide.html +1 -1
 - data/doc/CSVDecision/Decision.html +1 -1
 - data/doc/CSVDecision/Defaults.html +291 -0
 - data/doc/CSVDecision/Dictionary/Entry.html +584 -47
 - data/doc/CSVDecision/Dictionary.html +20 -20
 - data/doc/CSVDecision/Error.html +2 -2
 - data/doc/CSVDecision/FileError.html +1 -1
 - data/doc/CSVDecision/Header.html +110 -33
 - data/doc/CSVDecision/Input.html +1 -1
 - data/doc/CSVDecision/Load.html +1 -1
 - data/doc/CSVDecision/Matchers/Constant.html +12 -37
 - data/doc/CSVDecision/Matchers/Function.html +1 -1
 - data/doc/CSVDecision/Matchers/Guard.html +15 -13
 - data/doc/CSVDecision/Matchers/Matcher.html +1 -1
 - data/doc/CSVDecision/Matchers/Numeric.html +13 -21
 - data/doc/CSVDecision/Matchers/Pattern.html +14 -14
 - data/doc/CSVDecision/Matchers/Proc.html +1 -1
 - data/doc/CSVDecision/Matchers/Range.html +13 -58
 - data/doc/CSVDecision/Matchers/Symbol.html +1 -1
 - data/doc/CSVDecision/Matchers.html +9 -9
 - data/doc/CSVDecision/Options.html +1 -1
 - data/doc/CSVDecision/Parse.html +90 -19
 - data/doc/CSVDecision/Result.html +1 -1
 - data/doc/CSVDecision/ScanRow.html +17 -17
 - data/doc/CSVDecision/Table.html +50 -48
 - data/doc/CSVDecision/TableValidationError.html +143 -0
 - data/doc/CSVDecision/Validate.html +422 -0
 - data/doc/CSVDecision.html +8 -8
 - data/doc/_index.html +33 -1
 - data/doc/class_list.html +1 -1
 - data/doc/file.README.html +27 -3
 - data/doc/index.html +27 -3
 - data/doc/method_list.html +193 -89
 - data/doc/top-level-namespace.html +1 -1
 - data/lib/csv_decision/columns.rb +28 -27
 - data/lib/csv_decision/defaults.rb +47 -0
 - data/lib/csv_decision/dictionary.rb +104 -112
 - data/lib/csv_decision/header.rb +13 -10
 - data/lib/csv_decision/input.rb +53 -5
 - data/lib/csv_decision/matchers/constant.rb +1 -2
 - data/lib/csv_decision/matchers/guard.rb +3 -2
 - data/lib/csv_decision/matchers/numeric.rb +4 -6
 - data/lib/csv_decision/matchers/pattern.rb +6 -8
 - data/lib/csv_decision/matchers/range.rb +1 -3
 - data/lib/csv_decision/matchers.rb +7 -7
 - data/lib/csv_decision/parse.rb +24 -3
 - data/lib/csv_decision/scan_row.rb +16 -16
 - data/lib/csv_decision/table.rb +3 -7
 - data/lib/csv_decision/validate.rb +85 -0
 - data/lib/csv_decision.rb +3 -1
 - data/spec/csv_decision/columns_spec.rb +38 -22
 - data/spec/csv_decision/examples_spec.rb +17 -0
 - data/spec/csv_decision/matchers/range_spec.rb +0 -32
 - data/spec/csv_decision/table_spec.rb +39 -0
 - metadata +7 -2
 
    
        data/doc/file.README.html
    CHANGED
    
    | 
         @@ -262,7 +262,7 @@ operators are also supported: <code>!=</code>, <code>></code>, 
     | 
|
| 
       262 
262 
     | 
    
         
             
            <code>>=</code>, <code><</code>, <code><=</code>. For more simple
         
     | 
| 
       263 
263 
     | 
    
         
             
            examples see <code>spec/csv_decision/examples_spec.rb</code>.</p>
         
     | 
| 
       264 
264 
     | 
    
         | 
| 
       265 
     | 
    
         
            -
            <h4 id="label-Input+guard+conditions">Input guard conditions</h4>
         
     | 
| 
      
 265 
     | 
    
         
            +
            <h4 id="label-Input+guard+conditions">Input <code>guard</code> conditions</h4>
         
     | 
| 
       266 
266 
     | 
    
         | 
| 
       267 
267 
     | 
    
         
             
            <p>Sometimes it's more convenient to write guard expressions in a single
         
     | 
| 
       268 
268 
     | 
    
         
             
            column specialized for that purpose. For example:</p>
         
     | 
| 
         @@ -290,7 +290,7 @@ following comparison operators are allowed: <code>==</code>, 
     | 
|
| 
       290 
290 
     | 
    
         
             
            and <code><=</code>. Also, regular expressions are supported - i.e.,
         
     | 
| 
       291 
291 
     | 
    
         
             
            <code>=~</code> and <code>!~</code>.</p>
         
     | 
| 
       292 
292 
     | 
    
         | 
| 
       293 
     | 
    
         
            -
            <h4 id="label-Output+if+conditions">Output if conditions</h4>
         
     | 
| 
      
 293 
     | 
    
         
            +
            <h4 id="label-Output+if+conditions">Output <code>if</code> conditions</h4>
         
     | 
| 
       294 
294 
     | 
    
         | 
| 
       295 
295 
     | 
    
         
             
            <p>In some situations it is useful to apply filter conditions <em>after</em>
         
     | 
| 
       296 
296 
     | 
    
         
             
            all the output columns have been derived. For example:</p>
         
     | 
| 
         @@ -317,6 +317,30 @@ following comparison operators are allowed: <code>==</code>, 
     | 
|
| 
       317 
317 
     | 
    
         
             
            and <code><=</code>. Also, regular expressions are supported - i.e.,
         
     | 
| 
       318 
318 
     | 
    
         
             
            <code>=~</code> and <code>!~</code>.</p>
         
     | 
| 
       319 
319 
     | 
    
         | 
| 
      
 320 
     | 
    
         
            +
            <h4 id="label-Input+set+columns">Input <code>set</code> columns</h4>
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
            <p>If you wish to set default values in the input hash, you can use a
         
     | 
| 
      
 323 
     | 
    
         
            +
            <code>set</code> column rather than an <code>in</code> column. The data row
         
     | 
| 
      
 324 
     | 
    
         
            +
            beneath the header is used to specify the default expression. There are
         
     | 
| 
      
 325 
     | 
    
         
            +
            three variations: <code>set</code> (unconditional default)
         
     | 
| 
      
 326 
     | 
    
         
            +
            <code>set/nil?</code>(set if <code>nil?</code> true) and
         
     | 
| 
      
 327 
     | 
    
         
            +
            <code>set/blank?</code> (set if <code>blank?</code> true). Note that the
         
     | 
| 
      
 328 
     | 
    
         
            +
            <code>decide!</code> method will mutate the input hash.</p>
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
            <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='heredoc_beg'><<~DATA</span>
         
     | 
| 
      
 331 
     | 
    
         
            +
            <span class='tstring_content'>  set/nil? :country, guard:,          set: class,    out :PAID, out: len,     if:
         
     | 
| 
      
 332 
     | 
    
         
            +
            </span><span class='tstring_content'>  US,                ,                :class.upcase,
         
     | 
| 
      
 333 
     | 
    
         
            +
            </span><span class='tstring_content'>  US,                :CUSIP.present?, != PRIVATE,    :CUSIP,    :PAID.length, :len == 9
         
     | 
| 
      
 334 
     | 
    
         
            +
            </span><span class='tstring_content'>  !=US,              :ISIN.present?,  != PRIVATE,    :ISIN,     :PAID.length, :len == 12
         
     | 
| 
      
 335 
     | 
    
         
            +
            </span><span class='tstring_content'>  US,                :CUSIP.present?, PRIVATE,       :CUSIP,    :PAID.length,
         
     | 
| 
      
 336 
     | 
    
         
            +
            </span><span class='tstring_content'>  !=US,              :ISIN.present?,  PRIVATE,       :ISIN,     :PAID.length,
         
     | 
| 
      
 337 
     | 
    
         
            +
            </span><span class='heredoc_end'>DATA
         
     | 
| 
      
 338 
     | 
    
         
            +
            </span>
         
     | 
| 
      
 339 
     | 
    
         
            +
            <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='period'>.</span><span class='id identifier rubyid_parse'><span class='object_link'><a href="CSVDecision.html#parse-class_method" title="CSVDecision.parse (method)">parse</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
         
     | 
| 
      
 340 
     | 
    
         
            +
            <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_decide'>decide</span><span class='lparen'>(</span><span class='label'>CUSIP:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1234567890</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>class:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Private</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> {PAID: '1234567890', len: 10}
         
     | 
| 
      
 341 
     | 
    
         
            +
            </span><span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_decide'>decide</span><span class='lparen'>(</span><span class='label'>ISIN:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123456789012</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>country:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>GB</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>class:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>private</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> {PAID: '123456789012', len: 12}
         
     | 
| 
      
 342 
     | 
    
         
            +
            </span></code></pre>
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
       320 
344 
     | 
    
         
             
            <h3 id="label-Testing">Testing</h3>
         
     | 
| 
       321 
345 
     | 
    
         | 
| 
       322 
346 
     | 
    
         
             
            <p><code>csv_decision</code> includes thorough <a
         
     | 
| 
         @@ -359,7 +383,7 @@ href="./LICENSE">LICENSE</a> document for more information.</p> 
     | 
|
| 
       359 
383 
     | 
    
         
             
            </div></div>
         
     | 
| 
       360 
384 
     | 
    
         | 
| 
       361 
385 
     | 
    
         
             
                  <div id="footer">
         
     | 
| 
       362 
     | 
    
         
            -
              Generated on Sat Jan 
     | 
| 
      
 386 
     | 
    
         
            +
              Generated on Sat Jan 13 10:02:46 2018 by
         
     | 
| 
       363 
387 
     | 
    
         
             
              <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
         
     | 
| 
       364 
388 
     | 
    
         
             
              0.9.12 (ruby-2.4.0).
         
     | 
| 
       365 
389 
     | 
    
         
             
            </div>
         
     | 
    
        data/doc/index.html
    CHANGED
    
    | 
         @@ -262,7 +262,7 @@ operators are also supported: <code>!=</code>, <code>></code>, 
     | 
|
| 
       262 
262 
     | 
    
         
             
            <code>>=</code>, <code><</code>, <code><=</code>. For more simple
         
     | 
| 
       263 
263 
     | 
    
         
             
            examples see <code>spec/csv_decision/examples_spec.rb</code>.</p>
         
     | 
| 
       264 
264 
     | 
    
         | 
| 
       265 
     | 
    
         
            -
            <h4 id="label-Input+guard+conditions">Input guard conditions</h4>
         
     | 
| 
      
 265 
     | 
    
         
            +
            <h4 id="label-Input+guard+conditions">Input <code>guard</code> conditions</h4>
         
     | 
| 
       266 
266 
     | 
    
         | 
| 
       267 
267 
     | 
    
         
             
            <p>Sometimes it's more convenient to write guard expressions in a single
         
     | 
| 
       268 
268 
     | 
    
         
             
            column specialized for that purpose. For example:</p>
         
     | 
| 
         @@ -290,7 +290,7 @@ following comparison operators are allowed: <code>==</code>, 
     | 
|
| 
       290 
290 
     | 
    
         
             
            and <code><=</code>. Also, regular expressions are supported - i.e.,
         
     | 
| 
       291 
291 
     | 
    
         
             
            <code>=~</code> and <code>!~</code>.</p>
         
     | 
| 
       292 
292 
     | 
    
         | 
| 
       293 
     | 
    
         
            -
            <h4 id="label-Output+if+conditions">Output if conditions</h4>
         
     | 
| 
      
 293 
     | 
    
         
            +
            <h4 id="label-Output+if+conditions">Output <code>if</code> conditions</h4>
         
     | 
| 
       294 
294 
     | 
    
         | 
| 
       295 
295 
     | 
    
         
             
            <p>In some situations it is useful to apply filter conditions <em>after</em>
         
     | 
| 
       296 
296 
     | 
    
         
             
            all the output columns have been derived. For example:</p>
         
     | 
| 
         @@ -317,6 +317,30 @@ following comparison operators are allowed: <code>==</code>, 
     | 
|
| 
       317 
317 
     | 
    
         
             
            and <code><=</code>. Also, regular expressions are supported - i.e.,
         
     | 
| 
       318 
318 
     | 
    
         
             
            <code>=~</code> and <code>!~</code>.</p>
         
     | 
| 
       319 
319 
     | 
    
         | 
| 
      
 320 
     | 
    
         
            +
            <h4 id="label-Input+set+columns">Input <code>set</code> columns</h4>
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
            <p>If you wish to set default values in the input hash, you can use a
         
     | 
| 
      
 323 
     | 
    
         
            +
            <code>set</code> column rather than an <code>in</code> column. The data row
         
     | 
| 
      
 324 
     | 
    
         
            +
            beneath the header is used to specify the default expression. There are
         
     | 
| 
      
 325 
     | 
    
         
            +
            three variations: <code>set</code> (unconditional default)
         
     | 
| 
      
 326 
     | 
    
         
            +
            <code>set/nil?</code>(set if <code>nil?</code> true) and
         
     | 
| 
      
 327 
     | 
    
         
            +
            <code>set/blank?</code> (set if <code>blank?</code> true). Note that the
         
     | 
| 
      
 328 
     | 
    
         
            +
            <code>decide!</code> method will mutate the input hash.</p>
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
            <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='heredoc_beg'><<~DATA</span>
         
     | 
| 
      
 331 
     | 
    
         
            +
            <span class='tstring_content'>  set/nil? :country, guard:,          set: class,    out :PAID, out: len,     if:
         
     | 
| 
      
 332 
     | 
    
         
            +
            </span><span class='tstring_content'>  US,                ,                :class.upcase,
         
     | 
| 
      
 333 
     | 
    
         
            +
            </span><span class='tstring_content'>  US,                :CUSIP.present?, != PRIVATE,    :CUSIP,    :PAID.length, :len == 9
         
     | 
| 
      
 334 
     | 
    
         
            +
            </span><span class='tstring_content'>  !=US,              :ISIN.present?,  != PRIVATE,    :ISIN,     :PAID.length, :len == 12
         
     | 
| 
      
 335 
     | 
    
         
            +
            </span><span class='tstring_content'>  US,                :CUSIP.present?, PRIVATE,       :CUSIP,    :PAID.length,
         
     | 
| 
      
 336 
     | 
    
         
            +
            </span><span class='tstring_content'>  !=US,              :ISIN.present?,  PRIVATE,       :ISIN,     :PAID.length,
         
     | 
| 
      
 337 
     | 
    
         
            +
            </span><span class='heredoc_end'>DATA
         
     | 
| 
      
 338 
     | 
    
         
            +
            </span>
         
     | 
| 
      
 339 
     | 
    
         
            +
            <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='period'>.</span><span class='id identifier rubyid_parse'><span class='object_link'><a href="CSVDecision.html#parse-class_method" title="CSVDecision.parse (method)">parse</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
         
     | 
| 
      
 340 
     | 
    
         
            +
            <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_decide'>decide</span><span class='lparen'>(</span><span class='label'>CUSIP:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1234567890</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>class:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Private</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> {PAID: '1234567890', len: 10}
         
     | 
| 
      
 341 
     | 
    
         
            +
            </span><span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_decide'>decide</span><span class='lparen'>(</span><span class='label'>ISIN:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123456789012</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>country:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>GB</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>class:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>private</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> {PAID: '123456789012', len: 12}
         
     | 
| 
      
 342 
     | 
    
         
            +
            </span></code></pre>
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
       320 
344 
     | 
    
         
             
            <h3 id="label-Testing">Testing</h3>
         
     | 
| 
       321 
345 
     | 
    
         | 
| 
       322 
346 
     | 
    
         
             
            <p><code>csv_decision</code> includes thorough <a
         
     | 
| 
         @@ -359,7 +383,7 @@ href="./LICENSE">LICENSE</a> document for more information.</p> 
     | 
|
| 
       359 
383 
     | 
    
         
             
            </div></div>
         
     | 
| 
       360 
384 
     | 
    
         | 
| 
       361 
385 
     | 
    
         
             
                  <div id="footer">
         
     | 
| 
       362 
     | 
    
         
            -
              Generated on Sat Jan 
     | 
| 
      
 386 
     | 
    
         
            +
              Generated on Sat Jan 13 10:02:45 2018 by
         
     | 
| 
       363 
387 
     | 
    
         
             
              <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
         
     | 
| 
       364 
388 
     | 
    
         
             
              0.9.12 (ruby-2.4.0).
         
     | 
| 
       365 
389 
     | 
    
         
             
            </div>
         
     |