schema_dot_org 2.3.3 → 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 +5 -2
- 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
@@ -24,7 +24,9 @@ Good structured data [helps enhance a website's search result appearance](https:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
Let's say you have a Rails app. First write plain-ruby code in a helper or 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
|
28
30
|
the structured data object you want in your web page:
|
29
31
|
|
30
32
|
```ruby
|
@@ -117,7 +119,7 @@ In my experience, I never get errors from the lib. I code it once, it works, and
|
|
117
119
|
I move on to other things.
|
118
120
|
|
119
121
|
> [!NOTE]
|
120
|
-
> 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,
|
121
123
|
> is a thin wrapper around ActiveRecord::Validations. So there's nothing magical going on here.
|
122
124
|
|
123
125
|
## Supported Schema.org Types
|
@@ -127,6 +129,7 @@ See each type's RSpec for an example of how to use it.
|
|
127
129
|
| Name | Schema.org Page | RSpec Spec | Source Code |
|
128
130
|
| ---------------------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
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) |
|
130
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) |
|
131
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) |
|
132
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) |
|
@@ -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
|