contentful 0.1.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.
Files changed (133) hide show
  1. data/.README.md.swp +0 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +10 -0
  5. data/ChangeLog.md +3 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +193 -0
  9. data/Rakefile +30 -0
  10. data/contentful.gemspec +31 -0
  11. data/do_request.sh +5 -0
  12. data/doc/Contentful.html +131 -0
  13. data/doc/Contentful/AccessDenied.html +158 -0
  14. data/doc/Contentful/Array.html +346 -0
  15. data/doc/Contentful/Asset.html +315 -0
  16. data/doc/Contentful/BadRequest.html +158 -0
  17. data/doc/Contentful/Client.html +1407 -0
  18. data/doc/Contentful/ContentType.html +183 -0
  19. data/doc/Contentful/DynamicEntry.html +333 -0
  20. data/doc/Contentful/Entry.html +198 -0
  21. data/doc/Contentful/Error.html +413 -0
  22. data/doc/Contentful/Field.html +161 -0
  23. data/doc/Contentful/File.html +160 -0
  24. data/doc/Contentful/Link.html +275 -0
  25. data/doc/Contentful/Locale.html +161 -0
  26. data/doc/Contentful/NotFound.html +158 -0
  27. data/doc/Contentful/Request.html +669 -0
  28. data/doc/Contentful/Resource.html +606 -0
  29. data/doc/Contentful/Resource/AssetFields.html +413 -0
  30. data/doc/Contentful/Resource/AssetFields/ClassMethods.html +174 -0
  31. data/doc/Contentful/Resource/ClassMethods.html +271 -0
  32. data/doc/Contentful/Resource/Fields.html +398 -0
  33. data/doc/Contentful/Resource/Fields/ClassMethods.html +187 -0
  34. data/doc/Contentful/Resource/SystemProperties.html +444 -0
  35. data/doc/Contentful/Resource/SystemProperties/ClassMethods.html +174 -0
  36. data/doc/Contentful/ResourceBuilder.html +1400 -0
  37. data/doc/Contentful/Response.html +546 -0
  38. data/doc/Contentful/ServerError.html +158 -0
  39. data/doc/Contentful/Space.html +183 -0
  40. data/doc/Contentful/Support.html +198 -0
  41. data/doc/Contentful/Unauthorized.html +158 -0
  42. data/doc/Contentful/UnparsableJson.html +158 -0
  43. data/doc/Contentful/UnparsableResource.html +158 -0
  44. data/doc/_index.html +410 -0
  45. data/doc/class_list.html +54 -0
  46. data/doc/css/common.css +1 -0
  47. data/doc/css/full_list.css +57 -0
  48. data/doc/css/style.css +338 -0
  49. data/doc/file.README.html +214 -0
  50. data/doc/file_list.html +56 -0
  51. data/doc/frames.html +26 -0
  52. data/doc/index.html +214 -0
  53. data/doc/js/app.js +219 -0
  54. data/doc/js/full_list.js +178 -0
  55. data/doc/js/jquery.js +4 -0
  56. data/doc/method_list.html +533 -0
  57. data/doc/top-level-namespace.html +112 -0
  58. data/examples/custom_classes.rb +43 -0
  59. data/examples/dynamic_entries.rb +126 -0
  60. data/examples/example_queries.rb +27 -0
  61. data/examples/raise_errors.rb +22 -0
  62. data/examples/raw_mode.rb +15 -0
  63. data/examples/resource_mapping.rb +33 -0
  64. data/lib/contentful.rb +3 -0
  65. data/lib/contentful/array.rb +47 -0
  66. data/lib/contentful/asset.rb +34 -0
  67. data/lib/contentful/client.rb +193 -0
  68. data/lib/contentful/content_type.rb +16 -0
  69. data/lib/contentful/dynamic_entry.rb +54 -0
  70. data/lib/contentful/entry.rb +12 -0
  71. data/lib/contentful/error.rb +52 -0
  72. data/lib/contentful/field.rb +16 -0
  73. data/lib/contentful/file.rb +13 -0
  74. data/lib/contentful/link.rb +20 -0
  75. data/lib/contentful/locale.rb +12 -0
  76. data/lib/contentful/location.rb +12 -0
  77. data/lib/contentful/request.rb +37 -0
  78. data/lib/contentful/resource.rb +146 -0
  79. data/lib/contentful/resource/asset_fields.rb +50 -0
  80. data/lib/contentful/resource/fields.rb +39 -0
  81. data/lib/contentful/resource/system_properties.rb +48 -0
  82. data/lib/contentful/resource_builder.rb +197 -0
  83. data/lib/contentful/response.rb +64 -0
  84. data/lib/contentful/space.rb +14 -0
  85. data/lib/contentful/support.rb +18 -0
  86. data/lib/contentful/version.rb +3 -0
  87. data/spec/array_spec.rb +69 -0
  88. data/spec/asset_spec.rb +62 -0
  89. data/spec/auto_includes_spec.rb +12 -0
  90. data/spec/client_class_spec.rb +59 -0
  91. data/spec/client_configuration_spec.rb +197 -0
  92. data/spec/coercions_spec.rb +10 -0
  93. data/spec/content_type_spec.rb +44 -0
  94. data/spec/dynamic_entry_spec.rb +34 -0
  95. data/spec/entry_spec.rb +53 -0
  96. data/spec/error_class_spec.rb +60 -0
  97. data/spec/error_requests_spec.rb +32 -0
  98. data/spec/field_spec.rb +36 -0
  99. data/spec/file_spec.rb +28 -0
  100. data/spec/fixtures/json_responses/content_type.json +83 -0
  101. data/spec/fixtures/json_responses/not_found.json +13 -0
  102. data/spec/fixtures/json_responses/nyancat.json +48 -0
  103. data/spec/fixtures/json_responses/unparsable.json +13 -0
  104. data/spec/fixtures/vcr_cassettes/array.yml +288 -0
  105. data/spec/fixtures/vcr_cassettes/array_page_1.yml +106 -0
  106. data/spec/fixtures/vcr_cassettes/array_page_2.yml +73 -0
  107. data/spec/fixtures/vcr_cassettes/asset.yml +96 -0
  108. data/spec/fixtures/vcr_cassettes/bad_request.yml +76 -0
  109. data/spec/fixtures/vcr_cassettes/content_type.yml +147 -0
  110. data/spec/fixtures/vcr_cassettes/entries.yml +561 -0
  111. data/spec/fixtures/vcr_cassettes/entry.yml +112 -0
  112. data/spec/fixtures/vcr_cassettes/entry_cache.yml +288 -0
  113. data/spec/fixtures/vcr_cassettes/field.yml +147 -0
  114. data/spec/fixtures/vcr_cassettes/locale.yml +81 -0
  115. data/spec/fixtures/vcr_cassettes/location.yml +305 -0
  116. data/spec/fixtures/vcr_cassettes/not_found.yml +71 -0
  117. data/spec/fixtures/vcr_cassettes/nyancat.yml +112 -0
  118. data/spec/fixtures/vcr_cassettes/nyancat_include.yml +112 -0
  119. data/spec/fixtures/vcr_cassettes/reloaded_entry.yml +112 -0
  120. data/spec/fixtures/vcr_cassettes/space.yml +81 -0
  121. data/spec/fixtures/vcr_cassettes/unauthorized.yml +64 -0
  122. data/spec/link_spec.rb +40 -0
  123. data/spec/locale_spec.rb +20 -0
  124. data/spec/location_spec.rb +30 -0
  125. data/spec/request_spec.rb +48 -0
  126. data/spec/resource_spec.rb +52 -0
  127. data/spec/response_spec.rb +50 -0
  128. data/spec/space_spec.rb +36 -0
  129. data/spec/spec_helper.rb +6 -0
  130. data/spec/support/client.rb +6 -0
  131. data/spec/support/json_responses.rb +11 -0
  132. data/spec/support/vcr.rb +16 -0
  133. metadata +374 -0
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulGem/0.1.0
12
+ Authorization:
13
+ - Bearer b4c0n73n7fu1
14
+ Content-Type:
15
+ - application/vnd.contentful.delivery.v1+json
16
+ Host:
17
+ - cdn.contentful.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Wed, 05 Mar 2014 21:15:55 GMT
25
+ Server:
26
+ - nginx/1.1.19
27
+ Content-Type:
28
+ - application/vnd.contentful.delivery.v1+json
29
+ X-Contentful-Request-Id:
30
+ - 85f-830831773
31
+ Etag:
32
+ - "\"23e4b3361b063c545fdd9f7f4f97d825\""
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Allow-Headers:
36
+ - 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
37
+ Access-Control-Allow-Methods:
38
+ - GET,HEAD,OPTIONS
39
+ Access-Control-Max-Age:
40
+ - '86400'
41
+ Cache-Control:
42
+ - max-age=0
43
+ Content-Length:
44
+ - '238'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Via:
48
+ - 1.1 varnish
49
+ Age:
50
+ - '0'
51
+ X-Served-By:
52
+ - cache-fra1234-FRA
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ Vary:
58
+ - Accept-Encoding
59
+ body:
60
+ encoding: UTF-8
61
+ string: |
62
+ {
63
+ "sys": {
64
+ "type": "Space",
65
+ "id": "cfexampleapi"
66
+ },
67
+ "name": "Contentful Example API",
68
+ "locales": [
69
+ {
70
+ "code": "en-US",
71
+ "name": "English"
72
+ },
73
+ {
74
+ "code": "tlh",
75
+ "name": "Klingon"
76
+ }
77
+ ]
78
+ }
79
+ http_version:
80
+ recorded_at: Wed, 05 Mar 2014 21:15:56 GMT
81
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,305 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/lzjz8hygvfgu/content_types?limit=0
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulGem/0.1.0
12
+ Authorization:
13
+ - Bearer 0c6ef483524b5e46b3bafda1bf355f38f5f40b4830f7599f790a410860c7c271
14
+ Content-Type:
15
+ - application/vnd.contentful.delivery.v1+json
16
+ Host:
17
+ - cdn.contentful.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 13 Mar 2014 23:02:29 GMT
25
+ Server:
26
+ - nginx/1.1.19
27
+ Content-Type:
28
+ - application/vnd.contentful.delivery.v1+json
29
+ X-Contentful-Request-Id:
30
+ - 85f-830985851
31
+ Etag:
32
+ - "\"827a075bbc0b6dab95b230a0505294e3\""
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Allow-Headers:
36
+ - 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
37
+ Access-Control-Allow-Methods:
38
+ - GET,HEAD,OPTIONS
39
+ Access-Control-Max-Age:
40
+ - '86400'
41
+ Cache-Control:
42
+ - max-age=0
43
+ Content-Length:
44
+ - '3060'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Via:
48
+ - 1.1 varnish
49
+ Age:
50
+ - '0'
51
+ X-Served-By:
52
+ - cache-fra1222-FRA
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ Vary:
58
+ - Accept-Encoding
59
+ body:
60
+ encoding: UTF-8
61
+ string: |
62
+ {
63
+ "sys": {
64
+ "type": "Array"
65
+ },
66
+ "total": 2,
67
+ "skip": 0,
68
+ "limit": 0,
69
+ "items": [
70
+ {
71
+ "fields": [
72
+ {
73
+ "id": "name",
74
+ "name": "Name",
75
+ "type": "Symbol",
76
+ "required": true,
77
+ "localized": false
78
+ },
79
+ {
80
+ "id": "description",
81
+ "name": "Description",
82
+ "type": "Text",
83
+ "required": true,
84
+ "localized": false
85
+ }
86
+ ],
87
+ "name": "Alien species",
88
+ "displayField": "name",
89
+ "sys": {
90
+ "space": {
91
+ "sys": {
92
+ "type": "Link",
93
+ "linkType": "Space",
94
+ "id": "lzjz8hygvfgu"
95
+ }
96
+ },
97
+ "type": "ContentType",
98
+ "id": "110tmd3lykUqww2WYOQOYy",
99
+ "revision": 1,
100
+ "createdAt": "2013-06-20T14:49:44.002Z",
101
+ "updatedAt": "2013-06-20T14:49:44.002Z"
102
+ }
103
+ },
104
+ {
105
+ "fields": [
106
+ {
107
+ "id": "locationName",
108
+ "name": "Location name",
109
+ "type": "Text",
110
+ "required": true,
111
+ "localized": false
112
+ },
113
+ {
114
+ "id": "species",
115
+ "name": "Species",
116
+ "type": "Link",
117
+ "required": true,
118
+ "localized": false,
119
+ "disabled": false,
120
+ "linkType": "Entry"
121
+ },
122
+ {
123
+ "id": "location",
124
+ "name": "location",
125
+ "type": "Location",
126
+ "required": true,
127
+ "localized": false
128
+ },
129
+ {
130
+ "id": "description",
131
+ "name": "Description",
132
+ "type": "Text",
133
+ "required": true,
134
+ "localized": false
135
+ },
136
+ {
137
+ "id": "shape",
138
+ "name": "Shape",
139
+ "type": "Symbol",
140
+ "required": false,
141
+ "localized": false
142
+ },
143
+ {
144
+ "id": "reportedAt",
145
+ "name": "Reported at",
146
+ "type": "Date",
147
+ "required": true,
148
+ "localized": false
149
+ },
150
+ {
151
+ "id": "sightedAt",
152
+ "name": "Sighted at",
153
+ "type": "Date",
154
+ "required": true,
155
+ "localized": false
156
+ },
157
+ {
158
+ "id": "city",
159
+ "name": "City",
160
+ "type": "Symbol",
161
+ "required": false,
162
+ "localized": false
163
+ },
164
+ {
165
+ "id": "state",
166
+ "name": "State",
167
+ "type": "Symbol",
168
+ "required": false,
169
+ "localized": false
170
+ },
171
+ {
172
+ "id": "country",
173
+ "name": "Country",
174
+ "type": "Symbol",
175
+ "required": false,
176
+ "localized": false
177
+ }
178
+ ],
179
+ "name": "Ufo sighting",
180
+ "displayField": "locationName",
181
+ "sys": {
182
+ "space": {
183
+ "sys": {
184
+ "type": "Link",
185
+ "linkType": "Space",
186
+ "id": "lzjz8hygvfgu"
187
+ }
188
+ },
189
+ "type": "ContentType",
190
+ "id": "7ocuA1dfoccWqWwWUY4UY",
191
+ "revision": 3,
192
+ "createdAt": "2013-06-20T14:49:49.380Z",
193
+ "updatedAt": "2013-06-29T10:26:12.757Z"
194
+ }
195
+ }
196
+ ]
197
+ }
198
+ http_version:
199
+ recorded_at: Thu, 13 Mar 2014 23:02:29 GMT
200
+ - request:
201
+ method: get
202
+ uri: https://cdn.contentful.com/spaces/lzjz8hygvfgu/entries/3f6fq5ylFCi4kIYAQKsAYG
203
+ body:
204
+ encoding: US-ASCII
205
+ string: ''
206
+ headers:
207
+ User-Agent:
208
+ - RubyContentfulGem/0.1.0
209
+ Authorization:
210
+ - Bearer 0c6ef483524b5e46b3bafda1bf355f38f5f40b4830f7599f790a410860c7c271
211
+ Content-Type:
212
+ - application/vnd.contentful.delivery.v1+json
213
+ Host:
214
+ - cdn.contentful.com
215
+ response:
216
+ status:
217
+ code: 200
218
+ message: OK
219
+ headers:
220
+ Date:
221
+ - Thu, 13 Mar 2014 23:02:29 GMT
222
+ Server:
223
+ - nginx/1.1.19
224
+ Content-Type:
225
+ - application/vnd.contentful.delivery.v1+json
226
+ X-Contentful-Request-Id:
227
+ - 85f-830971238
228
+ Etag:
229
+ - "\"b40b427efac4e47710aa8124ef667f1b\""
230
+ Access-Control-Allow-Origin:
231
+ - "*"
232
+ Access-Control-Allow-Headers:
233
+ - 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
234
+ Access-Control-Allow-Methods:
235
+ - GET,HEAD,OPTIONS
236
+ Access-Control-Max-Age:
237
+ - '86400'
238
+ Cache-Control:
239
+ - max-age=0
240
+ Content-Length:
241
+ - '1464'
242
+ Accept-Ranges:
243
+ - bytes
244
+ Via:
245
+ - 1.1 varnish
246
+ Age:
247
+ - '84840'
248
+ X-Served-By:
249
+ - cache-fra1220-FRA
250
+ X-Cache:
251
+ - MISS
252
+ X-Cache-Hits:
253
+ - '0'
254
+ Vary:
255
+ - Accept-Encoding
256
+ body:
257
+ encoding: UTF-8
258
+ string: |
259
+ {
260
+ "fields": {
261
+ "description": "Caller had left a message at 1355 hrs. on 18JA96. The caller reported that she and her husband had witnessed two beams of light to the northeast of their home that appeared to go straight up into the sky, perfectly parallel to one another. They appeared to originate from behind a hill to the northeast of their home, and the beams were definitely separated from each other. They were looking toward Beaver Lake. the University at Springdale is to the north. They called the local newspapers and the local airport(s).",
262
+ "locationName": "Fayetteville, AR",
263
+ "sightedAt": "1996-01-17T23:00:00Z",
264
+ "reportedAt": "1996-01-17T23:00:00Z",
265
+ "city": "Fayetteville",
266
+ "state": "Arkansas",
267
+ "country": "United States",
268
+ "location": {
269
+ "lat": 36.0625795,
270
+ "lon": -94.1574263
271
+ },
272
+ "species": {
273
+ "sys": {
274
+ "type": "Link",
275
+ "linkType": "Entry",
276
+ "id": "5iBjcBn6eWskwS0GAOAsCA"
277
+ }
278
+ }
279
+ },
280
+ "sys": {
281
+ "space": {
282
+ "sys": {
283
+ "type": "Link",
284
+ "linkType": "Space",
285
+ "id": "lzjz8hygvfgu"
286
+ }
287
+ },
288
+ "type": "Entry",
289
+ "contentType": {
290
+ "sys": {
291
+ "type": "Link",
292
+ "linkType": "ContentType",
293
+ "id": "7ocuA1dfoccWqWwWUY4UY"
294
+ }
295
+ },
296
+ "id": "3f6fq5ylFCi4kIYAQKsAYG",
297
+ "revision": 1,
298
+ "createdAt": "2013-06-27T14:38:44.504Z",
299
+ "updatedAt": "2013-06-27T14:38:44.504Z",
300
+ "locale": "en-US"
301
+ }
302
+ }
303
+ http_version:
304
+ recorded_at: Thu, 13 Mar 2014 23:02:29 GMT
305
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/entries/not%20found
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulGem/0.1.0
12
+ Authorization:
13
+ - Bearer b4c0n73n7fu1
14
+ Content-Type:
15
+ - application/vnd.contentful.delivery.v1+json
16
+ Host:
17
+ - cdn.contentful.com
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: Not Found
22
+ headers:
23
+ Date:
24
+ - Wed, 05 Mar 2014 21:16:39 GMT
25
+ Server:
26
+ - nginx/1.1.19
27
+ Content-Type:
28
+ - application/vnd.contentful.delivery.v1+json
29
+ Access-Control-Allow-Origin:
30
+ - "*"
31
+ Access-Control-Allow-Headers:
32
+ - 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
33
+ Access-Control-Allow-Methods:
34
+ - GET,HEAD,OPTIONS
35
+ Access-Control-Max-Age:
36
+ - '86400'
37
+ Cache-Control:
38
+ - max-age=0
39
+ Content-Length:
40
+ - '234'
41
+ Accept-Ranges:
42
+ - bytes
43
+ Via:
44
+ - 1.1 varnish
45
+ Age:
46
+ - '0'
47
+ X-Served-By:
48
+ - cache-fra1235-FRA
49
+ X-Cache:
50
+ - MISS
51
+ X-Cache-Hits:
52
+ - '0'
53
+ body:
54
+ encoding: UTF-8
55
+ string: |
56
+ {
57
+ "sys": {
58
+ "type": "Error",
59
+ "id": "NotFound"
60
+ },
61
+ "details": {
62
+ "type": "Entry",
63
+ "space": "cfexampleapi",
64
+ "id": "not found"
65
+ },
66
+ "message": "The resource could not be found.",
67
+ "requestId": "85f-830831809"
68
+ }
69
+ http_version:
70
+ recorded_at: Wed, 05 Mar 2014 21:16:39 GMT
71
+ recorded_with: VCR 2.8.0