Sha256: f3bcbcf5f2da8f7ef5bd2df3f0e5b8881130cb09c0690ef22d6fe55897b57796
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 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" => 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? ? is_part_of.merge("name" => is_part_of["title"]) : 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bolognese-0.9.14 | lib/bolognese/writers/schema_org_writer.rb |
bolognese-0.9.13 | lib/bolognese/writers/schema_org_writer.rb |