izi_json_ld 1.0.7 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/entities/person_entity.rb +7 -1
- data/app/entities/product_entity.rb +19 -1
- data/app/entities/review_entity.rb +25 -1
- data/lib/izi_json_ld/version.rb +1 -1
- data/spec/dummy/log/test.log +2319 -18429
- data/spec/entities/person_entity_spec.rb +42 -0
- data/spec/entities/review_entity_spec.rb +69 -13
- metadata +4 -4
- data/spec/dummy/log/development.log +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc874ab5405c6e7f56fc9bde4bec4e288b44831
|
4
|
+
data.tar.gz: a2f871bd7e3a815180c17a2395a1e4744e0a54bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6cc1e6e99a9e7a40d82ee84d0499bd3e39f2743e268e1d403feab724351847e4e3f84fa9b2e7f04a0b00a058604ed811a13042e62674c17bdfbc6a2fa7080f9
|
7
|
+
data.tar.gz: 582a5dc61fb74a9db7dd4c61058bf7c0e0e3f5b83ea91de48312c3e27c9c4fa04c76b0c90d2a9d800ba85926922fd123675c4980ef0d7e8b91f7188667d6c757
|
@@ -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
|
@@ -4,11 +4,29 @@ class ProductEntity < ApplicationEntity
|
|
4
4
|
type 'Product'
|
5
5
|
|
6
6
|
attribute :name, ::IziJsonLd::Types::String
|
7
|
-
attribute? :brand, ::IziJsonLd::Types::String.optional
|
7
|
+
attribute? :brand, (::IziJsonLd::Types::Strict::String | ::OrganizationEntity).optional
|
8
8
|
attribute? :image, ::IziJsonLd::Types::String.optional
|
9
9
|
attribute? :description, ::IziJsonLd::Types::String.optional
|
10
|
+
attribute? :sku, ::IziJsonLd::Types::String.optional
|
11
|
+
attribute? :gtin, ::IziJsonLd::Types::String.optional
|
12
|
+
attribute? :mpn, ::IziJsonLd::Types::String.optional
|
10
13
|
|
11
14
|
attribute? :offers, OfferEntity.optional
|
12
15
|
attribute? :aggregateRating, AggregateRatingEntity.optional
|
13
16
|
attribute? :review, ::IziJsonLd::Types::OneOrMore[::ReviewEntity].optional
|
17
|
+
|
18
|
+
def dump_attributes
|
19
|
+
attributes.except(:brand).merge(
|
20
|
+
brand: safe_brand
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def safe_brand
|
27
|
+
return if brand.blank?
|
28
|
+
return brand unless brand.is_a?(String)
|
29
|
+
|
30
|
+
::OrganizationEntity.new(name: brand)
|
31
|
+
end
|
14
32
|
end
|
@@ -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
|
data/lib/izi_json_ld/version.rb
CHANGED