lib/hyrax/arkivo/metadata_munger.rb in hyrax-3.0.0.pre.rc1 vs lib/hyrax/arkivo/metadata_munger.rb in hyrax-3.0.0.pre.rc2
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
module Hyrax
module Arkivo
CREATOR_TYPES = ['author', 'interviewer', 'director', 'scriptwriter',
'inventor', 'composer', 'cartographer', 'programmer', 'artist',
'bookAuthor'].freeze
@@ -24,31 +25,31 @@
@munged
end
private
- def normalize_keys_and_values
- # First, normalize camelCase symbols to underscore strings
- @metadata.each do |key, value|
- @munged[key.to_s.underscore] = Array.wrap(value)
- end
+ def normalize_keys_and_values
+ # First, normalize camelCase symbols to underscore strings
+ @metadata.each do |key, value|
+ @munged[key.to_s.underscore] = Array.wrap(value)
end
+ end
- def rename_key(from:, to:)
- @munged[to] = @munged.delete(from) if @munged.key?(from)
- end
+ def rename_key(from:, to:)
+ @munged[to] = @munged.delete(from) if @munged.key?(from)
+ end
- def extract_creator_and_contributor_from_creators
- creator_names = []
- contributor_names = []
- @munged['creators'].each do |entry|
- entry['name'] ||= "#{entry.delete('lastName')}, #{entry.delete('firstName')}".strip
- creator_names << entry['name'] if Hyrax::Arkivo::CREATOR_TYPES.include?(entry['creatorType'])
- contributor_names << entry['name'] if Hyrax::Arkivo::CONTRIBUTOR_TYPES.include?(entry['creatorType'])
- end
- @munged['creator'] = creator_names if creator_names.present?
- @munged['contributor'] = contributor_names if contributor_names.present?
- @munged.delete('creators')
+ def extract_creator_and_contributor_from_creators
+ creator_names = []
+ contributor_names = []
+ @munged['creators'].each do |entry|
+ entry['name'] ||= "#{entry.delete('lastName')}, #{entry.delete('firstName')}".strip
+ creator_names << entry['name'] if Hyrax::Arkivo::CREATOR_TYPES.include?(entry['creatorType'])
+ contributor_names << entry['name'] if Hyrax::Arkivo::CONTRIBUTOR_TYPES.include?(entry['creatorType'])
end
+ @munged['creator'] = creator_names if creator_names.present?
+ @munged['contributor'] = contributor_names if contributor_names.present?
+ @munged.delete('creators')
+ end
end
end
end