schema_dot_org 2.0 → 2.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: 643f2d209ee7cac02447c46cc8f5c14682163dd171db5d3c1b5fdf84382a3eab
4
- data.tar.gz: cab0857ac26be75638701893e328db0a93840a368b46df5e5e6a106ccb98f3be
3
+ metadata.gz: 39339b796fe48d129c05873ab0a10b6d4ebd683b982723049e25e1bb98b1b893
4
+ data.tar.gz: 8e3c46e25e0e00849db2e0817c141f563209fb2ebbf9ec67a10fe8bc8241b9c2
5
5
  SHA512:
6
- metadata.gz: 69e7822b9097e10d3a4d51053f32982fddde76ffcccd3f611474d08c6ef890dc31a16cd3bcf14d6420b592ff80fff756b8737f733a0e57c1ffcc0be925772025
7
- data.tar.gz: 65e88820be2cdedb39aee20ca85bc14e1866b64a2737323076bba3d18d39184cc37b192edfbc65ba5ba1b194de0f9339fece13fb1e7fdd7d72e755bf3442e800
6
+ metadata.gz: 243792759980ee75f52dbc022aa59bb211b7a250a1af1078e5d167cd1700ae858d1588aafc9fd9a5ab92a7c89166fc437442ab176e9502744fbd6e7ff1bb2cd8
7
+ data.tar.gz: 17abef45bb90add2f3cb699720950a2402cc6c84fad5e37672710caf26ddf9b4556204481e418726322642245172b18b8d634e58088a083296a119f168c25799
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --format documentation
2
1
  --color
3
2
  --require spec_helper
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schema_dot_org (2.0)
5
- validated_object (~> 2.2)
4
+ schema_dot_org (2.2.0)
5
+ validated_object (~> 2.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -45,10 +45,10 @@ GEM
45
45
  rspec-support (~> 3.12.0)
46
46
  rspec-support (3.12.1)
47
47
  ruby2_keywords (0.0.5)
48
- sorbet-runtime (0.5.10993)
48
+ sorbet-runtime (0.5.11072)
49
49
  tzinfo (2.0.6)
50
50
  concurrent-ruby (~> 1.0)
51
- validated_object (2.2.0)
51
+ validated_object (2.3.0)
52
52
  activemodel (>= 3.2.21)
53
53
  sorbet-runtime (>= 0.5.5890)
54
54
 
data/README.md CHANGED
@@ -18,6 +18,7 @@ Let's say you have a Rails app. If you put this in a controller:
18
18
  founding_date: Date.new(2009, 3, 6),
19
19
  founding_location: Place.new(address: 'Portland, OR'),
20
20
  email: 'say_hi@public.law',
21
+ telephone: '+1 123 456 7890',
21
22
  url: 'https://www.public.law',
22
23
  logo: 'https://www.public.law/favicon-196x196.png',
23
24
  same_as: [
@@ -42,6 +43,7 @@ Let's say you have a Rails app. If you put this in a controller:
42
43
  "@type": "Organization",
43
44
  "name": "Public.Law",
44
45
  "email": "say_hi@public.law",
46
+ "telephone": "+1 123 456 7890",
45
47
  "url": "https://www.public.law",
46
48
  "logo": "https://www.public.law/favicon-196x196.png",
47
49
  "foundingDate": "2009-03-06",
@@ -8,24 +8,20 @@ require 'schema_dot_org/offer'
8
8
  #
9
9
  module SchemaDotOrg
10
10
  class AggregateOffer < SchemaType
11
- attr_accessor :priceCurrency,
12
- :highPrice,
13
- :lowPrice,
14
- :offerCount,
15
- :offers
11
+ attr_reader :priceCurrency
16
12
 
17
- validates :lowPrice, type: Numeric
18
- validates :highPrice, type: Numeric, allow_nil: true
19
- validates :offerCount, type: String, allow_nil: true
20
- validates :offers, type: Array, allow_nil: true
13
+ validated_attr :lowPrice, type: Numeric
14
+ validated_attr :highPrice, type: Numeric, allow_nil: true
15
+ validated_attr :offerCount, type: String, allow_nil: true
16
+ validated_attr :offers, type: Array, allow_nil: true
21
17
 
22
18
  def _to_json_struct
23
19
  {
24
20
  "priceCurrency" => priceCurrency,
25
- "lowPrice" => lowPrice,
26
- "highPrice" => highPrice,
27
- "offerCount" => offerCount,
28
- "offers" => offers.map(&:to_json_struct)
21
+ "lowPrice" => lowPrice,
22
+ "highPrice" => highPrice,
23
+ "offerCount" => offerCount,
24
+ "offers" => offers.map(&:to_json_struct)
29
25
  }
30
26
  end
31
27
 
@@ -6,17 +6,11 @@ require 'schema_dot_org'
6
6
  module SchemaDotOrg
7
7
  # Model the Schema.org `ContactPoint`. See http://schema.org/ContactPoint
8
8
  class ContactPoint < SchemaType
9
- attr_accessor :telephone,
10
- :contact_type,
11
- :contact_option,
12
- :area_served,
13
- :available_language
14
-
15
- validates :telephone, type: String, presence: true
16
- validates :contact_type, type: String, presence: true
17
- validates :contact_option, type: String, allow_nil: true
18
- validates :area_served, type: Array, allow_nil: true
19
- validates :available_language, type: Array, allow_nil: true
9
+ validated_attr :telephone, type: String, presence: true
10
+ validated_attr :contact_type, type: String, presence: true
11
+ validated_attr :contact_option, type: String, allow_nil: true
12
+ validated_attr :area_served, type: Array, allow_nil: true
13
+ validated_attr :available_language, type: Array, allow_nil: true
20
14
 
21
15
  def _to_json_struct
22
16
  {
@@ -5,19 +5,12 @@ require 'schema_dot_org'
5
5
  module SchemaDotOrg
6
6
  # Model the Schema.org `ItemList`. See https://schema.org/ItemList
7
7
  class ItemList < SchemaType
8
- attr_accessor :itemListOrder,
9
- :numberOfItems,
10
- :url,
11
- :image,
12
- :itemListElement
8
+ validated_attr :itemListElement, type: Array, presence: true
9
+ validated_attr :itemListOrder, type: String, allow_nil: true
10
+ validated_attr :numberOfItems, type: Integer, allow_nil: true
13
11
 
14
-
15
- validates :itemListElement, type: Array, presence: true
16
- validates :itemListOrder, type: String, allow_nil: true
17
- validates :numberOfItems, type: Integer, allow_nil: true
18
-
19
- validates :url, type: String, allow_nil: true
20
- validates :image, type: String, allow_nil: true
12
+ validated_attr :url, type: String, allow_nil: true
13
+ validated_attr :image, type: String, allow_nil: true
21
14
 
22
15
 
23
16
  def _to_json_struct
@@ -7,15 +7,12 @@ require 'schema_dot_org/product'
7
7
  module SchemaDotOrg
8
8
  # Model the Schema.org `ItemListElement`. See https://schema.org/ItemListElement
9
9
  class ListItem < SchemaType
10
- attr_accessor :position, :item,
11
- :url, :name, :image
10
+ validated_attr :position, type: Integer, presence: true
11
+ validated_attr :url, type: String, allow_nil: true
12
+ validated_attr :name, type: String, allow_nil: true
13
+ validated_attr :image, type: String, allow_nil: true
12
14
 
13
- validates :position, type: Integer, presence: true
14
- validates :url, type: String, allow_nil: true
15
- validates :name, type: String, allow_nil: true
16
- validates :image, type: String, allow_nil: true
17
-
18
- validates :item, type: Product, allow_nil: true
15
+ validated_attr :item, type: Product, allow_nil: true
19
16
 
20
17
  def _to_json_struct
21
18
  {
@@ -7,15 +7,10 @@ require 'schema_dot_org'
7
7
  #
8
8
  module SchemaDotOrg
9
9
  class Offer < SchemaType
10
- attr_accessor :priceCurrency,
11
- :price,
12
- :availability,
13
- :url
14
-
15
- validates :priceCurrency, type: String
16
- validates :price, type: Numeric
17
- validates :availability, type: String, allow_nil: true
18
- validates :url, type: String, allow_nil: true
10
+ validated_attr :priceCurrency, type: String
11
+ validated_attr :price, type: Numeric
12
+ validated_attr :availability, type: String, allow_nil: true
13
+ validated_attr :url, type: String, allow_nil: true
19
14
 
20
15
  def _to_json_struct
21
16
  {
@@ -9,30 +9,22 @@ require 'schema_dot_org/contact_point'
9
9
 
10
10
  module SchemaDotOrg
11
11
  class Organization < SchemaType
12
- attr_accessor :email,
13
- :founder,
14
- :founding_date,
15
- :founding_location,
16
- :logo,
17
- :name,
18
- :url,
19
- :same_as,
20
- :contact_points
21
-
22
- validates :email, type: String, allow_nil: true
23
- validates :founder, type: SchemaDotOrg::Person, allow_nil: true
24
- validates :founding_date, type: Date, allow_nil: true
25
- validates :founding_location, type: SchemaDotOrg::Place, allow_nil: true
26
- validates :logo, type: String
27
- validates :name, type: String
28
- validates :url, type: String
29
- validates :same_as, type: Array, allow_nil: true
30
- validates :contact_points, type: Array, allow_nil: true
12
+ validated_attr :email, type: String, allow_nil: true
13
+ validated_attr :telephone, type: String, allow_nil: true
14
+ validated_attr :founder, type: SchemaDotOrg::Person, allow_nil: true
15
+ validated_attr :founding_date, type: Date, allow_nil: true
16
+ validated_attr :founding_location, type: SchemaDotOrg::Place, allow_nil: true
17
+ validated_attr :logo, type: String
18
+ validated_attr :name, type: String
19
+ validated_attr :url, type: String
20
+ validated_attr :same_as, type: Array, allow_nil: true
21
+ validated_attr :contact_points, type: Array, allow_nil: true
31
22
 
32
23
  def _to_json_struct
33
24
  {
34
25
  "name" => name,
35
26
  "email" => email,
27
+ "telephone" => telephone,
36
28
  "url" => url,
37
29
  "logo" => logo,
38
30
  "founder" => object_to_json_struct(founder),
@@ -2,20 +2,17 @@
2
2
 
3
3
 
4
4
  module SchemaDotOrg
5
- # Model the Schema.org `Person`. See http://schema.org/Person
5
+ # Model the Schema.org **Person**. See http://schema.org/Person
6
6
  class Person < SchemaType
7
- attr_accessor :name,
8
- :url,
9
- :same_as
7
+ validated_attr :name, type: String, presence: true
8
+ validated_attr :same_as, type: Array, allow_nil: true
9
+ validated_attr :url, type: String, allow_nil: true
10
10
 
11
- validates :name, type: String, presence: true
12
- validates :url, type: String, allow_nil: true
13
- validates :same_as, type: Array, allow_nil: true
14
11
 
15
12
  def _to_json_struct
16
13
  {
17
- 'name' => name,
18
- 'url' => url,
14
+ 'name' => name,
15
+ 'url' => url,
19
16
  'same_as' => same_as
20
17
  }
21
18
  end
@@ -4,8 +4,7 @@
4
4
  module SchemaDotOrg
5
5
  # Model the Schema.org `Thing > Place`. See http://schema.org/Place
6
6
  class Place < SchemaType
7
- attr_accessor :address
8
- validates :address, type: String, presence: true
7
+ validated_attr :address, type: String, presence: true
9
8
 
10
9
  def _to_json_struct
11
10
  {
@@ -8,17 +8,11 @@ require 'schema_dot_org/aggregate_offer'
8
8
  #
9
9
  module SchemaDotOrg
10
10
  class Product < SchemaType
11
- attr_accessor :name,
12
- :url,
13
- :description,
14
- :image,
15
- :offers
16
-
17
- validates :name, type: String
18
- validates :url, type: String
19
- validates :description, type: String, allow_nil: true
20
- validates :image, type: Array, allow_nil: true
21
- validates :offers, type: SchemaDotOrg::AggregateOffer
11
+ validated_attr :name, type: String
12
+ validated_attr :url, type: String
13
+ validated_attr :description, type: String, allow_nil: true
14
+ validated_attr :image, type: Array, allow_nil: true
15
+ validated_attr :offers, type: SchemaDotOrg::AggregateOffer
22
16
 
23
17
  def _to_json_struct
24
18
  {
@@ -4,9 +4,8 @@
4
4
  module SchemaDotOrg
5
5
  # Model the Schema.org `Thing > SearchAction`. See http://schema.org/SearchAction
6
6
  class SearchAction < SchemaType
7
- attr_accessor :target, :query_input
8
- validates :target, type: String, presence: true
9
- validates :query_input, type: String, presence: true
7
+ validated_attr :target, type: String, presence: true
8
+ validated_attr :query_input, type: String, presence: true
10
9
 
11
10
  def _to_json_struct
12
11
  {
@@ -5,10 +5,10 @@ module SchemaDotOrg
5
5
  # Model the Schema.org `Thing > CreativeWork > WebSite`.
6
6
  # @See http://schema.org/WebSite
7
7
  class WebSite < SchemaType
8
- attr_accessor :name, :url, :potential_action
9
- validates :name, type: String, presence: true
10
- validates :url, type: String, presence: true
11
- validates :potential_action, type: SchemaDotOrg::SearchAction, allow_nil: true
8
+ validated_attr :name, type: String, presence: true
9
+ validated_attr :url, type: String, presence: true
10
+ validated_attr :potential_action, type: SchemaDotOrg::SearchAction, allow_nil: true
11
+
12
12
 
13
13
  def _to_json_struct
14
14
  {
@@ -14,12 +14,3 @@ require 'schema_dot_org/contact_point'
14
14
 
15
15
  module SchemaDotOrg
16
16
  end
17
-
18
-
19
- require 'schema_dot_org/person'
20
- require 'schema_dot_org/place'
21
-
22
- require 'schema_dot_org/organization'
23
-
24
- require 'schema_dot_org/search_action'
25
- require 'schema_dot_org/web_site'
@@ -7,7 +7,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
7
  Gem::Specification.new do |spec|
8
8
  spec.required_ruby_version = '>= 2.6'
9
9
  spec.name = 'schema_dot_org'
10
- spec.version = '2.0'
10
+ spec.version = '2.2.0'
11
11
  spec.authors = ['Robb Shecter']
12
12
  spec.email = ['robb@public.law']
13
13
 
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'validated_object', '~> 2.2'
28
+ spec.add_dependency 'validated_object', '~> 2.3'
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 2.4"
31
31
  spec.add_development_dependency "rake", "~> 13.0"
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: '2.0'
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.2'
19
+ version: '2.3'
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: '2.2'
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement