lib/bolognese/readers/datacite_reader.rb in bolognese-1.0.19 vs lib/bolognese/readers/datacite_reader.rb in bolognese-1.0.20
- old
+ new
@@ -47,10 +47,12 @@
"client_id" => attributes.fetch("datacentre_symbol", nil),
"content_url" => content_url }
end
def read_datacite(string: nil, **options)
+ read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:string, :sandbox))
+
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)
@@ -178,11 +180,11 @@
"geoLocationPlace" => parse_attributes(gl["geoLocationPlace"], first: true).to_s.strip.presence
}.compact
end
end.compact
periodical = set_periodical(meta)
- state = doi.present? ? "findable" : "not_found"
+ state = doi.present? || read_options.present? ? "findable" : "not_found"
{ "id" => id,
"types" => types,
"doi" => doi,
"alternate_identifiers" => alternate_identifiers,
@@ -205,10 +207,10 @@
"related_identifiers" => related_identifiers,
"formats" => formats,
"sizes" => sizes,
"schema_version" => schema_version,
"state" => state
- }
+ }.merge(read_options)
end
def set_periodical(meta)
container_title = Array.wrap(meta.dig("descriptions", "description")).find { |r| r["descriptionType"] == "SeriesInformation" }.to_h.fetch("__content__", nil)
is_part_of = Array.wrap(meta.dig("relatedIdentifiers", "relatedIdentifier")).find { |ri| ri["relationType"] == "IsPartOf" }.to_h