izi_json_ld 1.0.5 → 1.0.9

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
- SHA256:
3
- metadata.gz: 28d2678ee3475f8cebb2b386a2352b7b0995d1b9d4170b1ba3d38469fd1e2368
4
- data.tar.gz: 674ef10a8a510dff3b2d209845baf849186f2dea9b46e3af45975fd7d987e7cb
2
+ SHA1:
3
+ metadata.gz: 747a203ca8b1d17c682bc1f49efeb9782e47ac1f
4
+ data.tar.gz: da61b08b5f1317c8efb18317853e479b12643bfc
5
5
  SHA512:
6
- metadata.gz: fd0edbe4ebcf8f0fceb4b6735e5a05635152caceb991b7a6ab9c3224dc182978132da164a6f65b2e27a43b7cde03fd4c96e1a66cba3fdff2827f3fdca9052764
7
- data.tar.gz: 18afbea4f9912fd060b72d089be3081ed1288e0ee19579564752bf6e14d6d554ca8473fc2dce3aab8c6e674656231cd40a739f6630977078968a90f15fa89b24
6
+ metadata.gz: 8f66a9419f1ff8db70f9bcfdb85919db60f83d4de518dc265e5feb97c75c7bd8393abc417ec0b473b8b47d210f12eb0957f5bc63da1163f8d3b07223ac5489dd
7
+ data.tar.gz: 395652ef61e587fc8df01433ff5ba004b5037bf005646ce4db965aff314b3b6364a67961e5dfac0ee12d9f94ed2ab3a0199c2b69699b4e0372407c955417ef76
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AnswerEntity < ApplicationEntity
4
+ type 'Answer'
5
+
6
+ attribute :text, ::IziJsonLd::Types::String
7
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FaqPageEntity < ApplicationEntity
4
+ type 'FAQPage'
5
+
6
+ attribute :mainEntity, ::IziJsonLd::Types::OneOrMore[::QuestionEntity]
7
+ attribute? :breadcrumb, ::BreadcrumbListEntity
8
+ end
@@ -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
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class QuestionEntity < ApplicationEntity
4
+ type 'Question'
5
+
6
+ attribute :name, ::IziJsonLd::Types::String
7
+ attribute? :acceptedAnswer, ::AnswerEntity
8
+ attribute? :answer, ::IziJsonLd::Types::String
9
+
10
+ def dump_attributes
11
+ attributes.except(:answer).merge(acceptedAnswer: safe_answer.dump(self))
12
+ end
13
+
14
+ private
15
+
16
+ def safe_answer
17
+ acceptedAnswer || ::AnswerEntity.new(text: answer)
18
+ end
19
+ end
@@ -3,9 +3,23 @@
3
3
  class ReviewEntity < ApplicationEntity
4
4
  type 'Review'
5
5
 
6
- attribute? :author, ::IziJsonLd::Types::String.optional
6
+ # attribute? :author, ::IziJsonLd::Types::String.optional
7
+ attribute? :author, (::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).merge(author: safe_author)
15
+ end
16
+
17
+ private
18
+
19
+ def safe_author
20
+ return if author.blank?
21
+ return author unless author.is_a? String
22
+
23
+ PersonEntity.new(person_name: author)
24
+ end
11
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IziJsonLd
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.9'
5
5
  end