jekyll-spree-client 0.1.20 → 0.1.21
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 +4 -4
- data/lib/jekyll/spree_client.rb +18 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f691ea2cebbd451a912b7dc7ea4ec6cea4a30c8a2b345dd0a2ab5d113ef763f
|
4
|
+
data.tar.gz: 9d56c15db95801773a18ad56f0a1263ad0693a007611211f211e7e4a3797744c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7a0c45963d7ca0ee95f4448873dfe9d9eccc2050f579b00e5faeb215eca6051f1bad615216610fec97817d2e48e7bb3da79b7f537d8157d462ead7b690c8975
|
7
|
+
data.tar.gz: 865dbd12ff3369260a90ca5f9cc8e3bb2020209e4bac961d49f32695cd7b97a2a6e59e171d4265f7480fc0b062afb987ba016297a3aa33cddac1121ad1da6dab
|
data/lib/jekyll/spree_client.rb
CHANGED
@@ -188,11 +188,14 @@ module Jekyll
|
|
188
188
|
remote_product = attributes_from(product, product_fields).tap do |a|
|
189
189
|
a[:extra_attributes] ||= {}
|
190
190
|
end
|
191
|
-
|
191
|
+
|
192
|
+
variant_comparison = attributes_from(variant, product_fields).tap do |v|
|
193
|
+
v[:extra_attributes] = v[:extra_attributes]&.transform_keys(&:to_sym)
|
194
|
+
end
|
192
195
|
|
193
196
|
# Only when they haven't changed, so we don't waste time sending a
|
194
197
|
# request.
|
195
|
-
unless remote_product
|
198
|
+
unless compare_hashes(remote_product, variant_comparison)
|
196
199
|
# XXX: We don't have the product ID with the variant but we have
|
197
200
|
# the slug.
|
198
201
|
remote_variant = { id: variant['id'] }.merge!(attributes_from product, variant_only_fields)
|
@@ -268,5 +271,18 @@ module Jekyll
|
|
268
271
|
def attributes_from(document_or_hash, fields)
|
269
272
|
(document_or_hash.respond_to?(:data) ? document_or_hash.data : document_or_hash).slice(*fields).transform_keys(&:to_sym)
|
270
273
|
end
|
274
|
+
|
275
|
+
# Compare two hashes by the keys they share. Some fields we send
|
276
|
+
# are not available through the APIv1, like meta_description.
|
277
|
+
#
|
278
|
+
# @link https://stackoverflow.com/a/15503329
|
279
|
+
# @param :h1 [Hash]
|
280
|
+
# @param :h2 [Hash]
|
281
|
+
# @return [Boolean]
|
282
|
+
def compare_hashes(h1, h2)
|
283
|
+
(h1.keys & h2.keys).all? do |k|
|
284
|
+
h1[k] == h2[k]
|
285
|
+
end
|
286
|
+
end
|
271
287
|
end
|
272
288
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-spree-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree-api-client
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.3.
|
99
|
+
rubygems_version: 3.3.8
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Spree Ecommerce API client for Jekyll
|