Skip to content

Commit

Permalink
Allow mapping of multiple ingest fields to a single californica field
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefilter committed Jun 4, 2019
1 parent 4a8c25b commit 899e444
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ RSpec/DescribeClass:
- 'spec/system/search_crawler_spec.rb'
- 'spec/tasks/**/*'

Style/BracesAroundHashParameters:
Exclude:
- 'spec/importers/californica_mapper_spec.rb'

Style/Next:
Exclude:
- 'app/uploaders/csv_manifest_validator.rb'
4 changes: 3 additions & 1 deletion app/importers/californica_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def rights_statement
def map_field(name)
return unless CALIFORNICA_TERMS_MAP.keys.include?(name)

metadata[CALIFORNICA_TERMS_MAP[name]]&.split(DELIMITER)
Array.wrap(CALIFORNICA_TERMS_MAP[name]).map do |source_field|
metadata[source_field]&.split(DELIMITER)
end.flatten.compact
end

# Determine what Collection this object should be part of.
Expand Down
18 changes: 18 additions & 0 deletions spec/importers/californica_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@
end
end

describe '#map_field' do
let(:metadata) do
{ 'Single.source' => 'specific',
'Source.one' => 'ecolog|~|next',
'Source.two' => 'nihilism' }
end

it 'maps from a single source field' do
stub_const('CalifornicaMapper::CALIFORNICA_TERMS_MAP', { 'single_source' => 'Single.source' })
expect(mapper.map_field('single_source')).to eq(['specific'])
end

it 'maps from a list of source fields' do
stub_const('CalifornicaMapper::CALIFORNICA_TERMS_MAP', { 'multi_source' => ['Source.one', 'Source.two'] })
expect(mapper.map_field('multi_source')).to eq(['ecolog', 'next', 'nihilism'])
end
end

describe '#ark' do
it "maps the required ark field" do
expect(mapper.ark).to eq('ark:/21198/zz0002nq4w')
Expand Down

0 comments on commit 899e444

Please sign in to comment.