lib/bolognese/writers/schema_org_writer.rb in bolognese-0.15.9 vs lib/bolognese/writers/schema_org_writer.rb in bolognese-1.0

- old
+ new

@@ -5,40 +5,41 @@ module SchemaOrgWriter def schema_hsh { "@context" => identifier.present? ? "http://schema.org" : nil, "@type" => type, "@id" => identifier, - "identifier" => to_schema_org_identifier(identifier, alternate_identifier: alternate_identifier), + "identifier" => to_schema_org_identifier(identifier, alternate_identifiers: alternate_identifiers), "url" => b_url, "additionalType" => additional_type, "name" => parse_attributes(title, content: "text", first: true), - "author" => to_schema_org(author), + "author" => to_schema_org(creator), "editor" => to_schema_org(editor), "description" => parse_attributes(description, content: "text", first: true), - "license" => Array.wrap(license).map { |l| l["id"] }.compact.unwrap, + "license" => Array.wrap(rights).map { |l| l["id"] }.compact.unwrap, "version" => b_version, "keywords" => keywords.present? ? Array.wrap(keywords).map { |k| parse_attributes(k, content: "text", first: true) }.join(", ") : nil, "inLanguage" => language, - "contentSize" => content_size, - "encodingFormat" => content_format, - "dateCreated" => date_created, + "contentSize" => size, + "encodingFormat" => b_format, + "dateCreated" => Array.wrap(dates).find { |d| d["type"] == "Created" }.to_h.fetch("__content__", nil), "datePublished" => date_published, "dateModified" => date_modified, "pageStart" => first_page, "pageEnd" => last_page, - "spatialCoverage" => spatial_coverage, - "sameAs" => to_schema_org(is_identical_to), - "isPartOf" => (type == "Dataset") ? nil : to_schema_org_container(is_part_of, container_title: container_title, type: type), - "hasPart" => to_schema_org(has_part), - "predecessor_of" => to_schema_org(is_previous_version_of), - "successor_of" => to_schema_org(is_new_version_of), - "citation" => to_schema_org(references), + "spatialCoverage" => to_schema_org_spatial_coverage(geo_location), + "sameAs" => to_schema_org_relation(related_identifiers: related_identifiers, relation_type: "IsIdenticalTo"), + "isPartOf" => to_schema_org_relation(related_identifiers: related_identifiers, relation_type: "IsPartOf"), + "hasPart" => to_schema_org_relation(related_identifiers: related_identifiers, relation_type: "HasPart"), + "predecessor_of" => to_schema_org_relation(related_identifiers: related_identifiers, relation_type: "IsPreviousVersionOf"), + "successor_of" => to_schema_org_relation(related_identifiers: related_identifiers, relation_type: "IsNewVersionOf"), + "citation" => to_schema_org_relation(related_identifiers: related_identifiers, relation_type: "References"), "@reverse" => reverse.presence, "contentUrl" => content_url, "schemaVersion" => schema_version, - "includedInDataCatalog" => (type == "Dataset") ? to_schema_org_container(is_part_of, container_title: container_title, type: type) : nil, + "periodical" => (type != "Dataset") && periodical ? to_schema_org(periodical) : nil, + "includedInDataCatalog" => (type == "Dataset") && periodical ? to_schema_org(periodical) : nil, "publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher } : nil, - "funding" => to_schema_org(funding), + "funder" => to_schema_org_funder(funding_references), "provider" => service_provider.present? ? { "@type" => "Organization", "name" => service_provider } : nil }.compact.presence end def schema_org