contentful-management 0.6.1 → 0.7.0
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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +0 -2
- data/contentful-management.gemspec +1 -1
- data/lib/contentful/management/content_type.rb +9 -1
- data/lib/contentful/management/entry.rb +8 -0
- data/lib/contentful/management/field.rb +1 -0
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/entry/locales/fallback_to_default_locale.yml +324 -0
- data/spec/fixtures/vcr_cassettes/entry/locales/retrieve_localized.yml +326 -0
- data/spec/lib/contentful/management/entry_spec.rb +24 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e7aa420f1c03dd816c6c645c28d639d475a720
|
4
|
+
data.tar.gz: 6439b81172909e9bc10b5c0a8a070dcb25f4cdb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 447e88e59656db5a857abe6a92106a9dba8b912f4cffeb6fac56e216e9e0ef6d329701cc477ad4472616cdfe26a504ef99048e5944a6073432c448f69633b2e8
|
7
|
+
data.tar.gz: 9d0ba13fc77220f3ccf11297b19e0bbb8ea86f1e3c04ce232f74eb2c48098571623dda1fda3e718f674a363d4bd08fb880dab1f0c20da264b8eeee604d29c837
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
=======
|
3
3
|
|
4
|
+
## 0.7.0
|
5
|
+
### Added
|
6
|
+
* Add disable property to fields [#50](https://github.com/contentful/contentful-management.rb/pull/50), [#55](https://github.com/contentful/contentful-management.rb/pull/55)
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
* Explicitly set displayField to nil when it is not existing [#53](https://github.com/contentful/contentful-management.rb/pull/53), [#54](https://github.com/contentful/contentful-management.rb/pull/54)
|
10
|
+
* Merge values for default locale and current locale [#58](https://github.com/contentful/contentful-management.rb/pull/58)
|
11
|
+
|
12
|
+
|
13
|
+
|
4
14
|
## 0.6.1
|
5
15
|
### Fixed
|
6
16
|
* Fix access to space default_locale instance variable [#47](https://github.com/contentful/contentful-management.rb/pull/47)
|
@@ -11,6 +21,7 @@
|
|
11
21
|
## 0.6.0
|
12
22
|
### Added
|
13
23
|
* Access request and response from Contentful::Management:Error [#46](https://github.com/contentful/contentful-management.rb/pull/46)
|
24
|
+
|
14
25
|
### Fixed
|
15
26
|
* Handle 429 responses as errors [#46](https://github.com/contentful/contentful-management.rb/pull/46)
|
16
27
|
|
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
# Contentful::Management
|
3
3
|
[](http://badge.fury.io/rb/contentful-management) [](https://travis-ci.org/contentful/contentful-management.rb)
|
4
4
|
|
5
|
-
# This Gem does not yet support the full API functionality.
|
6
|
-
|
7
5
|
Ruby client for the Contentful Content Management API.
|
8
6
|
|
9
7
|
Contentful is a content management platform for web applications, mobile apps and connected devices. It allows you to create, edit & manage content in the cloud and publish it anywhere via powerful API. Contentful offers tools for managing editorial teams and enabling cooperation between organizations.
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_dependency 'http', '~> 0.
|
20
|
+
spec.add_dependency 'http', '~> 0.8'
|
21
21
|
spec.add_dependency 'multi_json', '~> 1'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
@@ -118,12 +118,20 @@ module Contentful
|
|
118
118
|
result
|
119
119
|
end
|
120
120
|
|
121
|
+
def display_field_value(attributes)
|
122
|
+
if attributes[:displayField].nil? && display_field.empty?
|
123
|
+
nil
|
124
|
+
else
|
125
|
+
attributes[:displayField] || display_field
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
121
129
|
# Updates a content type.
|
122
130
|
# Takes a hash with attributes.
|
123
131
|
# Returns a Contentful::Management::ContentType.
|
124
132
|
def update(attributes)
|
125
133
|
parameters = {}
|
126
|
-
parameters.merge!(displayField: attributes
|
134
|
+
parameters.merge!(displayField: display_field_value(attributes))
|
127
135
|
parameters.merge!(name: (attributes[:name] || name))
|
128
136
|
parameters.merge!(description: (attributes[:description] || description))
|
129
137
|
parameters.merge!(fields: self.class.fields_to_nested_properties_hash(attributes[:fields] || fields))
|
@@ -66,6 +66,14 @@ module Contentful
|
|
66
66
|
entry
|
67
67
|
end
|
68
68
|
|
69
|
+
def fields(wanted_locale = default_locale)
|
70
|
+
requested_locale = locale || wanted_locale
|
71
|
+
@fields[requested_locale] = {} unless @fields[requested_locale]
|
72
|
+
|
73
|
+
default_fields = @fields[default_locale] || {}
|
74
|
+
default_fields.merge(@fields[requested_locale])
|
75
|
+
end
|
76
|
+
|
69
77
|
# Updates an entry.
|
70
78
|
# Takes an optional hash with attributes of content type.
|
71
79
|
# Returns a Contentful::Management::Entry.
|
@@ -14,6 +14,7 @@ module Contentful
|
|
14
14
|
property :required, :boolean
|
15
15
|
property :localized, :boolean
|
16
16
|
property :validations, Validation
|
17
|
+
property :disabled, :boolean
|
17
18
|
|
18
19
|
# Takes a field object of content type
|
19
20
|
# Merges existing properties, items and validations of field with new one
|
@@ -0,0 +1,324 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.contentful.com/spaces/0agypmo1waov
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulManagementGem/0.6.1
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
Content-Length:
|
17
|
+
- '0'
|
18
|
+
Connection:
|
19
|
+
- close
|
20
|
+
Host:
|
21
|
+
- api.contentful.com
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 200
|
25
|
+
message: OK
|
26
|
+
headers:
|
27
|
+
Accept-Ranges:
|
28
|
+
- bytes
|
29
|
+
Access-Control-Allow-Headers:
|
30
|
+
- 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
|
31
|
+
Access-Control-Allow-Methods:
|
32
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- '*'
|
35
|
+
Access-Control-Expose-Headers:
|
36
|
+
- Etag
|
37
|
+
Access-Control-Max-Age:
|
38
|
+
- '1728000'
|
39
|
+
Cache-Control:
|
40
|
+
- max-age=0
|
41
|
+
Content-Type:
|
42
|
+
- application/vnd.contentful.management.v1+json
|
43
|
+
Date:
|
44
|
+
- Mon, 11 May 2015 09:40:07 GMT
|
45
|
+
Etag:
|
46
|
+
- '"52487c7acbb13bc23d9868ed9a4cf707"'
|
47
|
+
Server:
|
48
|
+
- nginx
|
49
|
+
Status:
|
50
|
+
- 200 OK
|
51
|
+
X-Contentful-Request-Id:
|
52
|
+
- 9f3-1404891018
|
53
|
+
Content-Length:
|
54
|
+
- '447'
|
55
|
+
Connection:
|
56
|
+
- Close
|
57
|
+
body:
|
58
|
+
encoding: UTF-8
|
59
|
+
string: |+
|
60
|
+
{
|
61
|
+
"sys":{
|
62
|
+
"type":"Space",
|
63
|
+
"id":"0agypmo1waov",
|
64
|
+
"version":1,
|
65
|
+
"createdBy":{
|
66
|
+
"sys":{
|
67
|
+
"type":"Link",
|
68
|
+
"linkType":"User",
|
69
|
+
"id":"4FLrUHftHW3v2BLi9fzfjU"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"createdAt":"2015-05-11T09:32:08Z",
|
73
|
+
"updatedBy":{
|
74
|
+
"sys":{
|
75
|
+
"type":"Link",
|
76
|
+
"linkType":"User",
|
77
|
+
"id":"4FLrUHftHW3v2BLi9fzfjU"
|
78
|
+
}
|
79
|
+
},
|
80
|
+
"updatedAt":"2015-05-11T09:32:08Z"
|
81
|
+
},
|
82
|
+
"name":"yolo"
|
83
|
+
}
|
84
|
+
|
85
|
+
http_version:
|
86
|
+
recorded_at: Mon, 11 May 2015 09:40:07 GMT
|
87
|
+
- request:
|
88
|
+
method: get
|
89
|
+
uri: https://api.contentful.com/spaces/0agypmo1waov/content_types
|
90
|
+
body:
|
91
|
+
encoding: US-ASCII
|
92
|
+
string: ''
|
93
|
+
headers:
|
94
|
+
User-Agent:
|
95
|
+
- RubyContentfulManagementGem/0.6.1
|
96
|
+
Authorization:
|
97
|
+
- Bearer <ACCESS_TOKEN>
|
98
|
+
Content-Type:
|
99
|
+
- application/vnd.contentful.management.v1+json
|
100
|
+
Content-Length:
|
101
|
+
- '0'
|
102
|
+
Connection:
|
103
|
+
- close
|
104
|
+
Host:
|
105
|
+
- api.contentful.com
|
106
|
+
response:
|
107
|
+
status:
|
108
|
+
code: 200
|
109
|
+
message: OK
|
110
|
+
headers:
|
111
|
+
Access-Control-Allow-Headers:
|
112
|
+
- 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
|
113
|
+
Access-Control-Allow-Methods:
|
114
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
115
|
+
Access-Control-Allow-Origin:
|
116
|
+
- '*'
|
117
|
+
Access-Control-Expose-Headers:
|
118
|
+
- Etag
|
119
|
+
Access-Control-Max-Age:
|
120
|
+
- '1728000'
|
121
|
+
Cf-Space-Id:
|
122
|
+
- 0agypmo1waov
|
123
|
+
Content-Type:
|
124
|
+
- application/vnd.contentful.management.v1+json
|
125
|
+
Date:
|
126
|
+
- Mon, 11 May 2015 09:40:09 GMT
|
127
|
+
Etag:
|
128
|
+
- '"fb29adcfd8a4e48f0e0e5d6b262d5429"'
|
129
|
+
Server:
|
130
|
+
- nginx
|
131
|
+
X-Contentful-Request-Id:
|
132
|
+
- content-api:6ivNBCchtSamAGCIwqQmcw
|
133
|
+
X-Powered-By:
|
134
|
+
- Express
|
135
|
+
Content-Length:
|
136
|
+
- '1485'
|
137
|
+
Connection:
|
138
|
+
- Close
|
139
|
+
body:
|
140
|
+
encoding: UTF-8
|
141
|
+
string: |
|
142
|
+
{
|
143
|
+
"sys": {
|
144
|
+
"type": "Array"
|
145
|
+
},
|
146
|
+
"total": 1,
|
147
|
+
"skip": 0,
|
148
|
+
"limit": 100,
|
149
|
+
"items": [
|
150
|
+
{
|
151
|
+
"name": "YOLO",
|
152
|
+
"fields": [
|
153
|
+
{
|
154
|
+
"name": "Name",
|
155
|
+
"id": "name",
|
156
|
+
"type": "Symbol",
|
157
|
+
"localized": true
|
158
|
+
},
|
159
|
+
{
|
160
|
+
"name": "YOLO",
|
161
|
+
"id": "yolo",
|
162
|
+
"type": "Text",
|
163
|
+
"localized": true
|
164
|
+
}
|
165
|
+
],
|
166
|
+
"displayField": "name",
|
167
|
+
"sys": {
|
168
|
+
"id": "5U4xpaLDQ4S8MCGMCC6yCa",
|
169
|
+
"type": "ContentType",
|
170
|
+
"createdAt": "2015-05-11T09:33:00.154Z",
|
171
|
+
"createdBy": {
|
172
|
+
"sys": {
|
173
|
+
"type": "Link",
|
174
|
+
"linkType": "User",
|
175
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
176
|
+
}
|
177
|
+
},
|
178
|
+
"space": {
|
179
|
+
"sys": {
|
180
|
+
"type": "Link",
|
181
|
+
"linkType": "Space",
|
182
|
+
"id": "0agypmo1waov"
|
183
|
+
}
|
184
|
+
},
|
185
|
+
"firstPublishedAt": "2015-05-11T09:33:58.032Z",
|
186
|
+
"publishedCounter": 2,
|
187
|
+
"publishedAt": "2015-05-11T09:35:45.788Z",
|
188
|
+
"publishedBy": {
|
189
|
+
"sys": {
|
190
|
+
"type": "Link",
|
191
|
+
"linkType": "User",
|
192
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
193
|
+
}
|
194
|
+
},
|
195
|
+
"publishedVersion": 4,
|
196
|
+
"version": 5,
|
197
|
+
"updatedAt": "2015-05-11T09:35:45.841Z",
|
198
|
+
"updatedBy": {
|
199
|
+
"sys": {
|
200
|
+
"type": "Link",
|
201
|
+
"linkType": "User",
|
202
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
]
|
208
|
+
}
|
209
|
+
http_version:
|
210
|
+
recorded_at: Mon, 11 May 2015 09:40:10 GMT
|
211
|
+
- request:
|
212
|
+
method: get
|
213
|
+
uri: https://api.contentful.com/spaces/0agypmo1waov/entries/4epXENbO8wsaOukgqquYcI
|
214
|
+
body:
|
215
|
+
encoding: US-ASCII
|
216
|
+
string: ''
|
217
|
+
headers:
|
218
|
+
User-Agent:
|
219
|
+
- RubyContentfulManagementGem/0.6.1
|
220
|
+
Authorization:
|
221
|
+
- Bearer <ACCESS_TOKEN>
|
222
|
+
Content-Type:
|
223
|
+
- application/vnd.contentful.management.v1+json
|
224
|
+
Content-Length:
|
225
|
+
- '0'
|
226
|
+
Connection:
|
227
|
+
- close
|
228
|
+
Host:
|
229
|
+
- api.contentful.com
|
230
|
+
response:
|
231
|
+
status:
|
232
|
+
code: 200
|
233
|
+
message: OK
|
234
|
+
headers:
|
235
|
+
Access-Control-Allow-Headers:
|
236
|
+
- 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
|
237
|
+
Access-Control-Allow-Methods:
|
238
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
239
|
+
Access-Control-Allow-Origin:
|
240
|
+
- '*'
|
241
|
+
Access-Control-Expose-Headers:
|
242
|
+
- Etag
|
243
|
+
Access-Control-Max-Age:
|
244
|
+
- '1728000'
|
245
|
+
Cf-Space-Id:
|
246
|
+
- 0agypmo1waov
|
247
|
+
Content-Type:
|
248
|
+
- application/vnd.contentful.management.v1+json
|
249
|
+
Date:
|
250
|
+
- Mon, 11 May 2015 09:40:10 GMT
|
251
|
+
Etag:
|
252
|
+
- '"172a1c397d3eae8112cb16220255a350"'
|
253
|
+
Server:
|
254
|
+
- nginx
|
255
|
+
X-Contentful-Request-Id:
|
256
|
+
- content-api:YjOfVpr0uyU422iICCiYW
|
257
|
+
X-Powered-By:
|
258
|
+
- Express
|
259
|
+
Content-Length:
|
260
|
+
- '1139'
|
261
|
+
Connection:
|
262
|
+
- Close
|
263
|
+
body:
|
264
|
+
encoding: UTF-8
|
265
|
+
string: |
|
266
|
+
{
|
267
|
+
"sys": {
|
268
|
+
"id": "4epXENbO8wsaOukgqquYcI",
|
269
|
+
"type": "Entry",
|
270
|
+
"createdAt": "2015-05-11T09:36:57.750Z",
|
271
|
+
"createdBy": {
|
272
|
+
"sys": {
|
273
|
+
"type": "Link",
|
274
|
+
"linkType": "User",
|
275
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
276
|
+
}
|
277
|
+
},
|
278
|
+
"space": {
|
279
|
+
"sys": {
|
280
|
+
"type": "Link",
|
281
|
+
"linkType": "Space",
|
282
|
+
"id": "0agypmo1waov"
|
283
|
+
}
|
284
|
+
},
|
285
|
+
"contentType": {
|
286
|
+
"sys": {
|
287
|
+
"type": "Link",
|
288
|
+
"linkType": "ContentType",
|
289
|
+
"id": "5U4xpaLDQ4S8MCGMCC6yCa"
|
290
|
+
}
|
291
|
+
},
|
292
|
+
"firstPublishedAt": "2015-05-11T09:37:09.215Z",
|
293
|
+
"publishedCounter": 1,
|
294
|
+
"publishedAt": "2015-05-11T09:37:09.215Z",
|
295
|
+
"publishedBy": {
|
296
|
+
"sys": {
|
297
|
+
"type": "Link",
|
298
|
+
"linkType": "User",
|
299
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
300
|
+
}
|
301
|
+
},
|
302
|
+
"publishedVersion": 7,
|
303
|
+
"version": 8,
|
304
|
+
"updatedAt": "2015-05-11T09:37:09.263Z",
|
305
|
+
"updatedBy": {
|
306
|
+
"sys": {
|
307
|
+
"type": "Link",
|
308
|
+
"linkType": "User",
|
309
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
310
|
+
}
|
311
|
+
}
|
312
|
+
},
|
313
|
+
"fields": {
|
314
|
+
"name": {
|
315
|
+
"en-US": "test2"
|
316
|
+
},
|
317
|
+
"yolo": {
|
318
|
+
"en-US": "YOLO"
|
319
|
+
}
|
320
|
+
}
|
321
|
+
}
|
322
|
+
http_version:
|
323
|
+
recorded_at: Mon, 11 May 2015 09:40:11 GMT
|
324
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,326 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.contentful.com/spaces/0agypmo1waov
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulManagementGem/0.6.1
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
Content-Length:
|
17
|
+
- '0'
|
18
|
+
Connection:
|
19
|
+
- close
|
20
|
+
Host:
|
21
|
+
- api.contentful.com
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 200
|
25
|
+
message: OK
|
26
|
+
headers:
|
27
|
+
Accept-Ranges:
|
28
|
+
- bytes
|
29
|
+
Access-Control-Allow-Headers:
|
30
|
+
- 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
|
31
|
+
Access-Control-Allow-Methods:
|
32
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- '*'
|
35
|
+
Access-Control-Expose-Headers:
|
36
|
+
- Etag
|
37
|
+
Access-Control-Max-Age:
|
38
|
+
- '1728000'
|
39
|
+
Cache-Control:
|
40
|
+
- max-age=0
|
41
|
+
Content-Type:
|
42
|
+
- application/vnd.contentful.management.v1+json
|
43
|
+
Date:
|
44
|
+
- Mon, 11 May 2015 09:40:04 GMT
|
45
|
+
Etag:
|
46
|
+
- '"52487c7acbb13bc23d9868ed9a4cf707"'
|
47
|
+
Server:
|
48
|
+
- nginx
|
49
|
+
Status:
|
50
|
+
- 200 OK
|
51
|
+
X-Contentful-Request-Id:
|
52
|
+
- c0e-1764378616
|
53
|
+
Content-Length:
|
54
|
+
- '447'
|
55
|
+
Connection:
|
56
|
+
- Close
|
57
|
+
body:
|
58
|
+
encoding: UTF-8
|
59
|
+
string: |+
|
60
|
+
{
|
61
|
+
"sys":{
|
62
|
+
"type":"Space",
|
63
|
+
"id":"0agypmo1waov",
|
64
|
+
"version":1,
|
65
|
+
"createdBy":{
|
66
|
+
"sys":{
|
67
|
+
"type":"Link",
|
68
|
+
"linkType":"User",
|
69
|
+
"id":"4FLrUHftHW3v2BLi9fzfjU"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"createdAt":"2015-05-11T09:32:08Z",
|
73
|
+
"updatedBy":{
|
74
|
+
"sys":{
|
75
|
+
"type":"Link",
|
76
|
+
"linkType":"User",
|
77
|
+
"id":"4FLrUHftHW3v2BLi9fzfjU"
|
78
|
+
}
|
79
|
+
},
|
80
|
+
"updatedAt":"2015-05-11T09:32:08Z"
|
81
|
+
},
|
82
|
+
"name":"yolo"
|
83
|
+
}
|
84
|
+
|
85
|
+
http_version:
|
86
|
+
recorded_at: Mon, 11 May 2015 09:40:04 GMT
|
87
|
+
- request:
|
88
|
+
method: get
|
89
|
+
uri: https://api.contentful.com/spaces/0agypmo1waov/content_types
|
90
|
+
body:
|
91
|
+
encoding: US-ASCII
|
92
|
+
string: ''
|
93
|
+
headers:
|
94
|
+
User-Agent:
|
95
|
+
- RubyContentfulManagementGem/0.6.1
|
96
|
+
Authorization:
|
97
|
+
- Bearer <ACCESS_TOKEN>
|
98
|
+
Content-Type:
|
99
|
+
- application/vnd.contentful.management.v1+json
|
100
|
+
Content-Length:
|
101
|
+
- '0'
|
102
|
+
Connection:
|
103
|
+
- close
|
104
|
+
Host:
|
105
|
+
- api.contentful.com
|
106
|
+
response:
|
107
|
+
status:
|
108
|
+
code: 200
|
109
|
+
message: OK
|
110
|
+
headers:
|
111
|
+
Access-Control-Allow-Headers:
|
112
|
+
- 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
|
113
|
+
Access-Control-Allow-Methods:
|
114
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
115
|
+
Access-Control-Allow-Origin:
|
116
|
+
- '*'
|
117
|
+
Access-Control-Expose-Headers:
|
118
|
+
- Etag
|
119
|
+
Access-Control-Max-Age:
|
120
|
+
- '1728000'
|
121
|
+
Cf-Space-Id:
|
122
|
+
- 0agypmo1waov
|
123
|
+
Content-Type:
|
124
|
+
- application/vnd.contentful.management.v1+json
|
125
|
+
Date:
|
126
|
+
- Mon, 11 May 2015 09:40:06 GMT
|
127
|
+
Etag:
|
128
|
+
- '"fb29adcfd8a4e48f0e0e5d6b262d5429"'
|
129
|
+
Server:
|
130
|
+
- nginx
|
131
|
+
X-Contentful-Request-Id:
|
132
|
+
- content-api:1kn9yCbv2mIEewkWMQKwem
|
133
|
+
X-Powered-By:
|
134
|
+
- Express
|
135
|
+
Content-Length:
|
136
|
+
- '1485'
|
137
|
+
Connection:
|
138
|
+
- Close
|
139
|
+
body:
|
140
|
+
encoding: UTF-8
|
141
|
+
string: |
|
142
|
+
{
|
143
|
+
"sys": {
|
144
|
+
"type": "Array"
|
145
|
+
},
|
146
|
+
"total": 1,
|
147
|
+
"skip": 0,
|
148
|
+
"limit": 100,
|
149
|
+
"items": [
|
150
|
+
{
|
151
|
+
"name": "YOLO",
|
152
|
+
"fields": [
|
153
|
+
{
|
154
|
+
"name": "Name",
|
155
|
+
"id": "name",
|
156
|
+
"type": "Symbol",
|
157
|
+
"localized": true
|
158
|
+
},
|
159
|
+
{
|
160
|
+
"name": "YOLO",
|
161
|
+
"id": "yolo",
|
162
|
+
"type": "Text",
|
163
|
+
"localized": true
|
164
|
+
}
|
165
|
+
],
|
166
|
+
"displayField": "name",
|
167
|
+
"sys": {
|
168
|
+
"id": "5U4xpaLDQ4S8MCGMCC6yCa",
|
169
|
+
"type": "ContentType",
|
170
|
+
"createdAt": "2015-05-11T09:33:00.154Z",
|
171
|
+
"createdBy": {
|
172
|
+
"sys": {
|
173
|
+
"type": "Link",
|
174
|
+
"linkType": "User",
|
175
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
176
|
+
}
|
177
|
+
},
|
178
|
+
"space": {
|
179
|
+
"sys": {
|
180
|
+
"type": "Link",
|
181
|
+
"linkType": "Space",
|
182
|
+
"id": "0agypmo1waov"
|
183
|
+
}
|
184
|
+
},
|
185
|
+
"firstPublishedAt": "2015-05-11T09:33:58.032Z",
|
186
|
+
"publishedCounter": 2,
|
187
|
+
"publishedAt": "2015-05-11T09:35:45.788Z",
|
188
|
+
"publishedBy": {
|
189
|
+
"sys": {
|
190
|
+
"type": "Link",
|
191
|
+
"linkType": "User",
|
192
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
193
|
+
}
|
194
|
+
},
|
195
|
+
"publishedVersion": 4,
|
196
|
+
"version": 5,
|
197
|
+
"updatedAt": "2015-05-11T09:35:45.841Z",
|
198
|
+
"updatedBy": {
|
199
|
+
"sys": {
|
200
|
+
"type": "Link",
|
201
|
+
"linkType": "User",
|
202
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
]
|
208
|
+
}
|
209
|
+
http_version:
|
210
|
+
recorded_at: Mon, 11 May 2015 09:40:06 GMT
|
211
|
+
- request:
|
212
|
+
method: get
|
213
|
+
uri: https://api.contentful.com/spaces/0agypmo1waov/entries/5cMXsmSd5So6iggWi268eG
|
214
|
+
body:
|
215
|
+
encoding: US-ASCII
|
216
|
+
string: ''
|
217
|
+
headers:
|
218
|
+
User-Agent:
|
219
|
+
- RubyContentfulManagementGem/0.6.1
|
220
|
+
Authorization:
|
221
|
+
- Bearer <ACCESS_TOKEN>
|
222
|
+
Content-Type:
|
223
|
+
- application/vnd.contentful.management.v1+json
|
224
|
+
Content-Length:
|
225
|
+
- '0'
|
226
|
+
Connection:
|
227
|
+
- close
|
228
|
+
Host:
|
229
|
+
- api.contentful.com
|
230
|
+
response:
|
231
|
+
status:
|
232
|
+
code: 200
|
233
|
+
message: OK
|
234
|
+
headers:
|
235
|
+
Access-Control-Allow-Headers:
|
236
|
+
- 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
|
237
|
+
Access-Control-Allow-Methods:
|
238
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
239
|
+
Access-Control-Allow-Origin:
|
240
|
+
- '*'
|
241
|
+
Access-Control-Expose-Headers:
|
242
|
+
- Etag
|
243
|
+
Access-Control-Max-Age:
|
244
|
+
- '1728000'
|
245
|
+
Cf-Space-Id:
|
246
|
+
- 0agypmo1waov
|
247
|
+
Content-Type:
|
248
|
+
- application/vnd.contentful.management.v1+json
|
249
|
+
Date:
|
250
|
+
- Mon, 11 May 2015 09:40:06 GMT
|
251
|
+
Etag:
|
252
|
+
- '"846472b82ccf83274a4b6ac82ed664f6"'
|
253
|
+
Server:
|
254
|
+
- nginx
|
255
|
+
X-Contentful-Request-Id:
|
256
|
+
- content-api:5uem7drI9aSMkuiWaukUW4
|
257
|
+
X-Powered-By:
|
258
|
+
- Express
|
259
|
+
Content-Length:
|
260
|
+
- '1203'
|
261
|
+
Connection:
|
262
|
+
- Close
|
263
|
+
body:
|
264
|
+
encoding: UTF-8
|
265
|
+
string: |
|
266
|
+
{
|
267
|
+
"sys": {
|
268
|
+
"id": "5cMXsmSd5So6iggWi268eG",
|
269
|
+
"type": "Entry",
|
270
|
+
"createdAt": "2015-05-11T09:34:57.142Z",
|
271
|
+
"createdBy": {
|
272
|
+
"sys": {
|
273
|
+
"type": "Link",
|
274
|
+
"linkType": "User",
|
275
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
276
|
+
}
|
277
|
+
},
|
278
|
+
"space": {
|
279
|
+
"sys": {
|
280
|
+
"type": "Link",
|
281
|
+
"linkType": "Space",
|
282
|
+
"id": "0agypmo1waov"
|
283
|
+
}
|
284
|
+
},
|
285
|
+
"contentType": {
|
286
|
+
"sys": {
|
287
|
+
"type": "Link",
|
288
|
+
"linkType": "ContentType",
|
289
|
+
"id": "5U4xpaLDQ4S8MCGMCC6yCa"
|
290
|
+
}
|
291
|
+
},
|
292
|
+
"firstPublishedAt": "2015-05-11T09:35:18.493Z",
|
293
|
+
"publishedCounter": 2,
|
294
|
+
"publishedAt": "2015-05-11T09:36:47.715Z",
|
295
|
+
"publishedBy": {
|
296
|
+
"sys": {
|
297
|
+
"type": "Link",
|
298
|
+
"linkType": "User",
|
299
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
300
|
+
}
|
301
|
+
},
|
302
|
+
"publishedVersion": 29,
|
303
|
+
"version": 30,
|
304
|
+
"updatedAt": "2015-05-11T09:36:47.769Z",
|
305
|
+
"updatedBy": {
|
306
|
+
"sys": {
|
307
|
+
"type": "Link",
|
308
|
+
"linkType": "User",
|
309
|
+
"id": "4FLrUHftHW3v2BLi9fzfjU"
|
310
|
+
}
|
311
|
+
}
|
312
|
+
},
|
313
|
+
"fields": {
|
314
|
+
"name": {
|
315
|
+
"en-US": "test1",
|
316
|
+
"de-DE": "mein Name"
|
317
|
+
},
|
318
|
+
"yolo": {
|
319
|
+
"en-US": "some text",
|
320
|
+
"de-DE": "etwas Text"
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
http_version:
|
325
|
+
recorded_at: Mon, 11 May 2015 09:40:07 GMT
|
326
|
+
recorded_with: VCR 2.9.3
|
@@ -584,6 +584,30 @@ module Contentful
|
|
584
584
|
end
|
585
585
|
end
|
586
586
|
|
587
|
+
describe 'handling of localized values' do
|
588
|
+
it 'retrieves localized value if it exists' do
|
589
|
+
vcr('entry/locales/retrieve_localized') do
|
590
|
+
space = Contentful::Management::Space.find('0agypmo1waov')
|
591
|
+
entry = space.entries.find('5cMXsmSd5So6iggWi268eG')
|
592
|
+
entry.locale = 'de-DE'
|
593
|
+
|
594
|
+
expect(entry.fields.count).to eq 2
|
595
|
+
expect(entry.fields[:yolo]).to eq 'etwas Text'
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
it 'retrieves value of default locale if it has not been localized' do
|
600
|
+
vcr('entry/locales/fallback_to_default_locale') do
|
601
|
+
space = Contentful::Management::Space.find('0agypmo1waov')
|
602
|
+
entry = space.entries.find('4epXENbO8wsaOukgqquYcI')
|
603
|
+
entry.locale = 'de-DE'
|
604
|
+
|
605
|
+
expect(entry.fields.count).to eq 2
|
606
|
+
expect(entry.fields[:yolo]).to eq 'YOLO'
|
607
|
+
end
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
587
611
|
describe '#fields_from_attributes' do
|
588
612
|
|
589
613
|
it 'parses all kind of fields' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Protas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0.
|
21
|
+
version: '0.8'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '0.
|
28
|
+
version: '0.8'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: multi_json
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -336,6 +336,8 @@ files:
|
|
336
336
|
- spec/fixtures/vcr_cassettes/entry/find.yml
|
337
337
|
- spec/fixtures/vcr_cassettes/entry/find_not_found.yml
|
338
338
|
- spec/fixtures/vcr_cassettes/entry/limited_entries.yml
|
339
|
+
- spec/fixtures/vcr_cassettes/entry/locales/fallback_to_default_locale.yml
|
340
|
+
- spec/fixtures/vcr_cassettes/entry/locales/retrieve_localized.yml
|
339
341
|
- spec/fixtures/vcr_cassettes/entry/publish.yml
|
340
342
|
- spec/fixtures/vcr_cassettes/entry/publish_already_published.yml
|
341
343
|
- spec/fixtures/vcr_cassettes/entry/published_false.yml
|
@@ -568,6 +570,8 @@ test_files:
|
|
568
570
|
- spec/fixtures/vcr_cassettes/entry/find.yml
|
569
571
|
- spec/fixtures/vcr_cassettes/entry/find_not_found.yml
|
570
572
|
- spec/fixtures/vcr_cassettes/entry/limited_entries.yml
|
573
|
+
- spec/fixtures/vcr_cassettes/entry/locales/fallback_to_default_locale.yml
|
574
|
+
- spec/fixtures/vcr_cassettes/entry/locales/retrieve_localized.yml
|
571
575
|
- spec/fixtures/vcr_cassettes/entry/publish.yml
|
572
576
|
- spec/fixtures/vcr_cassettes/entry/publish_already_published.yml
|
573
577
|
- spec/fixtures/vcr_cassettes/entry/published_false.yml
|