Strongly-typed Ruby library for generating JSON-LD

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