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 +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +38 -20
- data/lib/schema_dot_org/breadcrumb_list.rb +17 -0
- data/lib/schema_dot_org/list_item.rb +14 -1
- data/lib/schema_dot_org.rb +1 -0
- data/schema_dot_org.gemspec +3 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab85a88b3210a47d564f4f6cc3fd61db14a79bad76f61e4ae529534bef14a315
|
4
|
+
data.tar.gz: '090f666086836b9e1d57f8168443e667d72412623c33e3fef5cecf0257718240'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50f6a8b6b500b45eb7f999ec09ea92453be82afdd79b709a879f547c40768fc547dceca8d6f5cbd86b6196ec1f0973682e35679dfe201140901dfd0d91de5ac5
|
7
|
+
data.tar.gz: 494fb2b2e97e9f93597de163461f498f7c90ca364094484fda60613bb047128b31b3d78b6e3635498dd9f6a2cb27f563470f63daef919a360da103b644ff142e
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,32 @@
|
|
1
1
|
[](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.
|
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/
|
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/
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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/
|
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:
|
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
|
data/lib/schema_dot_org.rb
CHANGED
data/schema_dot_org.gemspec
CHANGED
@@ -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.
|
11
|
-
spec.authors = ['
|
12
|
-
spec.email = ['
|
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.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
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
|
-
-
|
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
|