schema_dot_org 0.4.0 → 0.5.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: 93bc15aae93a080fe09852b3299ea6f81eba62d760b198ce84b4df685d771f55
4
- data.tar.gz: 6cfe3d6685e94eb4a53ea84a9c5060409621d2efb9303736017fe41da4178699
3
+ metadata.gz: 0e11781fcf6716d6ead9eeb5128d405c6a7b1f417b59a34ff81ac9a79b5bebc4
4
+ data.tar.gz: 894473636d64822d08f87ebbdc082477d892f5b3496b9c421fa18429c11bf39b
5
5
  SHA512:
6
- metadata.gz: bdf06df8bb7eb6670c8fd4a895e9c25355a550de4fc6fa5cc43700c3ab374fda20b2380f6ef31daeadbc8ef27f0cdb49a60887a5be2c0bc24b3cfcd778b39fcf
7
- data.tar.gz: '04837cee51efa5f56cedadd141d24e99d60832307be1c7792b5eb72cc4ba9b030620fd8e3c3f8fbfb5de9730f8c8d117ec9f1cfec189228697d01bf1e259313f'
6
+ metadata.gz: c8ac48952653f553840cd8bc8282040cad63b8782a0aca6d8dc908032a6c178ceff8e934b10b6088aa6dbc8e8e0860c758cb90aaa1fb59b2fb8a56b5822752df
7
+ data.tar.gz: 18129d7a92e1c39e71d412fcc70e90e61b415c669380718625b7a24c1d51533af054bf2e5b40e4558fa608c060a02fce23b344984a4dacb6edb1770d6dcb40f9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schema_dot_org (0.3.0)
4
+ schema_dot_org (0.5.0)
5
5
  validated_object
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -21,7 +21,10 @@ include SchemaDotOrg
21
21
  org.name = "Public.Law"
22
22
  org.email = "say_hi@public.law"
23
23
  org.url = "https://www.public.law"
24
- org.founding_date = Date.new(2009, 3, 6)
24
+ org.founding_date = Date.new(2009, 3, 6)
25
+ org.founder = Person.new do |person|
26
+ person.name = "Robb Shecter"
27
+ end
25
28
  org.founding_location = Place.new do |place|
26
29
  place.address = "Portland, OR"
27
30
  end
@@ -43,6 +46,10 @@ SchemaDotOrg will validate your code, and if correct, will generate Schema.org J
43
46
  "email": "say_hi@public.law",
44
47
  "url": "https://www.public.law",
45
48
  "foundingDate": "2009-03-06",
49
+ "founder": {
50
+ "@type": "Person",
51
+ "name": "Robb Shecter"
52
+ },
46
53
  "foundingLocation": {
47
54
  "@type": "Place",
48
55
  "address": "Portland, OR"
@@ -109,13 +116,14 @@ but also _semantically_ correct. It should, e.g., ensure that only allowed
109
116
  attributes are used.
110
117
 
111
118
  ## Schema Development Roadmap
112
- | Type | Planned | Completed |
113
- | ---- |:-------:|:---------:|
114
- | [Place](http://schema.org/Place) | X | X |
115
- | [Person](http://schema.org/Person) | X |
116
- | [Organization](http://schema.org/Organization) | X |
117
- | [Date](http://schema.org/Date) | X |
118
- | [URL](http://schema.org/URL) | X |
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 |
119
127
 
120
128
  The plan is to implement a small subset of types and attributes relevant to the Google web crawler.
121
129
  Propose new types and attributes by opening an Issue.
@@ -4,9 +4,10 @@ require 'schema_dot_org'
4
4
 
5
5
  module SchemaDotOrg
6
6
  class Organization < SchemaType
7
- attr_accessor :founding_date, :founding_location, :email, :name, :url
7
+ attr_accessor :email, :founder, :founding_date, :founding_location, :name, :url
8
8
 
9
9
  validates :email, type: String
10
+ validates :founder, type: Person
10
11
  validates :founding_date, type: Date
11
12
  validates :founding_location, type: Place
12
13
  validates :name, type: String
@@ -18,6 +19,7 @@ module SchemaDotOrg
18
19
  "name" => name,
19
20
  "email" => email,
20
21
  "url" => url,
22
+ "founder" => founder.to_json_struct,
21
23
  "foundingDate" => founding_date.to_s,
22
24
  "foundingLocation" => founding_location.to_json_struct
23
25
  }
@@ -0,0 +1,19 @@
1
+ require 'schema_dot_org'
2
+
3
+
4
+ module SchemaDotOrg
5
+ # Model the Schema.org `Person`. See http://schema.org/Person
6
+ class Person < SchemaType
7
+
8
+ attr_accessor :name
9
+ validates :name, type: String, presence: true
10
+
11
+
12
+ def to_json_struct
13
+ {
14
+ "@type" => "Person",
15
+ name: self.name
16
+ }
17
+ end
18
+ end
19
+ end
@@ -5,9 +5,7 @@ module SchemaDotOrg
5
5
  # Model the Schema.org `Thing > Place`. See http://schema.org/Place
6
6
  class Place < SchemaType
7
7
  attr_accessor :address
8
-
9
- validates :address, presence: true
10
- validates :address, type: String
8
+ validates :address, type: String, presence: true
11
9
 
12
10
  def to_json_struct
13
11
  {
@@ -1,3 +1,3 @@
1
1
  module SchemaDotOrg
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/test-script.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'date'
2
2
 
3
+ require 'schema_dot_org/person'
3
4
  require 'schema_dot_org/place'
4
5
  require 'schema_dot_org/organization'
5
6
  include SchemaDotOrg
@@ -10,6 +11,9 @@ public_law = Organization.new do |org|
10
11
  org.founding_date = Date.new(2009, 3, 6)
11
12
  org.email = "say_hi@public.law"
12
13
  org.url = "https://www.public.law"
14
+ org.founder = Person.new do |person|
15
+ person.name = "Robb Shecter"
16
+ end
13
17
  org.founding_location = Place.new do |place|
14
18
  place.address = "Portland, OR"
15
19
  end
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
@@ -86,6 +86,7 @@ files:
86
86
  - bin/setup
87
87
  - lib/schema_dot_org.rb
88
88
  - lib/schema_dot_org/organization.rb
89
+ - lib/schema_dot_org/person.rb
89
90
  - lib/schema_dot_org/place.rb
90
91
  - lib/schema_dot_org/version.rb
91
92
  - schema_dot_org.gemspec