schema_dot_org 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2dfc9bdff909553c6fe2167179c1271676e9cee1d1422dd65eb26e0816d6dbd
4
- data.tar.gz: 34a1e0e972e11ec617d7f4fc5c8317b15f63af7168b750ff75949ab0c1326aad
3
+ metadata.gz: ab85a88b3210a47d564f4f6cc3fd61db14a79bad76f61e4ae529534bef14a315
4
+ data.tar.gz: '090f666086836b9e1d57f8168443e667d72412623c33e3fef5cecf0257718240'
5
5
  SHA512:
6
- metadata.gz: 52c0da39657a4ffba96c64eee10c489f6d0102196fd6b1e7e097a410f449c0fa5c16b0be535a804493bdf5e2671e45ae82c5cc6e1bb795e373844ed114bf594a
7
- data.tar.gz: 3db26074e88294c49d4e50705d7a8b059668c741a7b3a0942d35779f107006034df4556c17fae605835ade306028e5a6b508267bd5053f64718f78fe1c3d29fe
6
+ metadata.gz: 50f6a8b6b500b45eb7f999ec09ea92453be82afdd79b709a879f547c40768fc547dceca8d6f5cbd86b6196ec1f0973682e35679dfe201140901dfd0d91de5ac5
7
+ data.tar.gz: 494fb2b2e97e9f93597de163461f498f7c90ca364094484fda60613bb047128b31b3d78b6e3635498dd9f6a2cb27f563470f63daef919a360da103b644ff142e
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schema_dot_org (2.3.2)
4
+ schema_dot_org (2.4.0)
5
5
  validated_object (~> 2.3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,15 +1,32 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/schema_dot_org.svg)](https://badge.fury.io/rb/schema_dot_org)
2
2
 
3
+ ## Table of Contents
4
+
5
+ - [SchemaDotOrg](#schemadotorg)
6
+ - [Usage](#usage)
7
+ - [Principle: No silent failures](#principle-no-silent-failures)
8
+ - [You are prevented from creating invalid markup](#you-are-prevented-from-creating-invalid-markup)
9
+ - [Supported Schema.org Types](#supported-schemaorg-types)
10
+ - [Examples](#examples)
11
+ - [WebSite](#website)
12
+ - [Organization](#organization)
13
+ - [Installation](#installation)
14
+ - [Development](#development)
15
+ - [Contributing](#contributing)
16
+ - [License](#license)
17
+
3
18
  # SchemaDotOrg
4
19
 
5
20
  Easily create [Structured Data](https://developers.google.com/search/docs/guides/intro-structured-data) with **correct syntax and semantics**.
6
21
  Good structured data [helps enhance a website's search result appearance](https://developers.google.com/search/docs/guides/enhance-site):
7
22
 
8
- > Google Search works hard to understand the content of a page. You can help us by providing explicit clues about the meaning of a page…
23
+ > "Google Search works hard to understand the content of a page. You can help us by providing explicit clues about the meaning of a page…"
9
24
 
10
25
  ## Usage
11
26
 
12
- Let's say you have a Rails app. First write plain-ruby code in a controller. Just instantiate
27
+ Let's say you have a Rails app. First write plain-ruby code in a helper or controller.
28
+
29
+ Here's what that'd look like in a controller. Instantiate
13
30
  the structured data object you want in your web page:
14
31
 
15
32
  ```ruby
@@ -102,7 +119,7 @@ In my experience, I never get errors from the lib. I code it once, it works, and
102
119
  I move on to other things.
103
120
 
104
121
  > [!NOTE]
105
- > This automatic validation comes from my [ValidatedObject gem](https://github.com/dogweather/validated_object), which in turn,
122
+ > This automatic validation comes from my [ValidatedObject gem](https://github.com/public-law/validated_object), which in turn,
106
123
  > is a thin wrapper around ActiveRecord::Validations. So there's nothing magical going on here.
107
124
 
108
125
  ## Supported Schema.org Types
@@ -111,26 +128,27 @@ See each type's RSpec for an example of how to use it.
111
128
 
112
129
  | Name | Schema.org Page | RSpec Spec | Source Code |
113
130
  | ---------------------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
114
- | AggregateOffer | [Schema.org](https://schema.org/AggregateOffer) | | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/aggregate_offer.rb) |
115
- | CollegeOrUniversity | [Schema.org](https://schema.org/CollegeOrUniversity) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/college_or_university_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/college_or_university.rb) |
116
- | Comment | [Schema.org](https://schema.org/Comment) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/comment_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/comment.rb) |
117
- | ContactPoint | [Schema.org](https://schema.org/ContactPoint) | | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/contact_point.rb) |
118
- | DiscussionForumPosting | [Schema.org](https://schema.org/DiscussionForumPosting) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/discussion_forum_posting_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/discussion_forum_posting.rb) |
119
- | InteractionCounter | [Schema.org](https://schema.org/InteractionCounter) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/interaction_counter_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/interaction_counter.rb) |
120
- | ItemList | [Schema.org](https://schema.org/ItemList) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/item_list_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/item_list.rb) |
121
- | Language | [Schema.org](https://schema.org/Language) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/language_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/language.rb) |
122
- | ListItem | [Schema.org](https://schema.org/ListItem) | | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/list_item.rb) |
123
- | Offer | [Schema.org](https://schema.org/Offer) | | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/offer.rb) |
124
- | Organization | [Schema.org](https://schema.org/Organization) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/organization_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/organization.rb) |
125
- | Person | [Schema.org](https://schema.org/Person) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/person_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/person.rb) |
126
- | Place | [Schema.org](https://schema.org/Place) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/place_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/place.rb) |
127
- | Product | [Schema.org](https://schema.org/Product) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/product_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/product.rb) |
128
- | SearchAction | [Schema.org](https://schema.org/SearchAction) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/search_action_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/search_action.rb) |
129
- | WebSite | [Schema.org](https://schema.org/WebSite) | [RSpec](https://github.com/dogweather/schema-dot-org/blob/master/spec/schema_dot_org/web_site_spec.rb) | [Source](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/web_site.rb) |
131
+ | AggregateOffer | [Schema.org](https://schema.org/AggregateOffer) | | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/aggregate_offer.rb) |
132
+ | BreadcrumbList | [Schema.org](https://schema.org/BreadcrumbList) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/breadcrumb_list_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/breadcrumb_list.rb) |
133
+ | CollegeOrUniversity | [Schema.org](https://schema.org/CollegeOrUniversity) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/college_or_university_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/college_or_university.rb) |
134
+ | Comment | [Schema.org](https://schema.org/Comment) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/comment_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/comment.rb) |
135
+ | ContactPoint | [Schema.org](https://schema.org/ContactPoint) | | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/contact_point.rb) |
136
+ | DiscussionForumPosting | [Schema.org](https://schema.org/DiscussionForumPosting) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/discussion_forum_posting_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/discussion_forum_posting.rb) |
137
+ | InteractionCounter | [Schema.org](https://schema.org/InteractionCounter) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/interaction_counter_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/interaction_counter.rb) |
138
+ | ItemList | [Schema.org](https://schema.org/ItemList) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/item_list_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/item_list.rb) |
139
+ | Language | [Schema.org](https://schema.org/Language) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/language_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/language.rb) |
140
+ | ListItem | [Schema.org](https://schema.org/ListItem) | | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/list_item.rb) |
141
+ | Offer | [Schema.org](https://schema.org/Offer) | | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/offer.rb) |
142
+ | Organization | [Schema.org](https://schema.org/Organization) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/organization_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/organization.rb) |
143
+ | Person | [Schema.org](https://schema.org/Person) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/person_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/person.rb) |
144
+ | Place | [Schema.org](https://schema.org/Place) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/place_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/place.rb) |
145
+ | Product | [Schema.org](https://schema.org/Product) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/product_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/product.rb) |
146
+ | SearchAction | [Schema.org](https://schema.org/SearchAction) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/search_action_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/search_action.rb) |
147
+ | WebSite | [Schema.org](https://schema.org/WebSite) | [RSpec](https://github.com/public-law/schema-dot-org/blob/master/spec/schema_dot_org/web_site_spec.rb) | [Source](https://github.com/public-law/schema-dot-org/blob/master/lib/schema_dot_org/web_site.rb) |
130
148
 
131
149
  ## Examples
132
150
 
133
- Here are a few examples. [The source code for these is extremely easy to read.](https://github.com/dogweather/schema-dot-org/tree/master/lib/schema_dot_org) Check them out to see all the available attributes.
151
+ Here are a few examples. [The source code for these is extremely easy to read.](https://github.com/public-law/schema-dot-org/tree/master/lib/schema_dot_org) Check them out to see all the available attributes.
134
152
 
135
153
  ### WebSite
136
154
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ #
5
+ # Model the Google / Schema.org `BreadcrumbList`.
6
+ #
7
+ # The intent is to primarily support Google's BreadcrumbList. Properties
8
+ # from Schema.org are welcome if desired.
9
+ #
10
+ # See https://developers.google.com/search/docs/appearance/structured-data/breadcrumb
11
+ # and https://schema.org/BreadcrumbList
12
+ #
13
+ module SchemaDotOrg
14
+ class BreadcrumbList < SchemaType
15
+ validated_attr :itemListElement, type: Array, presence: true
16
+ end
17
+ end
@@ -9,9 +9,22 @@ require_relative 'product'
9
9
  module SchemaDotOrg
10
10
  class ListItem < SchemaType
11
11
  validated_attr :image, type: String, allow_nil: true
12
- validated_attr :item, type: SchemaDotOrg::Product, allow_nil: true
12
+ validated_attr :item, type: Object, allow_nil: true # Allow String or SchemaType
13
13
  validated_attr :name, type: String, allow_nil: true
14
14
  validated_attr :position, type: Integer, presence: true
15
15
  validated_attr :url, type: String, allow_nil: true
16
+
17
+ validate :item_must_be_valid_type
18
+
19
+
20
+ private
21
+
22
+ def item_must_be_valid_type
23
+ return if item.nil?
24
+ return if item.is_a?(String) # URL
25
+ return if item.is_a?(SchemaDotOrg::SchemaType) # Any Schema.org type
26
+
27
+ errors.add(:item, 'must be a URL string or Schema.org object, but was: ' + item.class.name + ' (' + item.inspect + ')')
28
+ end
16
29
  end
17
30
  end
@@ -116,6 +116,7 @@ end
116
116
 
117
117
 
118
118
  require 'schema_dot_org/aggregate_offer'
119
+ require 'schema_dot_org/breadcrumb_list'
119
120
  require 'schema_dot_org/college_or_university'
120
121
  require 'schema_dot_org/comment'
121
122
  require 'schema_dot_org/contact_point'
@@ -7,9 +7,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
7
  Gem::Specification.new do |spec|
8
8
  spec.required_ruby_version = '>= 3.0'
9
9
  spec.name = 'schema_dot_org'
10
- spec.version = '2.3.2'
11
- spec.authors = ['Robb Shecter']
12
- spec.email = ['robb@public.law']
10
+ spec.version = '2.4.0'
11
+ spec.authors = ['Robert Shecter']
12
+ spec.email = ['robert@public.law']
13
13
 
14
14
  spec.summary = 'JSON-LD generator for Schema.org vocabulary'
15
15
  spec.description = 'Creates well-formed website metadata with ' \
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_dot_org
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - Robb Shecter
7
+ - Robert Shecter
8
8
  bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '3.12'
68
68
  description: Creates well-formed website metadata with strongly typed Ruby.
69
69
  email:
70
- - robb@public.law
70
+ - robert@public.law
71
71
  executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
@@ -85,6 +85,7 @@ files:
85
85
  - bin/tapioca
86
86
  - lib/schema_dot_org.rb
87
87
  - lib/schema_dot_org/aggregate_offer.rb
88
+ - lib/schema_dot_org/breadcrumb_list.rb
88
89
  - lib/schema_dot_org/college_or_university.rb
89
90
  - lib/schema_dot_org/comment.rb
90
91
  - lib/schema_dot_org/contact_point.rb