Sha256: 6117e6d8e7becb8a435077a4581780af93913705ad73de4cf5805fc8855cfbdc
Contents?: true
Size: 1.74 KB
Versions: 3
Compression:
Stored size: 1.74 KB
Contents
module Bolognese module Writers module SchemaOrgWriter def schema_hsh { "@context" => id.present? ? "http://schema.org" : nil, "@type" => type, "@id" => id, "url" => url, "additionalType" => additional_type, "name" => name, "alternateName" => alternate_name, "author" => to_schema_org(author), "editor" => to_schema_org(editor), "description" => Array.wrap(description).map { |d| d["text"] }.compact.unwrap, "license" => Array.wrap(license).map { |l| l["id"] }.compact.unwrap, "version" => version, "keywords" => keywords, "inLanguage" => language, "contentSize" => content_size, "dateCreated" => date_created, "datePublished" => date_published, "dateModified" => date_modified, "pagination" => pagination, "spatialCoverage" => spatial_coverage, "sameAs" => same_as, "isPartOf" => is_part_of.present? ? to_schema_org(is_part_of) : nil, "hasPart" => has_part, "predecessor_of" => is_previous_version_of, "successor_of" => is_new_version_of, "citation" => Array.wrap(references).map { |r| r.except("relationType").merge("@type" => "CreativeWork") }.unwrap, "@reverse" => reverse.presence, "schemaVersion" => schema_version, "publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher } : nil, "funder" => funder, "provider" => provider.present? ? { "@type" => "Organization", "name" => provider } : nil }.compact.presence end def schema_org JSON.pretty_generate schema_hsh end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bolognese-0.9.17 | lib/bolognese/writers/schema_org_writer.rb |
bolognese-0.9.16 | lib/bolognese/writers/schema_org_writer.rb |
bolognese-0.9.15 | lib/bolognese/writers/schema_org_writer.rb |