contentful 0.12.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +41 -1
- data/contentful.gemspec +1 -1
- data/lib/contentful/resource.rb +18 -1
- data/lib/contentful/version.rb +1 -1
- data/spec/dynamic_entry_spec.rb +41 -0
- data/spec/fixtures/vcr_cassettes/entry/json_objects.yml +88 -0
- data/spec/fixtures/vcr_cassettes/entry/json_objects_client.yml +86 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0113f1da37746a15f2e342b3d7248ea3edffce5e
|
4
|
+
data.tar.gz: a3c9f048f5f9a8fd6dc2ecf978af27c2dc986952
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d39379d1187ab7037fb11000ca0233ff0c101c855a6ef01e651244ec0516e49822a5afd1e5d9b94fa9c20d487fa13bbd51c9abeff7467e6b84ca0930a96a2a
|
7
|
+
data.tar.gz: 84443697de10d3b27db87d08f7fd5b5385de83bfd32e44bdc3c58e8374f127772becb209e1e155e85957cf61aaa6fe20c7c4921d9d781df02a8c9b1a0f4ec0bf
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,48 @@
|
|
1
1
|
# Change Log
|
2
|
+
|
2
3
|
## Unreleased
|
3
4
|
|
4
|
-
## 0.
|
5
|
+
## 1.0.0
|
6
|
+
|
7
|
+
**ATTENTION**: Breaking changes on how JSON Fields are parsed. All keys are now symbolized, including
|
8
|
+
nested hashes. Parsing errors have been fixed, particularly for `array`, `null` and `boolean` present on the first
|
9
|
+
level of the JSON field. Also, on release 0.11.0, it was fixed that JSON Fields were being treated as locales.
|
10
|
+
This change increases consistency for the SDK, treating everything the same way. We strive for consistency and
|
11
|
+
quality in our tools.
|
12
|
+
|
13
|
+
The following `diff` shows previous and current state. This is the contents of the JSON Field we test this feature against.
|
14
|
+
|
15
|
+
```diff
|
16
|
+
- {:null=>"",
|
17
|
+
- :text=>"some text",
|
18
|
+
- :array=>"[1, 2, 3]",
|
19
|
+
- :number=>123,
|
20
|
+
- :object=>
|
21
|
+
- {"null"=>nil,
|
22
|
+
- "text"=>"bar",
|
23
|
+
- "array"=>[1, 2, 3],
|
24
|
+
- "number"=>123,
|
25
|
+
- "object"=>{"foo"=>"bar"},
|
26
|
+
- "boolean"=>false},
|
27
|
+
- :boolean=>"true"}
|
28
|
+
+ {:null=>nil,
|
29
|
+
+ :text=>"some text",
|
30
|
+
+ :array=>[1, 2, 3],
|
31
|
+
+ :number=>123,
|
32
|
+
+ :object=>
|
33
|
+
+ {:null=>nil,
|
34
|
+
+ :text=>"bar",
|
35
|
+
+ :array=>[1, 2, 3],
|
36
|
+
+ :number=>123,
|
37
|
+
+ :object=>{:foo=>"bar"},
|
38
|
+
+ :boolean=>false},
|
39
|
+
+ :boolean=>true}
|
40
|
+
```
|
5
41
|
|
42
|
+
### Fixed
|
43
|
+
* Fixed JSON Field Parsing [#96](https://github.com/contentful/contentful.rb/issues/96)
|
44
|
+
|
45
|
+
## 0.12.0
|
6
46
|
### Added
|
7
47
|
* Added Rate Limit automatic handling
|
8
48
|
|
data/contentful.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.summary = 'contentful'
|
7
7
|
gem.description = 'Ruby client for the https://www.contentful.com Content Delivery API'
|
8
8
|
gem.license = 'MIT'
|
9
|
-
gem.authors = ['Contentful GmbH (Jan Lelis)', 'Contentful GmbH (Andreas Tiefenthaler)']
|
9
|
+
gem.authors = ['Contentful GmbH (Jan Lelis)', 'Contentful GmbH (Andreas Tiefenthaler)', 'Contentful GmbH (David Litvak Bruno)']
|
10
10
|
gem.email = 'rubygems@contentful.com'
|
11
11
|
gem.homepage = 'https://github.com/contentful/contentful.rb'
|
12
12
|
|
data/lib/contentful/resource.rb
CHANGED
@@ -178,7 +178,7 @@ module Contentful
|
|
178
178
|
value.map { |v| coerce_or_create_class(v, what) }
|
179
179
|
elsif should_coerce_hash?(value)
|
180
180
|
::Hash[value.map do |k, v|
|
181
|
-
to_coerce = v
|
181
|
+
to_coerce = pre_coerce(v)
|
182
182
|
coercion = v.is_a?(Numeric) ? v : coerce_or_create_class(to_coerce, what)
|
183
183
|
[k.to_sym, coercion]
|
184
184
|
end]
|
@@ -187,6 +187,23 @@ module Contentful
|
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
+
def pre_coerce(value)
|
191
|
+
case value
|
192
|
+
when Numeric, true, false, nil
|
193
|
+
value
|
194
|
+
when Hash
|
195
|
+
result = {}
|
196
|
+
value.each_key do |k|
|
197
|
+
result[k.to_sym] = pre_coerce(value[k])
|
198
|
+
end
|
199
|
+
result
|
200
|
+
when ::Array
|
201
|
+
value.map { |e| pre_coerce(e) }
|
202
|
+
else
|
203
|
+
value.to_s
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
190
207
|
def should_coerce_hash?(value)
|
191
208
|
value.is_a?(::Hash) &&
|
192
209
|
!is_a?(Asset) &&
|
data/lib/contentful/version.rb
CHANGED
data/spec/dynamic_entry_spec.rb
CHANGED
@@ -31,4 +31,45 @@ describe Contentful::DynamicEntry do
|
|
31
31
|
expect(nyancat.birthday).to be_a DateTime
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
describe 'issues' do
|
36
|
+
describe 'JSON Fields should not be treated as locale data - #96' do
|
37
|
+
before do
|
38
|
+
vcr('entry/json_objects_client') {
|
39
|
+
@client = create_client(
|
40
|
+
space: 'h425t6gef30p',
|
41
|
+
access_token: '278f7aa72f2eb90c0e002d60f85bf2144c925acd2d37dd990d3ca274f25076cf',
|
42
|
+
dynamic_entries: :auto
|
43
|
+
)
|
44
|
+
|
45
|
+
}
|
46
|
+
vcr('entry/json_objects') {
|
47
|
+
@entry = @client.entries.first
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'only has default locale' do
|
52
|
+
expect(@entry.instance_variable_get(:@fields).keys).to eq ['en-US']
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'can obtain all values properly' do
|
56
|
+
expect(@entry.name).to eq('Test')
|
57
|
+
expect(@entry.object_test).to eq({
|
58
|
+
null: nil,
|
59
|
+
text: 'some text',
|
60
|
+
array: [1, 2, 3],
|
61
|
+
number: 123,
|
62
|
+
boolean: true,
|
63
|
+
object: {
|
64
|
+
null: nil,
|
65
|
+
text: 'bar',
|
66
|
+
array: [1, 2, 3],
|
67
|
+
number: 123,
|
68
|
+
boolean: false,
|
69
|
+
object: {foo: 'bar'}
|
70
|
+
}
|
71
|
+
})
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
34
75
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://cdn.contentful.com/spaces/h425t6gef30p/entries
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulGem/0.12.0
|
12
|
+
Authorization:
|
13
|
+
- Bearer 278f7aa72f2eb90c0e002d60f85bf2144c925acd2d37dd990d3ca274f25076cf
|
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
|
+
- Etag
|
36
|
+
Access-Control-Max-Age:
|
37
|
+
- '86400'
|
38
|
+
Cache-Control:
|
39
|
+
- max-age=0
|
40
|
+
Content-Encoding:
|
41
|
+
- gzip
|
42
|
+
Content-Type:
|
43
|
+
- application/vnd.contentful.delivery.v1+json
|
44
|
+
Etag:
|
45
|
+
- W/"ef08daf55d889bfac04481b2b1c2df2d"
|
46
|
+
Server:
|
47
|
+
- nginx
|
48
|
+
X-Content-Type-Options:
|
49
|
+
- nosniff
|
50
|
+
X-Contentful-Request-Id:
|
51
|
+
- 4c3-1865000018
|
52
|
+
Content-Length:
|
53
|
+
- '452'
|
54
|
+
Accept-Ranges:
|
55
|
+
- bytes
|
56
|
+
Date:
|
57
|
+
- Tue, 23 Aug 2016 16:02:57 GMT
|
58
|
+
Via:
|
59
|
+
- 1.1 varnish
|
60
|
+
Age:
|
61
|
+
- '0'
|
62
|
+
Connection:
|
63
|
+
- close
|
64
|
+
X-Served-By:
|
65
|
+
- cache-gru7124-GRU
|
66
|
+
X-Cache:
|
67
|
+
- MISS
|
68
|
+
X-Cache-Hits:
|
69
|
+
- '0'
|
70
|
+
Vary:
|
71
|
+
- Accept-Encoding
|
72
|
+
body:
|
73
|
+
encoding: ASCII-8BIT
|
74
|
+
string: !binary |-
|
75
|
+
H4sIAAAAAAAAA61TO2/CMBDe+RWR54KcJygbRaiq6BaqSq0YTGJal8SOHKdq
|
76
|
+
hPjv9TmEOAjapR4S3/u783eHkeOgqqlQ7Bz0VQuqKamW0FxK0iCtO96BjxKK
|
77
|
+
5FrvGqnas1IL2Ag5K5gCE25lpmgBCd9MwjbtRRVTqSpJCqU6j1ZpYQGFUXaY
|
78
|
+
nhjfI6jZH12d79cnzInJeOHAMmjnI/BCFb3TnY9L6Ko7x/Pd9Nke1MYEUXKP
|
79
|
+
V9M6Ch7Zw2qReC9LESRW/jOwJVeysQ2ppETRbA5zQR52ozGejT1/7YZxEMTu
|
80
|
+
dBLO8KsdUJfZrYDQjz08wcFsECDpF6uY4LqAZyFPBVeUq9NE/m+0Cyvv1QGL
|
81
|
+
7SdN1ZpW6u/x5iIluWEZ5ePnpAs4vwDaMZpnPSnhVRAnhQkxJayOrcIXXOJ1
|
82
|
+
DpSFnw0ZKfpt3qUSBXWMMDATw/yOvx0nDPH7Y80clL5l3Ayy8brYUqnTuZ4/
|
83
|
+
MLS4tcF+JOjzOmpYgxPuLZGXJL+O2WnX9RfcQ+SOM8BuwFxHr0038GvLTggY
|
84
|
+
L8AczMzaMICEtkLklACDdySvqL2Vg0n1fkrWvVu3uu0fvpvRcfQDnv3xztIE
|
85
|
+
AAA=
|
86
|
+
http_version:
|
87
|
+
recorded_at: Tue, 23 Aug 2016 16:02:58 GMT
|
88
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,86 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://cdn.contentful.com/spaces/h425t6gef30p/content_types?limit=1000
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulGem/0.12.0
|
12
|
+
Authorization:
|
13
|
+
- Bearer 278f7aa72f2eb90c0e002d60f85bf2144c925acd2d37dd990d3ca274f25076cf
|
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
|
+
- Etag
|
36
|
+
Access-Control-Max-Age:
|
37
|
+
- '86400'
|
38
|
+
Cache-Control:
|
39
|
+
- max-age=0
|
40
|
+
Content-Encoding:
|
41
|
+
- gzip
|
42
|
+
Content-Type:
|
43
|
+
- application/vnd.contentful.delivery.v1+json
|
44
|
+
Etag:
|
45
|
+
- W/"eb9d46f11dd1b96e6e6323d12c51b2bb"
|
46
|
+
Server:
|
47
|
+
- nginx
|
48
|
+
X-Content-Type-Options:
|
49
|
+
- nosniff
|
50
|
+
X-Contentful-Request-Id:
|
51
|
+
- ddd-1897159726
|
52
|
+
Content-Length:
|
53
|
+
- '373'
|
54
|
+
Accept-Ranges:
|
55
|
+
- bytes
|
56
|
+
Date:
|
57
|
+
- Tue, 23 Aug 2016 16:02:57 GMT
|
58
|
+
Via:
|
59
|
+
- 1.1 varnish
|
60
|
+
Age:
|
61
|
+
- '0'
|
62
|
+
Connection:
|
63
|
+
- close
|
64
|
+
X-Served-By:
|
65
|
+
- cache-gru7121-GRU
|
66
|
+
X-Cache:
|
67
|
+
- MISS
|
68
|
+
X-Cache-Hits:
|
69
|
+
- '0'
|
70
|
+
Vary:
|
71
|
+
- Accept-Encoding
|
72
|
+
body:
|
73
|
+
encoding: ASCII-8BIT
|
74
|
+
string: !binary |-
|
75
|
+
H4sIAAAAAAAAA8VSPW/CMBDd+RXIc6kSAqhlQ5U6Ve0AUytUmeRorzixa5tK
|
76
|
+
KeK/12eT4FAYOtVLcl/v3ru7Xa/fZ6Y2bNrfuV9n2FqBs9hMa14z59tfUY6V
|
77
|
+
lgvnT71lNqickXhDYImWQkkSHGihJMQXjxhwT9r4VkbxnHo1GcEZkSGHdzak
|
78
|
+
HrDaMGp6fK59tVkcSM894kkCFqTnfTQc28kbrLNEkazm7dt/LzQ8Fmrk6gNy
|
79
|
+
uwBjI8yWzJ2sLFTW945Kcw3cQjGjkbBhkk4Gyc1gmC3S8XSUTrPsenSbPscF
|
80
|
+
W1X8rUDDFxqUFc38QLnlzgo0SvD6HkF43RUvj/SC5bxPv5WxAkyuUdmAzFqK
|
81
|
+
bE1Yx4XSiDorC8PqNKKcttljTMFHmn3O63IlRWdhTMicC/wGYr/mwkC8Tqbh
|
82
|
+
c4v6QtBp5ytxISjdlbq9NKjn1n5G1dkTiLSF+Kvt3kgkMUz6nyUexC79ly5+
|
83
|
+
2dv3fgBbrE0p/AMAAA==
|
84
|
+
http_version:
|
85
|
+
recorded_at: Tue, 23 Aug 2016 16:02:57 GMT
|
86
|
+
recorded_with: VCR 3.0.3
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentful GmbH (Jan Lelis)
|
8
8
|
- Contentful GmbH (Andreas Tiefenthaler)
|
9
|
+
- Contentful GmbH (David Litvak Bruno)
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
13
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: http
|
@@ -388,6 +389,8 @@ files:
|
|
388
389
|
- spec/fixtures/vcr_cassettes/entries.yml
|
389
390
|
- spec/fixtures/vcr_cassettes/entry.yml
|
390
391
|
- spec/fixtures/vcr_cassettes/entry/custom_resource.yml
|
392
|
+
- spec/fixtures/vcr_cassettes/entry/json_objects.yml
|
393
|
+
- spec/fixtures/vcr_cassettes/entry/json_objects_client.yml
|
391
394
|
- spec/fixtures/vcr_cassettes/entry/marshall.yml
|
392
395
|
- spec/fixtures/vcr_cassettes/entry/raw.yml
|
393
396
|
- spec/fixtures/vcr_cassettes/entry_cache.yml
|
@@ -445,7 +448,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
445
448
|
version: '0'
|
446
449
|
requirements: []
|
447
450
|
rubyforge_project:
|
448
|
-
rubygems_version: 2.5.
|
451
|
+
rubygems_version: 2.5.1
|
449
452
|
signing_key:
|
450
453
|
specification_version: 4
|
451
454
|
summary: contentful
|
@@ -482,6 +485,8 @@ test_files:
|
|
482
485
|
- spec/fixtures/vcr_cassettes/entries.yml
|
483
486
|
- spec/fixtures/vcr_cassettes/entry.yml
|
484
487
|
- spec/fixtures/vcr_cassettes/entry/custom_resource.yml
|
488
|
+
- spec/fixtures/vcr_cassettes/entry/json_objects.yml
|
489
|
+
- spec/fixtures/vcr_cassettes/entry/json_objects_client.yml
|
485
490
|
- spec/fixtures/vcr_cassettes/entry/marshall.yml
|
486
491
|
- spec/fixtures/vcr_cassettes/entry/raw.yml
|
487
492
|
- spec/fixtures/vcr_cassettes/entry_cache.yml
|