schema_dot_org 0.3.0 → 0.4.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 +1 -1
- data/README.md +13 -7
- data/lib/schema_dot_org/organization.rb +4 -1
- data/lib/schema_dot_org/version.rb +1 -1
- data/test-script.rb +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93bc15aae93a080fe09852b3299ea6f81eba62d760b198ce84b4df685d771f55
|
4
|
+
data.tar.gz: 6cfe3d6685e94eb4a53ea84a9c5060409621d2efb9303736017fe41da4178699
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdf06df8bb7eb6670c8fd4a895e9c25355a550de4fc6fa5cc43700c3ab374fda20b2380f6ef31daeadbc8ef27f0cdb49a60887a5be2c0bc24b3cfcd778b39fcf
|
7
|
+
data.tar.gz: '04837cee51efa5f56cedadd141d24e99d60832307be1c7792b5eb72cc4ba9b030620fd8e3c3f8fbfb5de9730f8c8d117ec9f1cfec189228697d01bf1e259313f'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,7 @@ 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
25
|
org.founding_location = Place.new do |place|
|
25
26
|
place.address = "Portland, OR"
|
26
27
|
end
|
@@ -31,7 +32,7 @@ end
|
|
31
32
|
<%= @public_law %>
|
32
33
|
```
|
33
34
|
|
34
|
-
|
35
|
+
SchemaDotOrg will validate your code, and if correct, will generate Schema.org JSON-LD markup:
|
35
36
|
|
36
37
|
```html
|
37
38
|
<script type="application/ld+json">
|
@@ -41,12 +42,18 @@ The generated webpage will contain correct Schema.org JSON-LD markup:
|
|
41
42
|
"name": "Public.Law",
|
42
43
|
"email": "say_hi@public.law",
|
43
44
|
"url": "https://www.public.law",
|
45
|
+
"foundingDate": "2009-03-06",
|
44
46
|
"foundingLocation": {
|
45
47
|
"@type": "Place",
|
46
48
|
"address": "Portland, OR"
|
47
49
|
}
|
50
|
+
</script>
|
48
51
|
```
|
49
52
|
|
53
|
+
Notice how the `foundingDate` is in the required ISO-8601 format. The attribute requires a Ruby
|
54
|
+
`Date` and so can ensure correct formatting. In the same way, the `foundingLocation` is a `Place`
|
55
|
+
which adds the proper `@type` attribute.
|
56
|
+
|
50
57
|
### You cannot create invalid markup
|
51
58
|
|
52
59
|
E.g., If you use the wrong type or try to set an unknown attribute, SchemaDotOrg will
|
@@ -102,14 +109,13 @@ but also _semantically_ correct. It should, e.g., ensure that only allowed
|
|
102
109
|
attributes are used.
|
103
110
|
|
104
111
|
## Schema Development Roadmap
|
105
|
-
|
106
112
|
| Type | Planned | Completed |
|
107
113
|
| ---- |:-------:|:---------:|
|
108
|
-
| Place | X | X |
|
109
|
-
| Person | X |
|
110
|
-
| Organization | X |
|
111
|
-
| Date | X |
|
112
|
-
| URL | X |
|
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 |
|
113
119
|
|
114
120
|
The plan is to implement a small subset of types and attributes relevant to the Google web crawler.
|
115
121
|
Propose new types and attributes by opening an Issue.
|
@@ -1,11 +1,13 @@
|
|
1
|
+
require 'date'
|
1
2
|
require 'schema_dot_org'
|
2
3
|
|
3
4
|
|
4
5
|
module SchemaDotOrg
|
5
6
|
class Organization < SchemaType
|
6
|
-
attr_accessor :founding_location, :email, :name, :url
|
7
|
+
attr_accessor :founding_date, :founding_location, :email, :name, :url
|
7
8
|
|
8
9
|
validates :email, type: String
|
10
|
+
validates :founding_date, type: Date
|
9
11
|
validates :founding_location, type: Place
|
10
12
|
validates :name, type: String
|
11
13
|
validates :url, type: String
|
@@ -16,6 +18,7 @@ module SchemaDotOrg
|
|
16
18
|
"name" => name,
|
17
19
|
"email" => email,
|
18
20
|
"url" => url,
|
21
|
+
"foundingDate" => founding_date.to_s,
|
19
22
|
"foundingLocation" => founding_location.to_json_struct
|
20
23
|
}
|
21
24
|
end
|
data/test-script.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
require 'schema_dot_org/place'
|
2
4
|
require 'schema_dot_org/organization'
|
3
5
|
include SchemaDotOrg
|
4
6
|
|
5
7
|
|
6
8
|
public_law = Organization.new do |org|
|
7
|
-
org.name
|
9
|
+
org.name = "Public.Law"
|
10
|
+
org.founding_date = Date.new(2009, 3, 6)
|
8
11
|
org.email = "say_hi@public.law"
|
9
|
-
org.url
|
12
|
+
org.url = "https://www.public.law"
|
10
13
|
org.founding_location = Place.new do |place|
|
11
14
|
place.address = "Portland, OR"
|
12
15
|
end
|