izi_json_ld 1.0.9 → 1.0.10

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
  SHA1:
3
- metadata.gz: 747a203ca8b1d17c682bc1f49efeb9782e47ac1f
4
- data.tar.gz: da61b08b5f1317c8efb18317853e479b12643bfc
3
+ metadata.gz: 8460fc684cdf425df5ab3eb1c37cf3cec4fd94ce
4
+ data.tar.gz: ebe42ecc6dd75499a3d4c7d64011652ecd2a44be
5
5
  SHA512:
6
- metadata.gz: 8f66a9419f1ff8db70f9bcfdb85919db60f83d4de518dc265e5feb97c75c7bd8393abc417ec0b473b8b47d210f12eb0957f5bc63da1163f8d3b07223ac5489dd
7
- data.tar.gz: 395652ef61e587fc8df01433ff5ba004b5037bf005646ce4db965aff314b3b6364a67961e5dfac0ee12d9f94ed2ab3a0199c2b69699b4e0372407c955417ef76
6
+ metadata.gz: 1ce55344a93dc3e3ddfa65dc5387d48e5fc8af0f65ab072378de5764e37f7b9c52d966c18931a103631e919a1d984c3bbe67065a223fbad0ed4f9b9cb224d6d7
7
+ data.tar.gz: 8175939a4405a80fe70cad66c8e7e25b4007483123cf76027656eb752389fb989691abb039d22956ce0d68694e4e739759c1263bdf0ff4cc8db120c1c1fc1638
@@ -3,23 +3,33 @@
3
3
  class ReviewEntity < ApplicationEntity
4
4
  type 'Review'
5
5
 
6
- # attribute? :author, ::IziJsonLd::Types::String.optional
7
6
  attribute? :author, (::IziJsonLd::Types::Strict::String | ::PersonEntity | ::OrganizationEntity).optional
7
+ attribute? :publisher, (::IziJsonLd::Types::Strict::String | ::PersonEntity | ::OrganizationEntity).optional
8
8
  attribute? :reviewRating, RatingEntity.optional
9
9
  attribute? :reviewBody, ::IziJsonLd::Types::String.optional
10
10
 
11
11
  attribute? :datePublished, ::IziJsonLd::Types::DateTime.optional
12
12
 
13
13
  def dump_attributes
14
- attributes.except(:author).merge(author: safe_author)
14
+ attributes.except(:author, :publisher).merge(
15
+ author: safe_author,
16
+ publisher: safe_publisher
17
+ )
15
18
  end
16
19
 
17
20
  private
18
21
 
19
22
  def safe_author
20
23
  return if author.blank?
21
- return author unless author.is_a? String
24
+ return author unless author.is_a?(String)
22
25
 
23
- PersonEntity.new(person_name: author)
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)
24
34
  end
25
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IziJsonLd
4
- VERSION = '1.0.9'
4
+ VERSION = '1.0.10'
5
5
  end
@@ -1946,3 +1946,51 @@
1946
1946
  TRANSACTION (0.2ms) rollback transaction
1947
1947
  TRANSACTION (0.1ms) begin transaction
1948
1948
  TRANSACTION (0.1ms) rollback transaction
1949
+  (0.5ms) begin transaction
1950
+  (0.1ms) rollback transaction
1951
+  (0.1ms) begin transaction
1952
+  (0.1ms) rollback transaction
1953
+  (0.1ms) begin transaction
1954
+  (0.1ms) rollback transaction
1955
+  (0.1ms) begin transaction
1956
+  (0.1ms) rollback transaction
1957
+  (0.1ms) begin transaction
1958
+  (0.1ms) rollback transaction
1959
+  (0.0ms) begin transaction
1960
+  (0.1ms) rollback transaction
1961
+  (0.1ms) begin transaction
1962
+  (0.1ms) rollback transaction
1963
+  (0.1ms) begin transaction
1964
+  (0.0ms) rollback transaction
1965
+  (0.0ms) begin transaction
1966
+  (0.0ms) rollback transaction
1967
+  (0.1ms) begin transaction
1968
+  (0.1ms) rollback transaction
1969
+  (0.1ms) begin transaction
1970
+  (0.0ms) rollback transaction
1971
+  (0.0ms) begin transaction
1972
+  (0.1ms) rollback transaction
1973
+  (0.5ms) begin transaction
1974
+  (0.1ms) rollback transaction
1975
+  (0.1ms) begin transaction
1976
+  (0.1ms) rollback transaction
1977
+  (0.1ms) begin transaction
1978
+  (0.1ms) rollback transaction
1979
+  (0.1ms) begin transaction
1980
+  (0.1ms) rollback transaction
1981
+  (0.1ms) begin transaction
1982
+  (0.1ms) rollback transaction
1983
+  (0.1ms) begin transaction
1984
+  (0.1ms) rollback transaction
1985
+  (0.1ms) begin transaction
1986
+  (0.1ms) rollback transaction
1987
+  (0.1ms) begin transaction
1988
+  (0.1ms) rollback transaction
1989
+  (0.1ms) begin transaction
1990
+  (0.2ms) rollback transaction
1991
+  (0.1ms) begin transaction
1992
+  (0.2ms) rollback transaction
1993
+  (0.1ms) begin transaction
1994
+  (0.1ms) rollback transaction
1995
+  (0.1ms) begin transaction
1996
+  (0.0ms) rollback transaction
@@ -5,6 +5,7 @@ RSpec.describe ReviewEntity do
5
5
  let(:item_data) do
6
6
  {
7
7
  author: 'John',
8
+ publisher: 'Fodojo LLC',
8
9
  description: 'TODO',
9
10
  reviewRating: { ratingValue: 3 }
10
11
  }
@@ -71,4 +72,29 @@ RSpec.describe ReviewEntity do
71
72
  expect(author['name']).to eq raw.author.name
72
73
  end
73
74
  end
75
+
76
+ context 'publisher' do
77
+ it 'should parse publisher name as organizaton' do
78
+ publisher = item.as_json['publisher']
79
+ expect(publisher).to be_a Hash
80
+ expect(publisher['@type']).to eq 'Organization'
81
+ expect(publisher['name']).to eq item.publisher
82
+ end
83
+
84
+ it 'should allow to pass publisher hash' do
85
+ raw = described_class.new(item_data.merge(publisher: { person_name: 'Kenny' }))
86
+ publisher = raw.as_json['publisher']
87
+ expect(publisher).to be_a Hash
88
+ expect(publisher['@type']).to eq 'Person'
89
+ expect(publisher['name']).to eq raw.publisher.name
90
+ end
91
+
92
+ it 'should allow to pass publisher hash (Organization)' do
93
+ raw = described_class.new(item_data.merge(publisher: { name: 'Kenny' }))
94
+ publisher = raw.as_json['publisher']
95
+ expect(publisher).to be_a Hash
96
+ expect(publisher['@type']).to eq 'Organization'
97
+ expect(publisher['name']).to eq raw.publisher.name
98
+ end
99
+ end
74
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: izi_json_ld
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - IzikAJ
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct