W3C home > Mailing lists > Public > public-schemaorg@w3.org > February 2018

Strongly-typed Ruby library for generating JSON-LD

From: Robb Shecter <robb@public.law>
Date: Tue, 20 Feb 2018 22:54:32 +0000
Message-ID: <CABQwFw_PfbAihz7iqfODsuA9_dgyL4kNzR+PXQVF1O2dyzb2pg@mail.gmail.com>
To: public-schemaorg@w3.org
Hi,

A new project of mine, here's what it delivers. I have this in the app:

@public_law = Organization.new do |org|
  org.name    = 'Public.Law'
  org.email   = 'say_hi@public.law'
  org.url     = 'https://www.public.law'
  org.logo    = 'https://www.public.law/favicon-196x196.png'
  org.founding_date = Date.new(2009, 3, 6)
  org.founder = Person.new do |person|
    person.name = 'Robb Shecter'
  end
  org.founding_location = Place.new do |place|
    place.address = 'Portland, OR'
  end
end


....this in a template:


<%= @public_law %>


....and I get this in my HTML:


<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "name": "Public.Law",
  "email": "say_hi@public.law",
  "url": "https://www.public.law",
  "logo": "https://www.public.law/favicon-196x196.png",
  "foundingDate": "2009-03-06",
  "founder": {
    "@type": "Person",
    "name": "Robb Shecter"
  },
  "foundingLocation": {
    "@type": "Place",
    "address": "Portland, OR"
  }
</script>


The strong typing enforces schema.org types and hierarchy. Currently
covers my Google-supported needs, and is easily extensible.

https://github.com/dogweather/schema-dot-org
Received on Tuesday, 20 February 2018 23:22:56 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 February 2018 23:22:57 UTC