schema_dot_org 0.5.0 → 1.0.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: 0e11781fcf6716d6ead9eeb5128d405c6a7b1f417b59a34ff81ac9a79b5bebc4
4
- data.tar.gz: 894473636d64822d08f87ebbdc082477d892f5b3496b9c421fa18429c11bf39b
3
+ metadata.gz: aeaaa5ba2b21c92d56fec94da4e9326270fa751320365461f092ca44e55c0a65
4
+ data.tar.gz: 5747c59f5e1060866a115e7a5a02419091901817a5890e22c51e5efcb828c8bc
5
5
  SHA512:
6
- metadata.gz: c8ac48952653f553840cd8bc8282040cad63b8782a0aca6d8dc908032a6c178ceff8e934b10b6088aa6dbc8e8e0860c758cb90aaa1fb59b2fb8a56b5822752df
7
- data.tar.gz: 18129d7a92e1c39e71d412fcc70e90e61b415c669380718625b7a24c1d51533af054bf2e5b40e4558fa608c060a02fce23b344984a4dacb6edb1770d6dcb40f9
6
+ metadata.gz: bf34451c2987395d35b62c946fed6ed937b0f938c29ee5dd8825b2892357e41f98965b337df3bd727d1622971260791d230790a4e66a567c6961b925a2bf238b
7
+ data.tar.gz: 75a43fbd24fd903079598e0ad748d882856f6157002d6cd71631acf76823f5242fc8c07a6e59fc8abd40a3b01db4d500fe5dd81c79a0feda80de9ccf8ba452e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schema_dot_org (0.5.0)
4
+ schema_dot_org (1.0.0)
5
5
  validated_object
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -18,15 +18,17 @@ include SchemaDotOrg
18
18
 
19
19
 
20
20
  @public_law = Organization.new do |org|
21
- org.name = "Public.Law"
22
- org.email = "say_hi@public.law"
23
- org.url = "https://www.public.law"
21
+ org.name = 'Public.Law'
22
+ org.email = 'say_hi@public.law'
23
+ org.url = 'https://www.public.law'
24
+ org.logo = 'https://www.public.law/favicon-196x196.png'
25
+ org.same_as = 'https://www.facebook.com/PublicDotLaw'
24
26
  org.founding_date = Date.new(2009, 3, 6)
25
27
  org.founder = Person.new do |person|
26
- person.name = "Robb Shecter"
28
+ person.name = 'Robb Shecter'
27
29
  end
28
30
  org.founding_location = Place.new do |place|
29
- place.address = "Portland, OR"
31
+ place.address = 'Portland, OR'
30
32
  end
31
33
  end
32
34
  ```
@@ -45,6 +47,8 @@ SchemaDotOrg will validate your code, and if correct, will generate Schema.org J
45
47
  "name": "Public.Law",
46
48
  "email": "say_hi@public.law",
47
49
  "url": "https://www.public.law",
50
+ "logo": "https://www.public.law/favicon-196x196.png",
51
+ "same_as": "https://www.facebook.com/PublicDotLaw",
48
52
  "foundingDate": "2009-03-06",
49
53
  "founder": {
50
54
  "@type": "Person",
@@ -61,7 +65,7 @@ Notice how the `foundingDate` is in the required ISO-8601 format. The attribute
61
65
  `Date` and so can ensure correct formatting. In the same way, the `foundingLocation` is a `Place`
62
66
  which adds the proper `@type` attribute.
63
67
 
64
- ### You cannot create invalid markup
68
+ ### You cannot create invalid markup
65
69
 
66
70
  E.g., If you use the wrong type or try to set an unknown attribute, SchemaDotOrg will
67
71
  refuse to create the incorrect JSON-LD. Instead, you'll get a message explaining
@@ -82,50 +86,7 @@ This type safety comes from the [ValidatedObject gem](https://github.com/dogweat
82
86
 
83
87
  ## The Goal: Rich enough vocabulary for Google Schema.org parsing
84
88
 
85
- The end result is to output website metadata like this (taken from my site [public.law](https://www.public.law)):
86
-
87
- ```html
88
- <script type="application/ld+json">
89
- {
90
- "@context": "http://schema.org",
91
- "@type": "Organization",
92
- "email": "sayhi@public.law",
93
- "founder": {
94
- "@type": "Person",
95
- "name": "Robb Shecter"
96
- },
97
- "foundingDate": "2009-03-06",
98
- "foundingLocation": {
99
- "@type": "Place",
100
- "address": "Portland, Oregon"
101
- },
102
- "logo": "https://www.public.law/favicon-196x196.png",
103
- "name": "Public.Law",
104
- "sameAs": [
105
- "https://twitter.com/law_is_code",
106
- "https://www.facebook.com/PublicDotLaw",
107
- "https://www.linkedin.com/company/9170633/"
108
- ],
109
- "url": "https://www.public.law"
110
- }
111
- </script>
112
- ```
113
-
114
- And it should do it in a **typesafe** way. That is, not merely syntactically correct,
115
- but also _semantically_ correct. It should, e.g., ensure that only allowed
116
- attributes are used.
117
-
118
- ## Schema Development Roadmap
119
-
120
- | Type | Planned | Completed |
121
- | ---------------------------------------------- | :-----: | :-------: |
122
- | [Place](http://schema.org/Place) | X | X |
123
- | [Person](http://schema.org/Person) | X |
124
- | [Organization](http://schema.org/Organization) | X |
125
- | [Date](http://schema.org/Date) | X |
126
- | [URL](http://schema.org/URL) | X |
127
-
128
- The plan is to implement a small subset of types and attributes relevant to the Google web crawler.
89
+ The plan is to implement a subset of types and attributes relevant to the Google web crawler.
129
90
  Propose new types and attributes by opening an Issue.
130
91
 
131
92
  ## Installation
@@ -4,13 +4,15 @@ require 'schema_dot_org'
4
4
 
5
5
  module SchemaDotOrg
6
6
  class Organization < SchemaType
7
- attr_accessor :email, :founder, :founding_date, :founding_location, :name, :url
7
+ attr_accessor :email, :founder, :founding_date, :founding_location, :logo, :name, :same_as, :url
8
8
 
9
9
  validates :email, type: String
10
10
  validates :founder, type: Person
11
11
  validates :founding_date, type: Date
12
12
  validates :founding_location, type: Place
13
+ validates :logo, type: String
13
14
  validates :name, type: String
15
+ validates :same_as, type: String
14
16
  validates :url, type: String
15
17
 
16
18
  def to_json_struct
@@ -19,6 +21,8 @@ module SchemaDotOrg
19
21
  "name" => name,
20
22
  "email" => email,
21
23
  "url" => url,
24
+ "logo" => logo,
25
+ "same_as" => same_as,
22
26
  "founder" => founder.to_json_struct,
23
27
  "foundingDate" => founding_date.to_s,
24
28
  "foundingLocation" => founding_location.to_json_struct
@@ -1,3 +1,3 @@
1
1
  module SchemaDotOrg
2
- VERSION = "0.5.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/test-script.rb CHANGED
@@ -7,15 +7,17 @@ include SchemaDotOrg
7
7
 
8
8
 
9
9
  public_law = Organization.new do |org|
10
- org.name = "Public.Law"
10
+ org.name = 'Public.Law'
11
11
  org.founding_date = Date.new(2009, 3, 6)
12
- org.email = "say_hi@public.law"
13
- org.url = "https://www.public.law"
12
+ org.email = 'say_hi@public.law'
13
+ org.url = 'https://www.public.law'
14
+ org.logo = 'https://www.public.law/favicon-196x196.png'
15
+ org.same_as = 'https://www.facebook.com/PublicDotLaw'
14
16
  org.founder = Person.new do |person|
15
- person.name = "Robb Shecter"
17
+ person.name = 'Robb Shecter'
16
18
  end
17
19
  org.founding_location = Place.new do |place|
18
- place.address = "Portland, OR"
20
+ place.address = 'Portland, OR'
19
21
  end
20
22
  end
21
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_dot_org
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter