Skip to content

Commit

Permalink
Handle Replace::FieldValueWithStaticMapping fallback_val string
Browse files Browse the repository at this point in the history
  • Loading branch information
kspurgin committed Nov 30, 2020
1 parent 059d47f commit b63887c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
kiba-extend (1.5.0)
kiba-extend (1.6.0)
activesupport
kiba (>= 3.0.0)
kiba-common (>= 0.9.0)
Expand All @@ -10,23 +10,23 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.3.2)
activesupport (6.0.3.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
coderay (1.1.2)
concurrent-ruby (1.1.6)
concurrent-ruby (1.1.7)
diff-lcs (1.3)
facets (3.1.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
kiba (3.0.0)
kiba-common (1.0.0)
kiba (3.5.0)
kiba-common (1.1.0)
kiba (>= 1.0.0, < 4)
method_source (0.9.2)
minitest (5.14.1)
minitest (5.14.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand All @@ -45,10 +45,10 @@ GEM
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
thread_safe (0.3.6)
tzinfo (1.2.7)
tzinfo (1.2.8)
thread_safe (~> 0.1)
xxhash (0.4.0)
zeitwerk (2.4.0)
zeitwerk (2.4.1)

PLATFORMS
ruby
Expand Down
2 changes: 2 additions & 0 deletions lib/kiba/extend/transforms/replace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def process(row)
newvals << oval
when :nil
newvals << nil
else
newvals << @fallback
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/kiba/extend/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Kiba
module Extend
VERSION = "1.6.0"
VERSION = "1.6.1"
end
end
16 changes: 16 additions & 0 deletions spec/kiba/extend/transforms/replace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@
expect(result).to eq(expected)
end
end

context 'and :fallback_val = a string' do
it 'sends the string through to new column' do
expected = [
{:id=>'1', :name=>'Unnamed keet', :gender=>'unknown'},
{:id=>'2', :name=>'Kernel', :gender=>'female'}
]
result = execute_job(filename: test_csv,
xform: Replace::FieldValueWithStaticMapping,
xformopt: {source: :sex,
target: :gender,
mapping: mapping,
fallback_val: 'unknown'})
expect(result).to eq(expected)
end
end
end
end
end

0 comments on commit b63887c

Please sign in to comment.