contentful 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: e018b3e026198922d69a821134ba088e962b750f
4
- data.tar.gz: f0237cee08b92e9e17864831e20f91d74afb8733
3
+ metadata.gz: fa88c4ac86051cce5074ece0a442eba538b391de
4
+ data.tar.gz: d3b48ffb2e6415fe4ca1181273ea646c50c66ab6
5
5
  SHA512:
6
- metadata.gz: 4c11bc9897c16a237b5afac122f95d0fc4f1bdee794e68cdbc06f8526f4b0417f9bae230ef944c49609666adc923fbd6dfd0e5ec91db524ef0fbeb572f521d26
7
- data.tar.gz: c7aeb7db69f75723d92964142ca0a2355509049bc2df34842430fb5c9b2f33fae43e71bb763ca00ccf045d3c07377bb7b00d3a730c7b9f3f538b5bfe13959a8f
6
+ metadata.gz: ac44810a4f8fa5e725b2953ae54abfb8bb4987d4af1feecfed38631ce4fdade1096f1cfdede0a67fd20fe039e0939243e87ee946568a1cc59cb5107b0c3ac997
7
+ data.tar.gz: ca723275d5614061688b12d2cf7d1dcc0ca5881b611378f454b70563297c9df5beea6ef6a9a43606eecf80617e12d9042603714125c5a425fed4410f69675e98
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.2
6
+ ### Fixed
7
+ * Fix Link resolution for Arrays on localized content
8
+
9
+ ### Added
10
+ * Add `entry?` method to resources to easily detect entries
11
+ * Add missing documentation for `#locales` method
12
+
5
13
  ## 1.0.1
6
14
  ### Fixed
7
15
  * Fix Link resolution on localized content
@@ -32,6 +32,11 @@ module Contentful
32
32
  processed_raw
33
33
  end
34
34
 
35
+ # Returns true for resources that are entries
36
+ def entry?
37
+ true
38
+ end
39
+
35
40
  private
36
41
 
37
42
  def known_link?(name)
@@ -56,6 +56,11 @@ module Contentful
56
56
  "#<#{self.class}:#{properties_info}#{info}>"
57
57
  end
58
58
 
59
+ # Returns true for resources that are entries
60
+ def entry?
61
+ false
62
+ end
63
+
59
64
  # Returns true for resources that behave like an array
60
65
  def array?
61
66
  false
@@ -58,6 +58,7 @@ module Contentful
58
58
  end
59
59
  end
60
60
 
61
+ # Provides a list of the available locales for a Resource
61
62
  def locales
62
63
  @fields.keys
63
64
  end
@@ -204,12 +204,15 @@ module Contentful
204
204
  end
205
205
 
206
206
  def replace_localized_children(result, object, property_name, potential_objects)
207
- if localized_entry?(object, property_name, potential_objects)
208
- localized_objects = potential_objects.select { |_, p| Support.localized?(p) }
209
- localized_objects.each do |field_name, localized_object|
210
- detect_child_objects(localized_object).each do |locale, child_object|
211
- result.public_send(property_name, locale)[field_name.to_sym] = create_resource(child_object)
212
- end
207
+ return unless localized_entry?(object, property_name, potential_objects)
208
+
209
+ localized_objects = potential_objects.select { |_, p| Support.localized?(p) }
210
+ localized_objects.each do |field_name, localized_object|
211
+ detect_child_objects(localized_object).each do |locale, child_object|
212
+ result.public_send(property_name, locale)[field_name.to_sym] = create_resource(child_object)
213
+ end
214
+ detect_child_arrays(localized_object).each do |locale, _child_array|
215
+ replace_child_array result.public_send(property_name, locale)[field_name.to_sym]
213
216
  end
214
217
  end
215
218
  end
@@ -1,5 +1,5 @@
1
1
  # Contentful Namespace
2
2
  module Contentful
3
3
  # Gem Version
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
data/spec/entry_spec.rb CHANGED
@@ -98,6 +98,30 @@ describe Contentful::Entry do
98
98
  expect(entry.image.id).not_to eq entry.fields('zh')[:image].id
99
99
  }
100
100
  end
101
+
102
+ it 'can have references with arrays in multiple locales and have them properly solved' do
103
+ vcr('multi_locale_array_reference') {
104
+ client = create_client(
105
+ space: 'cma9f9g4dxvs',
106
+ access_token: '3e4560614990c9ac47343b9eea762bdaaebd845766f619660d7230787fd545e1',
107
+ dynamic_entries: :auto
108
+ )
109
+
110
+ entry = client.entries(content_type: 'test', locale: '*').first
111
+
112
+ expect(entry.files).to be_a ::Array
113
+ expect(entry.references).to be_a ::Array
114
+ expect(entry.files.first).to be_a ::Contentful::Asset
115
+ expect(entry.references.first.entry?).to be_truthy
116
+
117
+ expect(entry.fields('zh')[:files]).to be_a ::Array
118
+ expect(entry.fields('zh')[:references]).to be_a ::Array
119
+ expect(entry.fields('zh')[:files].first).to be_a ::Contentful::Asset
120
+ expect(entry.fields('zh')[:references].first.entry?).to be_truthy
121
+
122
+ expect(entry.files.first.id).not_to eq entry.fields('zh')[:files].first.id
123
+ }
124
+ end
101
125
  end
102
126
  end
103
127
 
@@ -0,0 +1,200 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cma9f9g4dxvs/content_types?limit=1000
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulGem/1.0.1
12
+ Authorization:
13
+ - Bearer 3e4560614990c9ac47343b9eea762bdaaebd845766f619660d7230787fd545e1
14
+ Content-Type:
15
+ - application/vnd.contentful.delivery.v1+json
16
+ Accept-Encoding:
17
+ - gzip
18
+ Connection:
19
+ - close
20
+ Host:
21
+ - cdn.contentful.com
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Access-Control-Allow-Headers:
28
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent
29
+ Access-Control-Allow-Methods:
30
+ - GET,HEAD,OPTIONS
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Access-Control-Expose-Headers:
34
+ - Etag
35
+ Access-Control-Max-Age:
36
+ - '86400'
37
+ Cache-Control:
38
+ - max-age=0
39
+ Content-Encoding:
40
+ - gzip
41
+ Content-Type:
42
+ - application/vnd.contentful.delivery.v1+json
43
+ Etag:
44
+ - W/"d88da8bd0b663c91b528c893d220e530"
45
+ Server:
46
+ - Contentful
47
+ Strict-Transport-Security:
48
+ - max-age=15768000
49
+ X-Content-Type-Options:
50
+ - nosniff
51
+ - nosniff
52
+ X-Contentful-Request-Id:
53
+ - a0059b039268294c11c0f01a5debe341
54
+ Content-Length:
55
+ - '466'
56
+ Accept-Ranges:
57
+ - bytes
58
+ Date:
59
+ - Wed, 05 Oct 2016 10:24:47 GMT
60
+ Via:
61
+ - 1.1 varnish
62
+ Age:
63
+ - '0'
64
+ Connection:
65
+ - close
66
+ X-Served-By:
67
+ - cache-gru7126-GRU
68
+ X-Cache:
69
+ - MISS
70
+ X-Cache-Hits:
71
+ - '0'
72
+ X-Timer:
73
+ - S1475663087.088657,VS0,VE163
74
+ Vary:
75
+ - Accept-Encoding
76
+ body:
77
+ encoding: ASCII-8BIT
78
+ string: !binary |-
79
+ H4sIAAAAAAAAA+VVO2/CMBDe+RXIc0EJUFCyoaqdusHUisEkl8rCsVPbQU0R
80
+ /72288CBUIrKUtULuTvf3XcPf+x6/T6ShURhf6c/taCKDLSE5kLgAmnd/s7c
81
+ UVxhqvUjK8kNybTgWYGSlCgt+Z5XKoiC1ER8tRHLuEdpbCqZ4cjkqm+USgeM
82
+ UVhlDeqZsA0ySQ9Hp2ebZQV6YSMeXSCxqSdKcZAEb5P4YytNWfXZN9+20PKg
83
+ 0keBVE60BsYDZwqYslkdp0gAVhDPTTPQyPOnA98bePdL3wv9cTgOhn4QvLgO
84
+ eRZf5yBgSyThzHS7AtugRjGRGcXFEwFqKmY5pTU4xHBqp7p0K0IxyEiQTJUR
85
+ UQMNJSbGYYSmKa0hle1JCAXZ6naTp8PUXix3RojyCFPyCQa2Ejm0jALecyKs
86
+ LcFUto26ZrymZ4xc76WeR6djvaNuWRcWbasx6nnpZtnOrL7Zw7mUoC5uWUdL
87
+ BSQggEXn+nrO/p+a+8iUsMzU8YQr7cr+Vk/jDxNQwvmN+GcS+rPhbDb9Mf90
88
+ OlzDP2iNxYFRagJyK/ot/7gJzLwb9jkx1M9jUaRrTtuU5ZLPKcHcjH0OfzPt
89
+ HdXSqrfvfQFKIERWiQcAAA==
90
+ http_version:
91
+ recorded_at: Wed, 05 Oct 2016 10:24:47 GMT
92
+ - request:
93
+ method: get
94
+ uri: https://cdn.contentful.com/spaces/cma9f9g4dxvs/entries?content_type=test&locale=*
95
+ body:
96
+ encoding: US-ASCII
97
+ string: ''
98
+ headers:
99
+ User-Agent:
100
+ - RubyContentfulGem/1.0.1
101
+ Authorization:
102
+ - Bearer 3e4560614990c9ac47343b9eea762bdaaebd845766f619660d7230787fd545e1
103
+ Content-Type:
104
+ - application/vnd.contentful.delivery.v1+json
105
+ Accept-Encoding:
106
+ - gzip
107
+ Connection:
108
+ - close
109
+ Host:
110
+ - cdn.contentful.com
111
+ response:
112
+ status:
113
+ code: 200
114
+ message: OK
115
+ headers:
116
+ Access-Control-Allow-Headers:
117
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent
118
+ Access-Control-Allow-Methods:
119
+ - GET,HEAD,OPTIONS
120
+ Access-Control-Allow-Origin:
121
+ - "*"
122
+ Access-Control-Expose-Headers:
123
+ - Etag
124
+ Access-Control-Max-Age:
125
+ - '86400'
126
+ Cache-Control:
127
+ - max-age=0
128
+ Content-Encoding:
129
+ - gzip
130
+ Content-Type:
131
+ - application/vnd.contentful.delivery.v1+json
132
+ Etag:
133
+ - W/"8edf1404b7716c31b2d3e1ee5e7bcf1d"
134
+ Server:
135
+ - Contentful
136
+ Strict-Transport-Security:
137
+ - max-age=15768000
138
+ X-Content-Type-Options:
139
+ - nosniff
140
+ - nosniff
141
+ X-Contentful-Request-Id:
142
+ - 4971acf3134093597e6a745b405ba08e
143
+ Content-Length:
144
+ - '1349'
145
+ Accept-Ranges:
146
+ - bytes
147
+ Date:
148
+ - Wed, 05 Oct 2016 10:24:47 GMT
149
+ Via:
150
+ - 1.1 varnish
151
+ Age:
152
+ - '0'
153
+ Connection:
154
+ - close
155
+ X-Served-By:
156
+ - cache-gru7121-GRU
157
+ X-Cache:
158
+ - MISS
159
+ X-Cache-Hits:
160
+ - '0'
161
+ X-Timer:
162
+ - S1475663087.427541,VS0,VE185
163
+ Vary:
164
+ - Accept-Encoding
165
+ body:
166
+ encoding: ASCII-8BIT
167
+ string: !binary |-
168
+ H4sIAAAAAAAAA+1aW3PaOhB+z69g/NKXE5DkO29MSkgmt6aUadMzHUaWZPDg
169
+ C8UmKenkv1eyMcjYDuGEnJzT1C+xJa20u/p29WnJz4NGQ4kXsdJu/OSv/CNZ
170
+ TBn/UjqzGV4ovO3hLzEmiRLs83aYfsUTb8o/QPrhe4GXiC6QfXsJC8SEf6cT
171
+ ZtNurJKuFE8xEUvlI7JGSRfRkDbmOp174UQRa64fvno4+bTUuZ/OuDHAo8Ic
172
+ EmDbtUca/XEbC6vy52H1ntqZPUomY3Zjb6GZ7++vomst6gdsMbi4GEjzrxTr
173
+ hslsIXeQGcMJox3hFwUBaBxCcAj0TxC0kdaGRhMC9FUWmE/pbgIzduvFXhTm
174
+ e7LUnERhwsJk6ZH9ufZImrfSwQmLkxrHLv26crDiesyna8wJ1Xmbz4pNvJGF
175
+ h4P+Ckr59shWpbIygPNBaccjwEn7ZfB04pglG+BJB2VgQJjeq2iEOtHpaE4m
176
+ 2l3/xkNItlgMXsMp/Sp66lX0Vi/R8QWN2DHqT4xIu776HpwN0sCWnw29pd5v
177
+ sg3K/fi/sRthcrL4Egw6PY0FVqydandnHtnBqMqonzGXzVhIXheHm7kk36Yl
178
+ DqFz+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4aUuHprw13DzF3DyB1ydw0z
195
+ dw3jYe4u0bFy1z/nHxCoJrC0cjZ5WiISSpdl5UyEoImemYqe4pl3O3nmifmq
196
+ aFkGwmfRzmpo2AxgC1ETmYYBLA4LXrGDDnUdlTiUaCyHhsD9S+NBhbaW/g9B
197
+ 8dkXGqCqqqXJd2OkUhIoOuNFICAnkNV7rnD29xtvfzh4OPgFEE8NsqwhAAA=
198
+ http_version:
199
+ recorded_at: Wed, 05 Oct 2016 10:24:47 GMT
200
+ recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentful GmbH (Jan Lelis)
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-10-04 00:00:00.000000000 Z
13
+ date: 2016-10-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http
@@ -386,6 +386,7 @@ files:
386
386
  - spec/fixtures/vcr_cassettes/linkField.yml
387
387
  - spec/fixtures/vcr_cassettes/locale.yml
388
388
  - spec/fixtures/vcr_cassettes/location.yml
389
+ - spec/fixtures/vcr_cassettes/multi_locale_array_reference.yml
389
390
  - spec/fixtures/vcr_cassettes/multi_locale_reference.yml
390
391
  - spec/fixtures/vcr_cassettes/not_found.yml
391
392
  - spec/fixtures/vcr_cassettes/nyancat.yml
@@ -483,6 +484,7 @@ test_files:
483
484
  - spec/fixtures/vcr_cassettes/linkField.yml
484
485
  - spec/fixtures/vcr_cassettes/locale.yml
485
486
  - spec/fixtures/vcr_cassettes/location.yml
487
+ - spec/fixtures/vcr_cassettes/multi_locale_array_reference.yml
486
488
  - spec/fixtures/vcr_cassettes/multi_locale_reference.yml
487
489
  - spec/fixtures/vcr_cassettes/not_found.yml
488
490
  - spec/fixtures/vcr_cassettes/nyancat.yml