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 +5 -5
- data/app/entities/answer_entity.rb +7 -0
- data/app/entities/faq_page_entity.rb +8 -0
- data/app/entities/person_entity.rb +7 -1
- data/app/entities/question_entity.rb +19 -0
- data/app/entities/review_entity.rb +15 -1
- data/lib/izi_json_ld/version.rb +1 -1
- data/spec/dummy/log/test.log +1209 -13929
- data/spec/entities/faq_page_entity_spec.rb +88 -0
- data/spec/entities/person_entity_spec.rb +42 -0
- data/spec/entities/review_entity_spec.rb +43 -13
- metadata +11 -5
- data/spec/dummy/log/development.log +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 747a203ca8b1d17c682bc1f49efeb9782e47ac1f
|
4
|
+
data.tar.gz: da61b08b5f1317c8efb18317853e479b12643bfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f66a9419f1ff8db70f9bcfdb85919db60f83d4de518dc265e5feb97c75c7bd8393abc417ec0b473b8b47d210f12eb0957f5bc63da1163f8d3b07223ac5489dd
|
7
|
+
data.tar.gz: 395652ef61e587fc8df01433ff5ba004b5037bf005646ce4db965aff314b3b6364a67961e5dfac0ee12d9f94ed2ab3a0199c2b69699b4e0372407c955417ef76
|
@@ -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
|
data/lib/izi_json_ld/version.rb
CHANGED