schema_dot_org 1.0.1 → 1.2.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: 5b1a873ff196b5b941a06d1ebe22e3257cdcac6af80913d6500d5e83904d682c
4
- data.tar.gz: b5fef9d53e234eb9ce43c3eb521cb12c23f25164b0aecf9ab1976236620fe2b7
3
+ metadata.gz: 05e64a986c95f51a4c09c880b9fc922c5e78c63bd238ad886934a82da85b82a3
4
+ data.tar.gz: 9271738e29bfb17acba96dc538f21e8fa867c35ff91f4b717c37b84452ae5872
5
5
  SHA512:
6
- metadata.gz: 852bfe4e5259d19ffc3ee9b88e83dae9ec894d7785cd75b64eb5d2a4186ecd2abef5e65db7b265e3acaf84bd7b95e84f16a9f153bb6287e615ae25c8b0404296
7
- data.tar.gz: af3a67ac2b4d81100e6ef90786a3f3e41e305d960b59f8a3e49a5e421577a1c120200bad24e6ea805158f08eba3bd5ece8a455c4dbc9509f7098cfe22d3240ab
6
+ metadata.gz: 2042feb05893352d1b10dd12d059e026bf175730beaf5b176f49cb2e8a6f5d88fd2b2b9eafa2e9e0d5ad13699bd8dad1b58e878bc6af5f153a99a825506f1513
7
+ data.tar.gz: 6645f5d6361ebeda245d33446e519050e7131b0cbc55e432e490c9fc952afd9681833e904b4cab69971d8ceb485f6337f3114b060b602c3fd7bcce4605e6eca4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schema_dot_org (1.0.1)
4
+ schema_dot_org (1.2.0)
5
5
  validated_object
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -12,6 +12,7 @@ every single time.
12
12
  Create the tree of objects, and then call `#to_s` in e.g., a Rails template:
13
13
 
14
14
  ```ruby
15
+ require 'schema_dot_org/person'
15
16
  require 'schema_dot_org/place'
16
17
  require 'schema_dot_org/organization'
17
18
  include SchemaDotOrg
@@ -30,5 +30,23 @@ module SchemaDotOrg
30
30
  end
31
31
  end
32
32
 
33
+
34
+ # Use the class name to create the "@type" attribute.
35
+ # @return a hash structure representing json.
36
+ def to_json_struct
37
+ { "@type" => un_namespaced_classname }.merge( _to_json_struct )
38
+ end
39
+
40
+
41
+ def _to_json_struct
42
+ raise "For subclasses to implement"
43
+ end
44
+
45
+
46
+ # @return the classname without the module namespace.
47
+ def un_namespaced_classname
48
+ self.class.name =~ /([^:]+)$/
49
+ $1
50
+ end
33
51
  end
34
52
  end
@@ -14,9 +14,8 @@ module SchemaDotOrg
14
14
  validates :name, type: String
15
15
  validates :url, type: String
16
16
 
17
- def to_json_struct
17
+ def _to_json_struct
18
18
  {
19
- "@type" => "Organization",
20
19
  "name" => name,
21
20
  "email" => email,
22
21
  "url" => url,
@@ -9,9 +9,8 @@ module SchemaDotOrg
9
9
  validates :name, type: String, presence: true
10
10
 
11
11
 
12
- def to_json_struct
12
+ def _to_json_struct
13
13
  {
14
- "@type" => "Person",
15
14
  name: self.name
16
15
  }
17
16
  end
@@ -7,9 +7,8 @@ module SchemaDotOrg
7
7
  attr_accessor :address
8
8
  validates :address, type: String, presence: true
9
9
 
10
- def to_json_struct
10
+ def _to_json_struct
11
11
  {
12
- "@type" => "Place",
13
12
  address: self.address
14
13
  }
15
14
  end
@@ -1,3 +1,3 @@
1
1
  module SchemaDotOrg
2
- VERSION = "1.0.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -0,0 +1,22 @@
1
+ require 'schema_dot_org'
2
+
3
+
4
+ module SchemaDotOrg
5
+ # Model the Schema.org `Thing > CreativeWork > WebSite`.
6
+ # @See http://schema.org/WebSite
7
+ class WebSite < SchemaType
8
+ attr_accessor :name
9
+ validates :name, type: String, presence: true
10
+
11
+ attr_accessor :url
12
+ validates :url, type: String, presence: true
13
+
14
+ def _to_json_struct
15
+ {
16
+ name: self.name,
17
+ url: self.url
18
+ }
19
+ end
20
+ end
21
+ end
22
+
@@ -3,6 +3,7 @@ require 'date'
3
3
  require 'schema_dot_org/person'
4
4
  require 'schema_dot_org/place'
5
5
  require 'schema_dot_org/organization'
6
+ require 'schema_dot_org/web_site'
6
7
  include SchemaDotOrg
7
8
 
8
9
 
@@ -20,4 +21,10 @@ public_law = Organization.new do |org|
20
21
  end
21
22
  end
22
23
 
23
- puts public_law
24
+ site_info = WebSite.new do |website|
25
+ website.name = 'Texas Public Law'
26
+ website.url = 'https://texas.public.law'
27
+ end
28
+
29
+ puts site_info
30
+ puts public_law
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: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
@@ -89,6 +89,7 @@ files:
89
89
  - lib/schema_dot_org/person.rb
90
90
  - lib/schema_dot_org/place.rb
91
91
  - lib/schema_dot_org/version.rb
92
+ - lib/schema_dot_org/web_site.rb
92
93
  - schema_dot_org.gemspec
93
94
  - test-script.rb
94
95
  homepage: https://github.com/dogweather/schema-dot-org