lib/bolognese/readers/schema_org_reader.rb in bolognese-1.0.19 vs lib/bolognese/readers/schema_org_reader.rb in bolognese-1.0.20
- old
+ new
@@ -31,10 +31,12 @@
if string.present?
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
end
+ read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:string, :sandbox))
+
meta = string.present? ? Maremma.from_json(string) : {}
identifier = Array.wrap(meta.fetch("identifier", nil))
if identifier.length > 1
alternate_identifiers = identifier[1..-1].map do |r|
@@ -106,11 +108,11 @@
dates << { "date" => meta.fetch("datePublished"), "dateType" => "Issued" } if meta.fetch("datePublished", nil).present?
dates << { "date" => meta.fetch("dateCreated"), "dateType" => "Created" } if meta.fetch("dateCreated", nil).present?
dates << { "date" => meta.fetch("dateModified"), "dateType" => "Updated" } if meta.fetch("dateModified", nil).present?
publication_year = meta.fetch("datePublished")[0..3] if meta.fetch("datePublished", nil).present?
- state = meta.present? ? "findable" : "not_found"
+ state = meta.present? || read_options.present? ? "findable" : "not_found"
geo_locations = Array.wrap(meta.fetch("spatialCoverage", nil)).map do |gl|
if gl.dig("geo", "box")
s, w, n, e = gl.dig("geo", "box").split(" ", 4)
geo_location_box = {
"westBoundLongitude" => w,
@@ -157,10 +159,10 @@
"subjects" => subjects,
"state" => state,
"schema_version" => meta.fetch("schemaVersion", nil).to_s.presence,
"funding_references" => funding_references,
"geo_locations" => geo_locations
- }
+ }.merge(read_options)
end
def schema_org_related_identifier(meta, relation_type: nil)
normalize_ids(ids: meta.fetch(relation_type, nil), relation_type: SO_TO_DC_RELATION_TYPES[relation_type])
end