lib/bolognese/readers/datacite_reader.rb in bolognese-1.0.3 vs lib/bolognese/readers/datacite_reader.rb in bolognese-1.0.4

- old
+ new

@@ -52,11 +52,11 @@ doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks) ns = doc.collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") } schema_version = Array.wrap(ns).last || "http://datacite.org/schema/kernel-4" doc.remove_namespaces! string = doc.to_xml(:indent => 2) - + meta = Maremma.from_xml(string).to_h.fetch("resource", {}) # validate only when option is set, as this step is expensive and # not needed if XML comes from DataCite MDS if options[:validate] @@ -84,24 +84,24 @@ "ris" => Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN" }.compact title = Array.wrap(meta.dig("titles", "title")).map do |r| if r.is_a?(String) - sanitize(r) + { "text" => sanitize(r) } else { "title_type" => r["titleType"], "lang" => r["lang"], "text" => sanitize(r["__content__"]) }.compact end - end.unwrap + end alternate_identifiers = Array.wrap(meta.dig("alternateIdentifiers", "alternateIdentifier")).map do |r| { "type" => r["alternateIdentifierType"], "name" => r["__content__"] } end.unwrap description = Array.wrap(meta.dig("descriptions", "description")).select { |r| r["descriptionType"] != "SeriesInformation" }.map do |r| - { "type" => r["descriptionType"], "text" => sanitize(r["__content__"]) }.compact - end.unwrap + { "type" => r["descriptionType"], "lang" => r["lang"], "text" => sanitize(r["__content__"]) }.compact + end rights = Array.wrap(meta.dig("rightsList", "rights")).map do |r| { "id" => normalize_url(r["rightsURI"]), "name" => r["__content__"] }.compact - end.unwrap + end keywords = Array.wrap(meta.dig("subjects", "subject")).map do |k| if k.nil? nil elsif k.is_a?(String) sanitize(k)