jekyll-spree-client 0.1.12 → 0.1.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29f4a2f251e21575d7f5b4ef34af064f8fb80a7a2e494267d19336f201288c3d
4
- data.tar.gz: 77521c26bb015d395fa515adf4270385c28de024a57725d08123c8c7d0daebd5
3
+ metadata.gz: 4fae6ac8495376030f27da4d790f5935e0f20c2ada484eced1a266c98704ec82
4
+ data.tar.gz: 144cbab5df09cab4c48c1a0d2c16ee2f0a9c593e273750af346d143f9526ad24
5
5
  SHA512:
6
- metadata.gz: 71480aa397d2fe3e0191833bc55194d6d287ac1825c5ebe01ecbb341a13d1de79f16d1686a2b6a4ebd879cc882584d9bab940ded155208988386110104d00a8b
7
- data.tar.gz: f917c8e9cf3675801c8240ab88bc05f19368fd1597065ec7d789f4ec82ed5acab22733e5dc65ba7dfc63cc703ed197de4c09d1207f9e79f0d1663253a647b2dc
6
+ metadata.gz: ede792ab10edef6455c9a32f7eb42f5ad6dadc4e4c9ab59ebf06c141073177aec0264a6a236da51099108f66e1893ae1c9e5a51b36aeb97efc7357a92ec80176
7
+ data.tar.gz: 40b3025ef2c89824713d338cc9d9151a7c765803c90e3c16c3bf8430304e62cf63a5d7a71a547f3705786e3ac5a65808c5ba88adc01a0a0c48a40f799f12e9c1
data/README.md CHANGED
@@ -43,6 +43,7 @@ spree:
43
43
  sku_field: sku
44
44
  api_url: http://localhost:3000
45
45
  shipping_category_id: 1
46
+ store: https://your.store
46
47
  ```
47
48
 
48
49
  You can get the API key on your user profile. Pass it as the
@@ -52,7 +53,7 @@ You can get the API key on your user profile. Pass it as the
52
53
  SPREE_API_KEY="some random value generated by spree" bundle exec jekyll build
53
54
  ```
54
55
 
55
- Since v0.1.4 you can pass the store URL too, and it'll take precedence
56
+ Since v0.1.4 you can pass the API URL too, and it'll take precedence
56
57
  over `_config.yml`:
57
58
 
58
59
  ```bash
@@ -16,13 +16,13 @@ Jekyll::Hooks.register :site, :post_read do |site|
16
16
  end
17
17
  end
18
18
 
19
- unless ENV['SPREE_API_KEY']
19
+ if ENV['SPREE_API_KEY'].nil? || ENV['SPREE_API_KEY'].empty?
20
20
  Jekyll.logger.warn "SPREE_API_KEY environment variable missing, skipping syncrhonization"
21
21
  next
22
22
  end
23
23
 
24
24
  config = site.config['spree']&.transform_keys(&:to_sym) || {}
25
- config.merge!(site: site, api_key: ENV['SPREE_API_KEY'], spree_url: ENV['SPREE_URL'])
25
+ config.merge!(site: site, api_key: ENV['SPREE_API_KEY'], spree_url: ENV['SPREE_URL'], store: site.config['url'])
26
26
 
27
27
  client = Jekyll::SpreeClient.new **config
28
28
 
@@ -5,7 +5,7 @@ require 'spree_client'
5
5
 
6
6
  #
7
7
  module Jekyll
8
- SpreeClient = Struct.new :site, :sku_field, :api_key, :spree_url, :shipping_category_id, keyword_init: true do
8
+ SpreeClient = Struct.new :site, :sku_field, :api_key, :spree_url, :shipping_category_id, :store, keyword_init: true do
9
9
  # Products are posts with the SKU field
10
10
  #
11
11
  # @return [Array] Jekyll::Document
@@ -33,7 +33,7 @@ module Jekyll
33
33
  #
34
34
  # @return [Array]
35
35
  def variant_fields
36
- @variant_fields ||= %w[price weight height width depth cost_price].freeze
36
+ @variant_fields ||= %w[price weight height width depth cost_price pay_what_you_can].freeze
37
37
  end
38
38
 
39
39
  # Fields that can change locally and we need to sync to Spree
@@ -54,7 +54,7 @@ module Jekyll
54
54
  #
55
55
  # @return [SpreeClient::API::V1]
56
56
  def spree
57
- @spree ||= ::SpreeClient::API::V1.new **to_h.slice(:api_key, :spree_url)
57
+ @spree ||= ::SpreeClient::API::V1.new **to_h.slice(:api_key, :spree_url, :store)
58
58
  end
59
59
 
60
60
  # Localization with jekyll-locales
@@ -181,9 +181,11 @@ module Jekyll
181
181
  def update(product, variant)
182
182
  # Sync local changes to Spree
183
183
  remote_product = product.data.slice(*product_fields).transform_keys(&:to_sym)
184
+ variant_comparison = variant.slice(*product_fields).transform_keys(&:to_sym)
185
+
184
186
  # Only when they haven't changed, so we don't waste time sending a
185
187
  # request.
186
- unless remote_product == variant.slice(*product_fields).transform_keys(&:to_sym)
188
+ unless remote_product.slice(*variant_comparison.keys) == variant_comparison
187
189
  # XXX: We don't have the product ID with the variant but we have
188
190
  # the slug.
189
191
  remote_product[:id] = variant['slug']
@@ -227,6 +229,7 @@ module Jekyll
227
229
  end
228
230
 
229
231
  product.data['variant_id'] = remote_products.response.dig('master', 'id')
232
+ product.data['in_stock'] = product.data['stock'].to_i > 0
230
233
 
231
234
  # Add the initial stock
232
235
  spree.stock_items(id: product.data['variant_id'], stock_location_id: stock_location['id'])
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-spree-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2021-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree-api-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.2'
19
+ version: 0.2.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.2'
26
+ version: 0.2.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fast_blank
29
29
  requirement: !ruby/object:Gem::Requirement