schema_dot_org 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/README.md +22 -28
- data/lib/schema_dot_org/version.rb +1 -1
- data/schema_dot_org.gemspec +1 -1
- data/test-script.rb +13 -17
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06093d53aa2d45e3ccb4220a1fb8537f6e0f6aae306d14d23e609b6939413aa5'
|
4
|
+
data.tar.gz: a4f5f7a98ef6753142f80c15eb82b37358e0c227d210962b98793cb0e10c3b0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e336d118cff1aa7afb2b73d825314993f7ee67d55a9c4c58ce3c05d0db05d9ca8d078d48903bc76d5f41fdd2931d39136b4f4fbd81c8099ef7158790d34cbc5
|
7
|
+
data.tar.gz: 6bcdfe9ab05c06aafe5b762c84b98a64687d2dfbd9623dc3c2d1e15dde6d1aeae78994ddf4900b21d5428d628214bd12158cf1809a748418515392b03ff47f8c
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
schema_dot_org (1.
|
5
|
-
validated_object
|
4
|
+
schema_dot_org (1.3.0)
|
5
|
+
validated_object (~> 2.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.1.
|
11
|
-
activesupport (= 5.1.
|
12
|
-
activesupport (5.1.
|
10
|
+
activemodel (5.1.5)
|
11
|
+
activesupport (= 5.1.5)
|
12
|
+
activesupport (5.1.5)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
14
|
i18n (~> 0.7)
|
15
15
|
minitest (~> 5.1)
|
16
16
|
tzinfo (~> 1.1)
|
17
17
|
concurrent-ruby (1.0.5)
|
18
18
|
diff-lcs (1.3)
|
19
|
-
i18n (0.9.
|
19
|
+
i18n (0.9.5)
|
20
20
|
concurrent-ruby (~> 1.0)
|
21
21
|
minitest (5.11.3)
|
22
22
|
rake (10.5.0)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
thread_safe (0.3.6)
|
37
37
|
tzinfo (1.2.5)
|
38
38
|
thread_safe (~> 0.1)
|
39
|
-
validated_object (
|
39
|
+
validated_object (2.0.0)
|
40
40
|
activemodel (>= 3.2.21)
|
41
41
|
|
42
42
|
PLATFORMS
|
data/README.md
CHANGED
@@ -9,35 +9,27 @@ every single time.
|
|
9
9
|
|
10
10
|
## Usage
|
11
11
|
|
12
|
-
|
12
|
+
Let's say you have a Rails app. If you put this in a controller:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
org.url = 'https://www.public.law'
|
25
|
-
org.logo = 'https://www.public.law/favicon-196x196.png'
|
26
|
-
org.founding_date = Date.new(2009, 3, 6)
|
27
|
-
org.founder = Person.new do |person|
|
28
|
-
person.name = 'Robb Shecter'
|
29
|
-
end
|
30
|
-
org.founding_location = Place.new do |place|
|
31
|
-
place.address = 'Portland, OR'
|
32
|
-
end
|
33
|
-
end
|
15
|
+
@public_law = Organization.new(
|
16
|
+
name: 'Public.Law',
|
17
|
+
founder: Person.new(name: 'Robb Shecter'),
|
18
|
+
founding_date: Date.new(2009, 3, 6),
|
19
|
+
founding_location: Place.new(address: 'Portland, OR'),
|
20
|
+
email: 'say_hi@public.law',
|
21
|
+
url: 'https://www.public.law',
|
22
|
+
logo: 'https://www.public.law/favicon-196x196.png'
|
23
|
+
)
|
34
24
|
```
|
35
25
|
|
26
|
+
...and this in a template:
|
27
|
+
|
36
28
|
```html
|
37
29
|
<%= @public_law %>
|
38
30
|
```
|
39
31
|
|
40
|
-
|
32
|
+
...you'll get this HTML:
|
41
33
|
|
42
34
|
```html
|
43
35
|
<script type="application/ld+json">
|
@@ -60,8 +52,9 @@ SchemaDotOrg will validate your code, and if correct, will generate Schema.org J
|
|
60
52
|
</script>
|
61
53
|
```
|
62
54
|
|
63
|
-
|
64
|
-
`
|
55
|
+
Strong typing is at work here. SchemaDotOrg will validate your code, and if correct, will generate Schema.org JSON-LD markup.
|
56
|
+
Notice how the `foundingDate` is in the required ISO-8601 format. [The founding date must be a Ruby
|
57
|
+
Date object](https://github.com/dogweather/schema-dot-org/blob/master/lib/schema_dot_org/organization.rb#L11) and so we can ensure correct formatting. In the same way, the `foundingLocation` is a `Place`
|
65
58
|
which adds the proper `@type` attribute.
|
66
59
|
|
67
60
|
### You cannot create invalid markup
|
@@ -71,13 +64,13 @@ refuse to create the incorrect JSON-LD. Instead, you'll get a message explaining
|
|
71
64
|
the problem:
|
72
65
|
|
73
66
|
```ruby
|
74
|
-
Place.new
|
67
|
+
Place.new(address: 12345)
|
75
68
|
# => ArgumentError: Address is class Integer, not String
|
76
69
|
|
77
|
-
Place.new
|
78
|
-
|
79
|
-
|
80
|
-
|
70
|
+
Place.new(
|
71
|
+
address: '12345 Happy Street',
|
72
|
+
author: 'Hemmingway'
|
73
|
+
)
|
81
74
|
# => NoMethodError: undefined method `author='
|
82
75
|
```
|
83
76
|
|
@@ -86,6 +79,7 @@ This type safety comes from the [ValidatedObject gem](https://github.com/dogweat
|
|
86
79
|
## The Goal: Rich enough vocabulary for Google Schema.org parsing
|
87
80
|
|
88
81
|
The plan is to implement a subset of types and attributes relevant to the Google web crawler.
|
82
|
+
See `test-script.rb` for the supported types. Currently, all the attributes are required.
|
89
83
|
Propose new types and attributes by opening an Issue.
|
90
84
|
|
91
85
|
## Installation
|
data/schema_dot_org.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "validated_object"
|
24
|
+
spec.add_dependency "validated_object", "~> 2.0.0"
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.16"
|
27
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/test-script.rb
CHANGED
@@ -7,24 +7,20 @@ require 'schema_dot_org/web_site'
|
|
7
7
|
include SchemaDotOrg
|
8
8
|
|
9
9
|
|
10
|
-
public_law = Organization.new
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
org.founding_location = Place.new do |place|
|
20
|
-
place.address = 'Portland, OR'
|
21
|
-
end
|
22
|
-
end
|
10
|
+
public_law = Organization.new(
|
11
|
+
name: 'Public.Law',
|
12
|
+
founder: Person.new(name: 'Robb Shecter'),
|
13
|
+
founding_date: Date.new(2009, 3, 6),
|
14
|
+
founding_location: Place.new(address: 'Portland, OR'),
|
15
|
+
email: 'say_hi@public.law',
|
16
|
+
url: 'https://www.public.law',
|
17
|
+
logo: 'https://www.public.law/favicon-196x196.png',
|
18
|
+
)
|
23
19
|
|
24
|
-
site_info = WebSite.new
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
site_info = WebSite.new(
|
21
|
+
name: 'Texas Public Law',
|
22
|
+
url: 'https://texas.public.law'
|
23
|
+
)
|
28
24
|
|
29
25
|
puts site_info
|
30
26
|
puts public_law
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_dot_org
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: validated_object
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.7.
|
115
|
+
rubygems_version: 2.7.6
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: JSON-LD generator for Schema.org vocabulary
|