wcc-contentful 1.4.0.rc3 → 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: f1c1fa12c92cfa84f2308474f177f56f015dc6c8116245b13074a64fe29eeaa5
4
- data.tar.gz: 6ee074042103a824705738f6aeab222c302918ebf1f4fc53f37e63e0857328ba
3
+ metadata.gz: 63f3ef5be57de2373cfb7af9def7e9227fe0be9d7acc22977f650f4638f8835d
4
+ data.tar.gz: 80021d370e0b6e4238515658f491cd6fee5bafe39c813822dcf3e44d86d7a6fa
5
5
  SHA512:
6
- metadata.gz: 4a63d99f50a9c89d5f708f8da774a178959ba3336ddb1e40503b05c32a071f00e1cb72667083caaa51b59f29f582cfa78233960d95cfe170b362d0a24160bbe4
7
- data.tar.gz: 6e190a63485e5b22e7e772d6fee2fc545dba96daf8bdaa57ea819ae9f760cc010170ac354818f85b620167362dbfb3729d0749634e3c2217cc7f28d6160a96e1
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
  ##
@@ -54,29 +55,29 @@ module WCC::Contentful::EntryLocaleTransformer
54
55
  # Transform the store's "locale=*" entry into a localized one
55
56
  locale ||= default_locale
56
57
 
57
- sys = entry['sys'].deep_dup
58
- sys['locale'] = locale
59
- fields =
60
- entry['fields']&.transform_values do |value|
61
- next if value.nil?
62
-
63
- # replace the all-locales value with the localized value
64
- l = locale
65
- v = nil
66
- while l
67
- v = value[l]
68
- break if v
69
-
70
- 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
71
77
  end
78
+ end
72
79
 
73
- v
74
- end
75
-
76
- {
77
- 'sys' => sys,
78
- 'fields' => fields
79
- }
80
+ new_entry
80
81
  end
81
82
 
82
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.rc3'
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.rc3
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-05-01 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: