lib/bolognese/readers/datacite_reader.rb in bolognese-1.11.5 vs lib/bolognese/readers/datacite_reader.rb in bolognese-2.0.0

- old
+ new

@@ -92,17 +92,33 @@ "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 titles = get_titles(meta) + publisher = Array.wrap(meta.dig("publisher")).map do |r| + if r.blank? + nil + elsif r.is_a?(String) + { "name" => r.strip } + elsif r.is_a?(Hash) + { + "name" => r["__content__"].strip, + "publisherIdentifier" => r["publisherIdentifierScheme"] == "ROR" ? normalize_ror(r["publisherIdentifier"]) : r["publisherIdentifier"], + "publisherIdentifierScheme" => r["publisherIdentifierScheme"], + "schemeUri" => r["schemeURI"], + "lang" => r["lang"], + }.compact + end + end.compact.first + descriptions = Array.wrap(meta.dig("descriptions", "description")).map do |r| if r.blank? nil elsif r.is_a?(String) - { "description" => sanitize(r), "descriptionType" => "Abstract" } + { "description" => sanitize(r, new_line: true), "descriptionType" => "Abstract" } elsif r.is_a?(Hash) - { "description" => sanitize(r["__content__"]), "descriptionType" => r["descriptionType"], "lang" => r["lang"] }.compact + { "description" => sanitize(r["__content__"], new_line: true), "descriptionType" => r["descriptionType"], "lang" => r["lang"] }.compact end end.compact rights_list = Array.wrap(meta.dig("rightsList", "rights")).map do |r| if r.blank? nil @@ -285,10 +301,10 @@ "url" => options.fetch(:url, nil).to_s.strip.presence, "titles" => titles, "creators" => get_authors(Array.wrap(meta.dig("creators", "creator"))), "contributors" => get_authors(Array.wrap(meta.dig("contributors", "contributor"))), "container" => set_container(meta), - "publisher" => parse_attributes(meta.fetch("publisher", nil), first: true).to_s.strip.presence, + "publisher" => publisher, "agency" => "datacite", "funding_references" => funding_references, "dates" => dates, "publication_year" => parse_attributes(meta.fetch("publicationYear", nil), first: true).to_s.strip.presence, "descriptions" => descriptions,