contentful 2.0.0 → 2.0.1

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: 3336395c12c33716d03ef5ccd4ca5662d0c9f0e4
4
- data.tar.gz: ff41b0e879b3ab72bc0962abeac4dae2fb49496a
3
+ metadata.gz: adb51bf63992e8954100bf135c6a03ae27470131
4
+ data.tar.gz: daaad9d76c496da15b3118caccd6d0c6060cbcbe
5
5
  SHA512:
6
- metadata.gz: 39692cf6bc73f11ea37ede62a11fc70f9ca5ccc7346cfe415d88dc53c320a30443669b7585df78ef13b657697a7f91fe126f01e26cdbab280ab03ebd5bcbdc5b
7
- data.tar.gz: a6d462ef93caf18c9179b36403911f255685bcacd3ff7a06c9f91eca40c5c8e1346474068f20766baa726513d9a63a0c5fee101f0037b6444230062bda5bf65a
6
+ metadata.gz: 489539c127176b6169dd2da6dc5c0a054e64e02eec27885644b38ac036c26d8dcf43296125a450884fd41a91161806f729e602864de9eaaeb26b63da8627ebaf
7
+ data.tar.gz: 131a32ea047617743fe160a713d4e4442464c3179949eb11845b10a012415bd380295521dbeb28a319dbd341e0db2e2dfe5eabd7fd1204c2dc098b30bea6a681
@@ -2,11 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.0.1
6
+
7
+ ### Fixed
8
+ * Fixed Integer/Decimal field serializations [#125](https://github.com/contentful/contentful.rb/issues/125)
9
+ * Fixed File coercion for Localized Assets [#129](https://github.com/contentful/contentful.rb/issues/129)
10
+
5
11
  ## 2.0.0
6
12
 
7
13
  **ATTENTION**: Breaking Changes introduces in order to simplify code and improve the ability to add new features.
8
14
 
9
- ## Changed
15
+ ### Changed
10
16
 
11
17
  * The removal of the Client and Request objects from the Resource objects, means that for example: Link#resolve and Array#next_page now require the client as a parameter.
12
18
  * Client#entry now uses /entries?sys.id=ENTRY_ID instead of /entries/ENTRY_ID to properly resolve includes.
@@ -20,6 +26,7 @@
20
26
  * Resource #inspect now provides a clearer and better output, without all the noise that was previously there
21
27
  * CustomResource was removed, now subclasses of Entry should be used instead.
22
28
  * `max_include_resolution_depth` option added to the client, defaults to 20.
29
+ * `sys` properties now match accessors.
23
30
  * Updated LICENSE
24
31
  * Updated examples
25
32
 
@@ -7,7 +7,10 @@ module Contentful
7
7
  class Asset < FieldsResource
8
8
  # @private
9
9
  def marshal_dump
10
- raw
10
+ {
11
+ configuration: @configuration,
12
+ raw: raw
13
+ }
11
14
  end
12
15
 
13
16
  # @private
@@ -64,16 +67,16 @@ module Contentful
64
67
  private
65
68
 
66
69
  def create_files!
67
- file_json = fields[:file]
70
+ file_json = raw.fetch('fields', {}).fetch('file', nil)
68
71
  return if file_json.nil?
69
72
 
70
73
  is_localized = file_json.keys.none? { |f| %w(fileName contentType details url).include? f }
71
74
  if is_localized
72
75
  locales.each do |locale|
73
- fields(locale)[:file] = ::Contentful::File.new(file_json[locale.to_s] || {})
76
+ @fields[locale][:file] = ::Contentful::File.new(file_json[locale.to_s] || {})
74
77
  end
75
78
  else
76
- fields[:file] = ::Contentful::File.new(file_json)
79
+ @fields[default_locale][:file] = ::Contentful::File.new(file_json)
77
80
  end
78
81
  end
79
82
 
@@ -27,12 +27,17 @@ module Contentful
27
27
 
28
28
  # @private
29
29
  def marshal_dump
30
- raw
30
+ {
31
+ configuration: @configuration,
32
+ raw: raw
33
+ }
31
34
  end
32
35
 
33
36
  # @private
34
37
  def marshal_load(raw_object)
35
- @raw = raw_object
38
+ @raw = raw_object[:raw]
39
+ @configuration = raw_object[:configuration]
40
+ @default_locale = @configuration[:default_locale]
36
41
  @sys = hydrate_sys
37
42
  @depth = 0
38
43
  define_sys_methods!
@@ -63,7 +63,7 @@ module Contentful
63
63
  def known_link?(name)
64
64
  field_name = name.to_sym
65
65
  return true if known_contentful_object?(fields[field_name])
66
- fields[field_name].is_a?(Enumerable) && known_contentful_object?(fields[field_name].first)
66
+ fields[field_name].is_a?(Enumerable) && fields[field_name].any? { |object| known_contentful_object?(object) }
67
67
  end
68
68
 
69
69
  def known_contentful_object?(object)
@@ -11,7 +11,7 @@ module Contentful
11
11
  'Text' => TextCoercion,
12
12
  'Symbol' => SymbolCoercion,
13
13
  'Integer' => IntegerCoercion,
14
- 'Float' => FloatCoercion,
14
+ 'Number' => FloatCoercion,
15
15
  'Boolean' => BooleanCoercion,
16
16
  'Date' => DateCoercion,
17
17
  'Location' => LocationCoercion,
@@ -42,13 +42,16 @@ module Contentful
42
42
 
43
43
  # @private
44
44
  def marshal_dump
45
- raw_with_links
45
+ {
46
+ configuration: @configuration,
47
+ raw: raw_with_links
48
+ }
46
49
  end
47
50
 
48
51
  # @private
49
52
  def marshal_load(raw_object)
50
53
  super(raw_object)
51
- localized = raw_object.fetch('fields', {}).all? { |_, v| v.is_a?(Hash) }
54
+ localized = raw_object[:raw].fetch('fields', {}).all? { |_, v| v.is_a?(Hash) }
52
55
  @fields = hydrate_fields(localized, [])
53
56
  define_fields_methods!
54
57
  end
@@ -16,14 +16,6 @@ module Contentful
16
16
  .downcase
17
17
  end
18
18
 
19
- # Returns true if resource is localized
20
- #
21
- # @return [true, false]
22
- def localized?(value)
23
- return false unless value.is_a? ::Hash
24
- value.keys.any? { |possible_locale| Contentful::Constants::KNOWN_LOCALES.include?(possible_locale) }
25
- end
26
-
27
19
  # Checks if value is a link
28
20
  #
29
21
  # @param value
@@ -1,5 +1,5 @@
1
1
  # Contentful Namespace
2
2
  module Contentful
3
3
  # Gem Version
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
@@ -120,4 +120,26 @@ describe Contentful::Asset do
120
120
  end
121
121
  end
122
122
  end
123
+
124
+ describe 'issues' do
125
+ it 'serializes files correctly for every locale - #129' do
126
+ vcr('assets/issues_129') {
127
+ client = create_client(
128
+ space: 'bht13amj0fva',
129
+ access_token: 'bb703a05e107148bed6ee246a9f6b3678c63fed7335632eb68fe1b689c801534'
130
+ )
131
+
132
+ asset = client.assets('sys.id' => '14bZJKTr6AoaGyeg4kYiWq', locale: '*').first
133
+
134
+ expect(asset.file).to be_a ::Contentful::File
135
+ expect(asset.file.file_name).to eq 'Flag_of_the_United_States.svg'
136
+
137
+ expect(asset.fields[:file]).to be_a ::Contentful::File
138
+ expect(asset.fields[:file].file_name).to eq 'Flag_of_the_United_States.svg'
139
+
140
+ expect(asset.fields('es')[:file]).to be_a ::Contentful::File
141
+ expect(asset.fields('es')[:file].file_name).to eq 'Flag_of_Spain.svg'
142
+ }
143
+ end
144
+ end
123
145
  end
@@ -329,5 +329,15 @@ describe Contentful::Entry do
329
329
  })
330
330
  end
331
331
  end
332
+
333
+ it 'Number (Integer and Decimal) values get properly serialized - #125' do
334
+ vcr('entries/issue_125') {
335
+ client = create_client(space: 'zui87wsu8q80', access_token: '64ff902c58cd14ea063d3ded810d1111a0266537e9aba283bad3319b1762c302', dynamic_entries: :auto)
336
+ entry = client.entries.first
337
+
338
+ expect(entry.integer).to eq 123
339
+ expect(entry.decimal).to eq 12.3
340
+ }
341
+ end
332
342
  end
333
343
  end
@@ -0,0 +1,90 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/bht13amj0fva/assets?locale=*&sys.id=14bZJKTr6AoaGyeg4kYiWq
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulGem/2.0.0
12
+ Authorization:
13
+ - Bearer bb703a05e107148bed6ee246a9f6b3678c63fed7335632eb68fe1b689c801534
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/"7e90131294f96e196d1e6c2dddb41ccb"
45
+ Server:
46
+ - Contentful
47
+ X-Content-Type-Options:
48
+ - nosniff
49
+ X-Contentful-Request-Id:
50
+ - e5083424335e7ca4ebfead1b0fb34a1e
51
+ Content-Length:
52
+ - '508'
53
+ Accept-Ranges:
54
+ - bytes
55
+ Date:
56
+ - Wed, 05 Apr 2017 15:49:25 GMT
57
+ Via:
58
+ - 1.1 varnish
59
+ Age:
60
+ - '0'
61
+ Connection:
62
+ - close
63
+ X-Served-By:
64
+ - cache-lax8637-LAX
65
+ X-Cache:
66
+ - MISS
67
+ X-Cache-Hits:
68
+ - '0'
69
+ X-Timer:
70
+ - S1491407366.696669,VS0,VE230
71
+ Vary:
72
+ - Accept-Encoding
73
+ body:
74
+ encoding: ASCII-8BIT
75
+ string: !binary |-
76
+ H4sIAAAAAAAAA61UTY/aMBC98yuQry3EzhcJN6RuK7XVXmBVdasKOc6EdclX
77
+ Y4NKV/z32k6yMSwrLav6Eo89njfz3kweR+MxEgeB5uNHtVWGPNSgLLRoGnpA
78
+ 6uz4XvvIStJcnRNjiS2vlYGNkfOCS32FW5tLKHTAHyZgG/YMxSCJmjIN1Xu0
79
+ h1Yu+sAc9jl95eUWacxhKfRyu+pyXpqIZw481eUkD5J4tPiFsz3VVfXr+LQ3
80
+ dbYLtW+In9x//rJqwkVFPx1g42+/82+/rfgDWUKAtC9YA1RCutC8IBeTcELw
81
+ BAcr4s89MvfCKY7ce/vBrk6ve9DAngtelZr4LvGnClDGIU8HUXVVSHKZP6Mb
82
+ ysndUud4czteGQebPQQ6BrpZdncXuUpBsIbXss3lREw7+gfL7TKG7XERKeMv
83
+ F2DjqmJ3jW5W5DhUKyOmrCollDLb5WpbOHY3OJdldoiXYZyk2SxgxHMxDgkD
84
+ f0aoF0UEIo84H3O6WVfZWj7A+q5UXZ+ul1KJKKZivznvwhQk5fmpJF2zCf5X
85
+ 6xLF8UlnW/1o9NPV39LCDOdV0F3t/ZDwgm7AUSm++1PkJ6PwXJb/z2oQYMLi
86
+ iLlxSLPZLIkpSyghfgjUA5cMrKpZ5uXbmAyxGwRXc/ki4Kv5G5q2H0jz1b+Y
87
+ n6Pj6B/AhXSYbAUAAA==
88
+ http_version:
89
+ recorded_at: Wed, 05 Apr 2017 15:49:25 GMT
90
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,198 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/zui87wsu8q80/content_types?limit=1000
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulGem/2.0.0
12
+ Authorization:
13
+ - Bearer 64ff902c58cd14ea063d3ded810d1111a0266537e9aba283bad3319b1762c302
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/"b8403cd0f2664e6663a4ed099c5a0ad1"
45
+ Server:
46
+ - Contentful
47
+ X-Content-Type-Options:
48
+ - nosniff
49
+ X-Contentful-Request-Id:
50
+ - b2a122d2f0e4f510fd5b77d0f6e213f5
51
+ Content-Length:
52
+ - '371'
53
+ Accept-Ranges:
54
+ - bytes
55
+ Date:
56
+ - Wed, 05 Apr 2017 15:22:28 GMT
57
+ Via:
58
+ - 1.1 varnish
59
+ Age:
60
+ - '0'
61
+ Connection:
62
+ - close
63
+ X-Served-By:
64
+ - cache-lax8637-LAX
65
+ X-Cache:
66
+ - MISS
67
+ X-Cache-Hits:
68
+ - '0'
69
+ X-Timer:
70
+ - S1491405748.191815,VS0,VE196
71
+ Vary:
72
+ - Accept-Encoding
73
+ body:
74
+ encoding: ASCII-8BIT
75
+ string: !binary |-
76
+ H4sIAAAAAAAAA71SsW7CMBDd+QrkuVQOKgWxoVaVKlVdytSKwSRHdcJxgu20
77
+ Coh/r8/GIURhYKkVKb47+91773wYDIfM1IbNhwe3dYGtS3ARW2gtauZyxzs6
78
+ YwsrpMsnPjJbLF3AfSAxR0slzkMCLeSE+OURA26njW9lSpFSr3giJFtkKOGT
79
+ kdQbqi2jpufl2qvt8kT6wyN2DmBGevYVzqa/pprtZpxkxXVs9l5oWCzcsWBs
80
+ C62h8VQoC8r6rq1LqQZhIVuQGWzMk+mIP4z4ZJlM5u7jyf2YP362L1RldtsF
81
+ DT9osFDk9olsw5plaEop6hcESYpVJWUkx5TI/VSXbUUsA5NqLG1AZA01tiGM
82
+ 8wjJlIshBXvQufAN+sLvptNrXzHOsbcoi1RI3AOR3whpoD1HpmFXob5SdNLF
83
+ Wl4pFu55urFE1L5594jLIMXcPfkLEtHG575iFPde5euuK/+u7aRy5f/0xleD
84
+ 4+APz7KeV+4DAAA=
85
+ http_version:
86
+ recorded_at: Wed, 05 Apr 2017 15:22:28 GMT
87
+ - request:
88
+ method: get
89
+ uri: https://cdn.contentful.com/spaces/zui87wsu8q80/entries
90
+ body:
91
+ encoding: US-ASCII
92
+ string: ''
93
+ headers:
94
+ User-Agent:
95
+ - RubyContentfulGem/2.0.0
96
+ Authorization:
97
+ - Bearer 64ff902c58cd14ea063d3ded810d1111a0266537e9aba283bad3319b1762c302
98
+ Content-Type:
99
+ - application/vnd.contentful.delivery.v1+json
100
+ Accept-Encoding:
101
+ - gzip
102
+ Connection:
103
+ - close
104
+ Host:
105
+ - cdn.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,X-Contentful-User-Agent
113
+ Access-Control-Allow-Methods:
114
+ - GET,HEAD,OPTIONS
115
+ Access-Control-Allow-Origin:
116
+ - "*"
117
+ Access-Control-Expose-Headers:
118
+ - Etag
119
+ Access-Control-Max-Age:
120
+ - '86400'
121
+ Cache-Control:
122
+ - max-age=0
123
+ Content-Type:
124
+ - application/vnd.contentful.delivery.v1+json
125
+ Etag:
126
+ - '"8a73a5579355b16a76b6c6827be4cb40"'
127
+ Server:
128
+ - Contentful
129
+ X-Content-Type-Options:
130
+ - nosniff
131
+ X-Contentful-Request-Id:
132
+ - 8c83e246e7803d22fb0a7f97f684952b
133
+ Content-Length:
134
+ - '735'
135
+ Accept-Ranges:
136
+ - bytes
137
+ Date:
138
+ - Wed, 05 Apr 2017 15:22:29 GMT
139
+ Via:
140
+ - 1.1 varnish
141
+ Age:
142
+ - '315'
143
+ Connection:
144
+ - close
145
+ X-Served-By:
146
+ - cache-lax8649-LAX
147
+ X-Cache:
148
+ - HIT
149
+ X-Cache-Hits:
150
+ - '1'
151
+ X-Timer:
152
+ - S1491405749.281463,VS0,VE0
153
+ Vary:
154
+ - Accept-Encoding
155
+ body:
156
+ encoding: ASCII-8BIT
157
+ string: |
158
+ {
159
+ "sys": {
160
+ "type": "Array"
161
+ },
162
+ "total": 1,
163
+ "skip": 0,
164
+ "limit": 100,
165
+ "items": [
166
+ {
167
+ "sys": {
168
+ "space": {
169
+ "sys": {
170
+ "type": "Link",
171
+ "linkType": "Space",
172
+ "id": "zui87wsu8q80"
173
+ }
174
+ },
175
+ "id": "dzNHzcQaVGwgouGswEoSm",
176
+ "type": "Entry",
177
+ "createdAt": "2017-04-05T15:15:27.632Z",
178
+ "updatedAt": "2017-04-05T15:15:27.632Z",
179
+ "revision": 1,
180
+ "contentType": {
181
+ "sys": {
182
+ "type": "Link",
183
+ "linkType": "ContentType",
184
+ "id": "test"
185
+ }
186
+ },
187
+ "locale": "en-US"
188
+ },
189
+ "fields": {
190
+ "integer": 123,
191
+ "decimal": 12.3
192
+ }
193
+ }
194
+ ]
195
+ }
196
+ http_version:
197
+ recorded_at: Wed, 05 Apr 2017 15:22:29 GMT
198
+ 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: 2.0.0
4
+ version: 2.0.1
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: 2017-03-21 00:00:00.000000000 Z
13
+ date: 2017-04-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http
@@ -432,10 +432,12 @@ files:
432
432
  - spec/fixtures/vcr_cassettes/asset/select_no_sys.yml
433
433
  - spec/fixtures/vcr_cassettes/asset/select_one_field.yml
434
434
  - spec/fixtures/vcr_cassettes/asset/select_only_sys.yml
435
+ - spec/fixtures/vcr_cassettes/assets/issues_129.yml
435
436
  - spec/fixtures/vcr_cassettes/bad_request.yml
436
437
  - spec/fixtures/vcr_cassettes/content_type.yml
437
438
  - spec/fixtures/vcr_cassettes/entries.yml
438
439
  - spec/fixtures/vcr_cassettes/entries/issue_117.yml
440
+ - spec/fixtures/vcr_cassettes/entries/issue_125.yml
439
441
  - spec/fixtures/vcr_cassettes/entry.yml
440
442
  - spec/fixtures/vcr_cassettes/entry/custom_resource.yml
441
443
  - spec/fixtures/vcr_cassettes/entry/include_resolution.yml
@@ -538,10 +540,12 @@ test_files:
538
540
  - spec/fixtures/vcr_cassettes/asset/select_no_sys.yml
539
541
  - spec/fixtures/vcr_cassettes/asset/select_one_field.yml
540
542
  - spec/fixtures/vcr_cassettes/asset/select_only_sys.yml
543
+ - spec/fixtures/vcr_cassettes/assets/issues_129.yml
541
544
  - spec/fixtures/vcr_cassettes/bad_request.yml
542
545
  - spec/fixtures/vcr_cassettes/content_type.yml
543
546
  - spec/fixtures/vcr_cassettes/entries.yml
544
547
  - spec/fixtures/vcr_cassettes/entries/issue_117.yml
548
+ - spec/fixtures/vcr_cassettes/entries/issue_125.yml
545
549
  - spec/fixtures/vcr_cassettes/entry.yml
546
550
  - spec/fixtures/vcr_cassettes/entry/custom_resource.yml
547
551
  - spec/fixtures/vcr_cassettes/entry/include_resolution.yml