wcc-contentful 1.4.0.rc2 → 1.4.0

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
  SHA256:
3
- metadata.gz: 0b1a0aa21bc1bc749fdfc169eecf55d5bf829e0d4ac4272e90649c2d46abf622
4
- data.tar.gz: 12812d6728c4992ea3763cdbe0dc8f204267a75c3f35a052a663ec8c4f380115
3
+ metadata.gz: 63f3ef5be57de2373cfb7af9def7e9227fe0be9d7acc22977f650f4638f8835d
4
+ data.tar.gz: 80021d370e0b6e4238515658f491cd6fee5bafe39c813822dcf3e44d86d7a6fa
5
5
  SHA512:
6
- metadata.gz: 9226778b6abf97db358f836ed0659e202f13266fbf946acd793cbeed23f69cb3cab475e9750ca64761ba6ceecd38cdaaad7f919ea2a2d04f00fa4d8e940d9653
7
- data.tar.gz: c4f0bb1b6e44fa8b0a4aa647e246ff7dd6726d62e2905d026f2bb201867fb09af640b266ab95c22e04dab6b23f4c162ec6d88cf3bd45ca41c9a5853eb4842d80
6
+ metadata.gz: 4a26f8d7e360cac5511bf68fd083c980f0ab8d9f5c81657b363f157c2c811fa0316bcd6987fff4ae0225a74db8450a196d2a21cafee9d6cb42213d9c55556a4f
7
+ data.tar.gz: 26299e68f65c992b226c8c17064913454d582795ac2bd2345784f0b4550f73f77047bf8f3a67d2110652843508d885f20f45d6202bb36ede4b3d7b3244b0d6b7
@@ -22,20 +22,21 @@ module WCC::Contentful::EntryLocaleTransformer
22
22
  return entry
23
23
  end
24
24
 
25
- sys = entry['sys'].except('locale').merge({
25
+ new_entry = entry.dup
26
+
27
+ new_entry['sys'] = entry['sys'].except('locale').merge({
26
28
  'WCC::Contentful::EntryLocaleTransformer:locales_included' => [entry_locale]
27
29
  })
28
- fields =
29
- entry['fields'].transform_values do |value|
30
- h = {}
31
- h[entry_locale] = value
32
- h
33
- end
30
+ if entry.key?('fields')
31
+ new_entry['fields'] =
32
+ entry['fields'].transform_values do |value|
33
+ h = {}
34
+ h[entry_locale] = value
35
+ h
36
+ end
37
+ end
34
38
 
35
- {
36
- 'sys' => sys,
37
- 'fields' => fields
38
- }
39
+ new_entry
39
40
  end
40
41
 
41
42
  ##
@@ -50,34 +51,33 @@ module WCC::Contentful::EntryLocaleTransformer
50
51
 
51
52
  return entry
52
53
  end
53
- return entry unless entry['fields']
54
54
 
55
55
  # Transform the store's "locale=*" entry into a localized one
56
56
  locale ||= default_locale
57
57
 
58
- sys = entry['sys'].deep_dup
59
- sys['locale'] = locale
60
- fields =
61
- entry['fields'].transform_values do |value|
62
- next if value.nil?
63
-
64
- # replace the all-locales value with the localized value
65
- l = locale
66
- v = nil
67
- while l
68
- v = value[l]
69
- break if v
70
-
71
- l = configuration.locale_fallbacks[l]
58
+ new_entry = entry.dup
59
+ new_entry['sys'] = entry['sys'].deep_dup
60
+ new_entry['sys']['locale'] = locale
61
+ if entry.key?('fields')
62
+ new_entry['fields'] =
63
+ entry['fields']&.transform_values do |value|
64
+ next if value.nil?
65
+
66
+ # replace the all-locales value with the localized value
67
+ l = locale
68
+ v = nil
69
+ while l
70
+ v = value[l]
71
+ break if v
72
+
73
+ l = configuration.locale_fallbacks[l]
74
+ end
75
+
76
+ v
72
77
  end
78
+ end
73
79
 
74
- v
75
- end
76
-
77
- {
78
- 'sys' => sys,
79
- 'fields' => fields
80
- }
80
+ new_entry
81
81
  end
82
82
 
83
83
  ##
@@ -22,9 +22,11 @@ module WCC::Contentful::Middleware::Store
22
22
  found =
23
23
  @cache.fetch(key, expires_in: expires_in) do
24
24
  event = 'miss'
25
- # if it's not a contentful ID don't hit the API.
25
+ # if it's from the sync engine don't hit the API.
26
+ next if key =~ /^sync:/
27
+
26
28
  # Store a nil object if we can't find the object on the CDN.
27
- (store.find(key, **options) || nil_obj(key)) if key =~ /^\w+$/
29
+ (store.find(key, **options) || nil_obj(key))
28
30
  end
29
31
 
30
32
  return unless found
@@ -138,7 +138,8 @@ module WCC::Contentful
138
138
  # This job uses the Contentful Sync API to update the configured store with
139
139
  # the latest data from Contentful.
140
140
  class Job < ActiveJob::Base
141
- self.queue_adapter ||= :async
141
+ # This should always be "async", because the configured store could be an in-memory store.
142
+ self.queue_adapter = :async
142
143
  queue_as :default
143
144
 
144
145
  def configuration
@@ -2,6 +2,6 @@
2
2
 
3
3
  module WCC
4
4
  module Contentful
5
- VERSION = '1.4.0.rc2'
5
+ VERSION = '1.4.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-contentful
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.rc2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-27 00:00:00.000000000 Z
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -508,9 +508,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
508
508
  version: '2.7'
509
509
  required_rubygems_version: !ruby/object:Gem::Requirement
510
510
  requirements:
511
- - - ">"
511
+ - - ">="
512
512
  - !ruby/object:Gem::Version
513
- version: 1.3.1
513
+ version: '0'
514
514
  requirements: []
515
515
  rubygems_version: 3.3.7
516
516
  signing_key: