izi_json_ld 1.0.6 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 218c8d0a8c8738157adeca124dd26d6a38591ea1
4
- data.tar.gz: 6bc6047444d90f426b4baa52934e3efc9f4879f7
3
+ metadata.gz: 8460fc684cdf425df5ab3eb1c37cf3cec4fd94ce
4
+ data.tar.gz: ebe42ecc6dd75499a3d4c7d64011652ecd2a44be
5
5
  SHA512:
6
- metadata.gz: 7f0a6db05d7698790454e2f4f50c47df74892a40af537f29c25a84ce24eb429fcfb8c9fab97960e8c8caf8968d71703d125d13237e869bbf9e354d0d87143ee7
7
- data.tar.gz: 8ec1adf33df2e4d1c318873a451d7eb416213389bf7211368eec56e3643d23afcb425e928949a2797dc35eab79d0017f114e33b656c155b5a3de89e8ac119c02
6
+ metadata.gz: 1ce55344a93dc3e3ddfa65dc5387d48e5fc8af0f65ab072378de5764e37f7b9c52d966c18931a103631e919a1d984c3bbe67065a223fbad0ed4f9b9cb224d6d7
7
+ data.tar.gz: 8175939a4405a80fe70cad66c8e7e25b4007483123cf76027656eb752389fb989691abb039d22956ce0d68694e4e739759c1263bdf0ff4cc8db120c1c1fc1638
@@ -5,10 +5,16 @@ class PersonEntity < ApplicationEntity
5
5
  attribute :person_name, ::IziJsonLd::Types::String
6
6
  attribute? :email, ::IziJsonLd::Types::String.optional
7
7
  attribute? :image, ::IziJsonLd::Types::String.optional
8
- attribute? :sameAs, ::IziJsonLd::Types::String.optional
8
+ attribute? :sameAs, ::IziJsonLd::Types::OneOrMore[::IziJsonLd::Types::String].optional
9
9
  attribute? :worksFor, ::OrganizationEntity
10
+ attribute? :url, ::IziJsonLd::Types::String.optional
11
+ attribute? :jobTitle, ::IziJsonLd::Types::String.optional
10
12
 
11
13
  def dump_attributes
12
14
  attributes.except(:person_name).merge(name: person_name)
13
15
  end
16
+
17
+ def name
18
+ person_name
19
+ end
14
20
  end
@@ -8,7 +8,7 @@ class QuestionEntity < ApplicationEntity
8
8
  attribute? :answer, ::IziJsonLd::Types::String
9
9
 
10
10
  def dump_attributes
11
- attributes.except(:answer).merge(acceptedAnswer: safe_answer.dump)
11
+ attributes.except(:answer).merge(acceptedAnswer: safe_answer.dump(self))
12
12
  end
13
13
 
14
14
  private
@@ -3,9 +3,33 @@
3
3
  class ReviewEntity < ApplicationEntity
4
4
  type 'Review'
5
5
 
6
- attribute? :author, ::IziJsonLd::Types::String.optional
6
+ attribute? :author, (::IziJsonLd::Types::Strict::String | ::PersonEntity | ::OrganizationEntity).optional
7
+ attribute? :publisher, (::IziJsonLd::Types::Strict::String | ::PersonEntity | ::OrganizationEntity).optional
7
8
  attribute? :reviewRating, RatingEntity.optional
8
9
  attribute? :reviewBody, ::IziJsonLd::Types::String.optional
9
10
 
10
11
  attribute? :datePublished, ::IziJsonLd::Types::DateTime.optional
12
+
13
+ def dump_attributes
14
+ attributes.except(:author, :publisher).merge(
15
+ author: safe_author,
16
+ publisher: safe_publisher
17
+ )
18
+ end
19
+
20
+ private
21
+
22
+ def safe_author
23
+ return if author.blank?
24
+ return author unless author.is_a?(String)
25
+
26
+ ::PersonEntity.new(person_name: author)
27
+ end
28
+
29
+ def safe_publisher
30
+ return if publisher.blank?
31
+ return publisher unless publisher.is_a?(String)
32
+
33
+ ::OrganizationEntity.new(name: publisher)
34
+ end
11
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IziJsonLd
4
- VERSION = '1.0.6'
4
+ VERSION = '1.0.10'
5
5
  end