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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll/spree_client.rb +18 -2
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 390af0f63aee218e9f828303c23352dfaddd6c08c0830476ae04788b7115f6b0
4
- data.tar.gz: 81f4e247841705eaea3f73b2e0a941455435c65dd17d87cee68449324d9b8c0f
3
+ metadata.gz: 8f691ea2cebbd451a912b7dc7ea4ec6cea4a30c8a2b345dd0a2ab5d113ef763f
4
+ data.tar.gz: 9d56c15db95801773a18ad56f0a1263ad0693a007611211f211e7e4a3797744c
5
5
  SHA512:
6
- metadata.gz: 99290d03c7daebf7b12cead21c69d0560530ab8bc50ab37312c26f15a6d377c6ae22b4e35b31a77cd1e8550990e7c4b4c11432b896134edb5c52daa5f4b44641
7
- data.tar.gz: f846b9e1914977776df45da460794e48855bc5b6fb37dec363d4b6e264e0530a2782e13fee38af25f119457c2bd4d519e5cc3e66ab47b9d24101d94e73a1d771
6
+ metadata.gz: f7a0c45963d7ca0ee95f4448873dfe9d9eccc2050f579b00e5faeb215eca6051f1bad615216610fec97817d2e48e7bb3da79b7f537d8157d462ead7b690c8975
7
+ data.tar.gz: 865dbd12ff3369260a90ca5f9cc8e3bb2020209e4bac961d49f32695cd7b97a2a6e59e171d4265f7480fc0b062afb987ba016297a3aa33cddac1121ad1da6dab
@@ -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
- variant_comparison = attributes_from variant, product_fields
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.slice(*variant_comparison.keys) == variant_comparison
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.20
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-17 00:00:00.000000000 Z
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.5
99
+ rubygems_version: 3.3.8
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Spree Ecommerce API client for Jekyll