Skip to content

Commit

Permalink
Merge pull request #23 from lyrasis/fix-multiprepend
Browse files Browse the repository at this point in the history
Fix handling prepending field if target blank or prepend is multival
  • Loading branch information
kspurgin authored Jul 20, 2021
2 parents f4e4e7a + f059c6c commit 6538525
Show file tree
Hide file tree
Showing 19 changed files with 473 additions and 1,429 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ AllCops:
TargetRubyVersion: 2.7.3
SuggestExtensions:
rubocop-rake: false
Naming/MethodParameterName:
AllowedNames: i, v
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
kiba-extend (1.15.1)
kiba-extend (1.15.2)
activesupport
kiba (>= 4.0.0)
kiba-common (>= 1.5.0)
Expand Down
24 changes: 3 additions & 21 deletions docs/Kiba.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,12 @@

<dl>
<dt>Defined in:</dt>
<dd>lib/kiba/extend.rb<span class="defines">,<br />
lib/kiba/extend/version.rb,<br /> lib/kiba/extend/fieldset.rb,<br /> lib/kiba/extend/utils/lookup.rb,<br /> lib/kiba/extend/transforms/copy.rb,<br /> lib/kiba/extend/destinations/csv.rb,<br /> lib/kiba/extend/transforms/clean.rb,<br /> lib/kiba/extend/transforms/merge.rb,<br /> lib/kiba/extend/transforms/split.rb,<br /> lib/kiba/extend/transforms/append.rb,<br /> lib/kiba/extend/transforms/cspace.rb,<br /> lib/kiba/extend/transforms/delete.rb,<br /> lib/kiba/extend/transforms/rename.rb,<br /> lib/kiba/extend/transforms/explode.rb,<br /> lib/kiba/extend/transforms/prepend.rb,<br /> lib/kiba/extend/transforms/replace.rb,<br /> lib/kiba/extend/transforms/reshape.rb,<br /> lib/kiba/extend/transforms/ms_access.rb,<br /> lib/kiba/extend/transforms/deduplicate.rb,<br /> lib/kiba/extend/transforms/filter_rows.rb,<br /> lib/kiba/extend/transforms/combine_values.rb</span>
</dd>
<dd>lib/kiba/extend/transforms/prepend.rb</dd>
</dl>

</div>

<h2>Overview</h2><div class="docstring">
<div class="discussion">

<p>The Kiba ETL framework for Ruby. <code>kiba-extend</code> extends only Kiba OSS. Kiba Pro features are not used.</p>
<ul><li>
<p><a href="https://www.kiba-etl.org/">Main website</a></p>
</li><li>
<p><a href="https://github.com/thbar/kiba">Github repo</a></p>
</li></ul>


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


</div><h2>Defined Under Namespace</h2>
<h2>Defined Under Namespace</h2>
<p class="children">


Expand All @@ -123,7 +105,7 @@ <h2>Overview</h2><div class="docstring">
</div>

<div id="footer">
Generated on Tue Jul 20 12:08:37 2021 by
Generated on Tue Jul 20 15:57:30 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
Expand Down
39 changes: 4 additions & 35 deletions docs/Kiba/Extend.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,53 +78,22 @@

<dl>
<dt>Defined in:</dt>
<dd>lib/kiba/extend.rb<span class="defines">,<br />
lib/kiba/extend/version.rb,<br /> lib/kiba/extend/fieldset.rb,<br /> lib/kiba/extend/utils/lookup.rb,<br /> lib/kiba/extend/transforms/copy.rb,<br /> lib/kiba/extend/destinations/csv.rb,<br /> lib/kiba/extend/transforms/clean.rb,<br /> lib/kiba/extend/transforms/merge.rb,<br /> lib/kiba/extend/transforms/split.rb,<br /> lib/kiba/extend/transforms/append.rb,<br /> lib/kiba/extend/transforms/cspace.rb,<br /> lib/kiba/extend/transforms/delete.rb,<br /> lib/kiba/extend/transforms/rename.rb,<br /> lib/kiba/extend/transforms/explode.rb,<br /> lib/kiba/extend/transforms/prepend.rb,<br /> lib/kiba/extend/transforms/replace.rb,<br /> lib/kiba/extend/transforms/reshape.rb,<br /> lib/kiba/extend/transforms/ms_access.rb,<br /> lib/kiba/extend/transforms/deduplicate.rb,<br /> lib/kiba/extend/transforms/filter_rows.rb,<br /> lib/kiba/extend/transforms/combine_values.rb</span>
</dd>
<dd>lib/kiba/extend/transforms/prepend.rb</dd>
</dl>

</div>

<h2>Overview</h2><div class="docstring">
<div class="discussion">

<p>Provides a suite of abstract, reusable, well-tested data transformations for use in Kiba ETL pipelines</p>


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


</div><h2>Defined Under Namespace</h2>
<h2>Defined Under Namespace</h2>
<p class="children">


<strong class="modules">Modules:</strong> <span class='object_link'><a href="Extend/Destinations.html" title="Kiba::Extend::Destinations (module)">Destinations</a></span>, <span class='object_link'><a href="Extend/Transforms.html" title="Kiba::Extend::Transforms (module)">Transforms</a></span>, <span class='object_link'><a href="Extend/Utils.html" title="Kiba::Extend::Utils (module)">Utils</a></span>
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Extend/Transforms.html" title="Kiba::Extend::Transforms (module)">Transforms</a></span>



<strong class="classes">Classes:</strong> <span class='object_link'><a href="Extend/Fieldset.html" title="Kiba::Extend::Fieldset (class)">Fieldset</a></span>


</p>


<h2>
Constant Summary
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
</h2>

<dl class="constants">

<dt id="VERSION-constant" class="">VERSION =

</dt>
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1.15.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>

</dl>





Expand All @@ -136,7 +105,7 @@ <h2>
</div>

<div id="footer">
Generated on Tue Jul 20 12:08:37 2021 by
Generated on Tue Jul 20 15:57:30 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
Expand Down
8 changes: 3 additions & 5 deletions docs/Kiba/Extend/Transforms.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@

<dl>
<dt>Defined in:</dt>
<dd>lib/kiba/extend/transforms/copy.rb<span class="defines">,<br />
lib/kiba/extend/transforms/clean.rb,<br /> lib/kiba/extend/transforms/merge.rb,<br /> lib/kiba/extend/transforms/split.rb,<br /> lib/kiba/extend/transforms/append.rb,<br /> lib/kiba/extend/transforms/cspace.rb,<br /> lib/kiba/extend/transforms/delete.rb,<br /> lib/kiba/extend/transforms/rename.rb,<br /> lib/kiba/extend/transforms/explode.rb,<br /> lib/kiba/extend/transforms/prepend.rb,<br /> lib/kiba/extend/transforms/replace.rb,<br /> lib/kiba/extend/transforms/reshape.rb,<br /> lib/kiba/extend/transforms/ms_access.rb,<br /> lib/kiba/extend/transforms/deduplicate.rb,<br /> lib/kiba/extend/transforms/filter_rows.rb,<br /> lib/kiba/extend/transforms/combine_values.rb</span>
</dd>
<dd>lib/kiba/extend/transforms/prepend.rb</dd>
</dl>

</div>
Expand All @@ -89,7 +87,7 @@ <h2>Defined Under Namespace</h2>
<p class="children">


<strong class="modules">Modules:</strong> <span class='object_link'><a href="Transforms/Append.html" title="Kiba::Extend::Transforms::Append (module)">Append</a></span>, <span class='object_link'><a href="Transforms/Clean.html" title="Kiba::Extend::Transforms::Clean (module)">Clean</a></span>, <span class='object_link'><a href="Transforms/CombineValues.html" title="Kiba::Extend::Transforms::CombineValues (module)">CombineValues</a></span>, <span class='object_link'><a href="Transforms/Copy.html" title="Kiba::Extend::Transforms::Copy (module)">Copy</a></span>, <span class='object_link'><a href="Transforms/Cspace.html" title="Kiba::Extend::Transforms::Cspace (module)">Cspace</a></span>, <span class='object_link'><a href="Transforms/Deduplicate.html" title="Kiba::Extend::Transforms::Deduplicate (module)">Deduplicate</a></span>, <span class='object_link'><a href="Transforms/Delete.html" title="Kiba::Extend::Transforms::Delete (module)">Delete</a></span>, <span class='object_link'><a href="Transforms/Explode.html" title="Kiba::Extend::Transforms::Explode (module)">Explode</a></span>, <span class='object_link'><a href="Transforms/FilterRows.html" title="Kiba::Extend::Transforms::FilterRows (module)">FilterRows</a></span>, <span class='object_link'><a href="Transforms/Merge.html" title="Kiba::Extend::Transforms::Merge (module)">Merge</a></span>, <span class='object_link'><a href="Transforms/MsAccess.html" title="Kiba::Extend::Transforms::MsAccess (module)">MsAccess</a></span>, <span class='object_link'><a href="Transforms/Prepend.html" title="Kiba::Extend::Transforms::Prepend (module)">Prepend</a></span>, <span class='object_link'><a href="Transforms/Rename.html" title="Kiba::Extend::Transforms::Rename (module)">Rename</a></span>, <span class='object_link'><a href="Transforms/Replace.html" title="Kiba::Extend::Transforms::Replace (module)">Replace</a></span>, <span class='object_link'><a href="Transforms/Reshape.html" title="Kiba::Extend::Transforms::Reshape (module)">Reshape</a></span>, <span class='object_link'><a href="Transforms/Split.html" title="Kiba::Extend::Transforms::Split (module)">Split</a></span>
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Transforms/Prepend.html" title="Kiba::Extend::Transforms::Prepend (module)">Prepend</a></span>



Expand All @@ -107,7 +105,7 @@ <h2>Defined Under Namespace</h2>
</div>

<div id="footer">
Generated on Tue Jul 20 12:08:37 2021 by
Generated on Tue Jul 20 15:57:30 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/Kiba/Extend/Transforms/Prepend.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h2>Overview</h2><div class="docstring">
</div>

<div id="footer">
Generated on Tue Jul 20 12:08:37 2021 by
Generated on Tue Jul 20 15:57:30 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
Expand Down
72 changes: 53 additions & 19 deletions docs/Kiba/Extend/Transforms/Prepend/FieldToFieldValue.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h2>Overview</h2><div class="docstring">

<p>Adds the value of prepended_field to the beginning of the value(s) of the target_field</p>

<p>If target field value is blank, it is left blank, even if there is a prepended field value. If there is no value in prepended field, target field is left as-is</p>
<p>If target field value is blank, it is left blank, even if there is a prepended field value. If there is no value in prepended field, target field is left as-is</p>

<h1 id="label-Examples">Examples</h1>

Expand All @@ -118,6 +118,7 @@ <h1 id="label-Examples">Examples</h1>
| i | |
| j;k | l;m |
| o;p;q | r;s |
| ;t | u;v
</code></pre>

<p>Used in pipeline as:</p>
Expand All @@ -135,6 +136,7 @@ <h1 id="label-Examples">Examples</h1>
| i | |
| l;m: j;k | l;m |
| r;s: o;p;q | r;s |
| u;v: ;t | u;v |
</code></pre>

<p>Used in pipeline as:</p>
Expand All @@ -153,9 +155,10 @@ <h1 id="label-Examples">Examples</h1>
| i |
| l;m: j;l;m: k |
| r;s: o;r;s: p;r;s: q |
| ;u;v: t |
</code></pre>

<p><strong>This probably introduces extra unexpected <code>mvdelim</code> strings in the result.</strong> If <code>prepended_field</code> contains the <code>mvdelim</code> character, you probably want to set <code>multivalue_prepended_field: true</code>.</p>
<p><strong>This probably introduces extra unexpected <code>mvdelim</code> strings in the result.</strong> If <code>prepended_field</code> contains the <code>mvdelim</code> character, you probably want to set <code>multivalue_prepended_field: true</code>.</p>

<p>Used in pipeline as:</p>

Expand All @@ -169,22 +172,33 @@ <h1 id="label-Examples">Examples</h1>
<pre class="code ruby"><code class="ruby">| a |
|----------------|
| d: c |
| g: e;g: f |
| g: e;f |
| |
| i |
| l: j;m: k |
| r: o;s: p;s: q |
| r: o;s: p;q |
| ;v: t |
</code></pre>

<p>If there are more <code>target_field</code> values than <code>prepend_field</code> values after they are split, the final <code>prepend_field</code> value is prepended to remaining <code>target_field</code> values.</p>
<p>If there are more <code>target_field</code> values than <code>prepend_field</code> values after they are split, nothing is prepended to remaining <code>target_field</code> values.</p>


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


</div>
</div><h2>Defined Under Namespace</h2>
<p class="children">




<strong class="classes">Classes:</strong> <span class='object_link'><a href="FieldToFieldValue/MissingDelimiterError.html" title="Kiba::Extend::Transforms::Prepend::FieldToFieldValue::MissingDelimiterError (class)">MissingDelimiterError</a></span>


</p>




Expand Down Expand Up @@ -219,7 +233,7 @@ <h2>


<span class="summary_desc"><div class='inline'>
<p>A new instance of FieldToFieldValue.</p>
<p>rubocop:disable Metrics/ParameterLists.</p>
</div></span>

</li>
Expand All @@ -243,7 +257,7 @@ <h3 class="signature first" id="initialize-instance_method">
</h3><div class="docstring">
<div class="discussion">

<p>Returns a new instance of FieldToFieldValue.</p>
<p>rubocop:disable Metrics/ParameterLists</p>


</div>
Expand Down Expand Up @@ -358,25 +372,44 @@ <h3 class="signature first" id="initialize-instance_method">

</ul>

<p class="tag_title">Raises:</p>
<ul class="raise">

<li>


<span class='type'>(<tt><span class='object_link'><a href="FieldToFieldValue/MissingDelimiterError.html" title="Kiba::Extend::Transforms::Prepend::FieldToFieldValue::MissingDelimiterError (class)">MissingDelimiterError</a></span></tt>)</span>



&mdash;
<div class='inline'>
<p>if constructed with multivalue_prepended_field true and no mvdelim value</p>
</div>

</li>

</ul>

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


96
97
98
99
100
101
102
103
104</pre>
121
122
123
124
125
126
127
128
129
130</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/kiba/extend/transforms/prepend.rb', line 96</span>
<pre class="code"><span class="info file"># File 'lib/kiba/extend/transforms/prepend.rb', line 121</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>target_field:</span><span class='comma'>,</span> <span class='label'>prepended_field:</span><span class='comma'>,</span> <span class='label'>sep:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>delete_prepended:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>mvdelim:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
<span class='label'>multivalue_prepended_field:</span> <span class='kw'>false</span><span class='rparen'>)</span>
Expand All @@ -386,6 +419,7 @@ <h3 class="signature first" id="initialize-instance_method">
<span class='ivar'>@delete</span> <span class='op'>=</span> <span class='id identifier rubyid_delete_prepended'>delete_prepended</span>
<span class='ivar'>@mvdelim</span> <span class='op'>=</span> <span class='id identifier rubyid_mvdelim'>mvdelim</span>
<span class='ivar'>@multival_prepend</span> <span class='op'>=</span> <span class='id identifier rubyid_multivalue_prepended_field'>multivalue_prepended_field</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="FieldToFieldValue/MissingDelimiterError.html" title="Kiba::Extend::Transforms::Prepend::FieldToFieldValue::MissingDelimiterError (class)">MissingDelimiterError</a></span></span> <span class='kw'>if</span> <span class='ivar'>@multival_prepend</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@mvdelim</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
<span class='kw'>end</span></pre>
</td>
</tr>
Expand All @@ -398,7 +432,7 @@ <h3 class="signature first" id="initialize-instance_method">
</div>

<div id="footer">
Generated on Tue Jul 20 12:08:38 2021 by
Generated on Tue Jul 20 15:57:30 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
Expand Down
Loading

0 comments on commit 6538525

Please sign in to comment.