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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db371250ff6b29c349d658e85503ab19412d35e491a9800827f129f9d93413d0
4
- data.tar.gz: e429bee64238b2f43697cd2f7bb95984eda07389573b9148008bfe2f0c84079b
3
+ metadata.gz: '06093d53aa2d45e3ccb4220a1fb8537f6e0f6aae306d14d23e609b6939413aa5'
4
+ data.tar.gz: a4f5f7a98ef6753142f80c15eb82b37358e0c227d210962b98793cb0e10c3b0d
5
5
  SHA512:
6
- metadata.gz: e55d94f56727c50903971dfe8b88ecbb1193e7132e62b4f30d5a65bd2eb34f00ac3c6dd35f2857190bd86982c0dbc2c1f2d0ffb0131b85913e060df93901643f
7
- data.tar.gz: 98c43a569614deccbacfbadc7e587b309f8a78975aa03e06c60f47a4fb653cdb3087ac3b4fb2b129e27691a673a5e955102261b206af99d941ae645e46087993
6
+ metadata.gz: 5e336d118cff1aa7afb2b73d825314993f7ee67d55a9c4c58ce3c05d0db05d9ca8d078d48903bc76d5f41fdd2931d39136b4f4fbd81c8099ef7158790d34cbc5
7
+ data.tar.gz: 6bcdfe9ab05c06aafe5b762c84b98a64687d2dfbd9623dc3c2d1e15dde6d1aeae78994ddf4900b21d5428d628214bd12158cf1809a748418515392b03ff47f8c
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schema_dot_org (1.2.0)
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.4)
11
- activesupport (= 5.1.4)
12
- activesupport (5.1.4)
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.4)
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 (1.1.0)
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
- Create the tree of objects, and then call `#to_s` in e.g., a Rails template:
12
+ Let's say you have a Rails app. If you put this in a controller:
13
13
 
14
14
  ```ruby
15
- require 'schema_dot_org/person'
16
- require 'schema_dot_org/place'
17
- require 'schema_dot_org/organization'
18
- include SchemaDotOrg
19
-
20
-
21
- @public_law = Organization.new do |org|
22
- org.name = 'Public.Law'
23
- org.email = 'say_hi@public.law'
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
- SchemaDotOrg will validate your code, and if correct, will generate Schema.org JSON-LD markup:
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
- Notice how the `foundingDate` is in the required ISO-8601 format. The attribute requires a Ruby
64
- `Date` and so can ensure correct formatting. In the same way, the `foundingLocation` is a `Place`
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 { |p| p.address = 12345 }
67
+ Place.new(address: 12345)
75
68
  # => ArgumentError: Address is class Integer, not String
76
69
 
77
- Place.new do |p|
78
- p.address = '12345 Happy Street'
79
- p.author = 'Hemmingway'
80
- end
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
@@ -1,3 +1,3 @@
1
1
  module SchemaDotOrg
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -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"
@@ -7,24 +7,20 @@ require 'schema_dot_org/web_site'
7
7
  include SchemaDotOrg
8
8
 
9
9
 
10
- public_law = Organization.new do |org|
11
- org.name = 'Public.Law'
12
- org.founding_date = Date.new(2009, 3, 6)
13
- org.email = 'say_hi@public.law'
14
- org.url = 'https://www.public.law'
15
- org.logo = 'https://www.public.law/favicon-196x196.png'
16
- org.founder = Person.new do |person|
17
- person.name = 'Robb Shecter'
18
- end
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 do |website|
25
- website.name = 'Texas Public Law'
26
- website.url = 'https://texas.public.law'
27
- end
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.2.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-13 00:00:00.000000000 Z
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: '0'
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: '0'
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.5
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