contentful 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,13 @@
1
+ {
2
+ "sys": {
3
+ "type": "Error",
4
+ "id": "NotFound"
5
+ },
6
+ "details": {
7
+ "type": "Entry",
8
+ "space": "cfexampleapi",
9
+ "id": "not found"
10
+ },
11
+ "message": "The resource could not be found.",
12
+ "requestId": "85f-351076632",
13
+ "missing": "braceright"
@@ -0,0 +1,288 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types
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:53 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-830831768
31
+ Etag:
32
+ - "\"8d1249fb102065e5e5080d2871e0d05e\""
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
+ - '4975'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Via:
48
+ - 1.1 varnish
49
+ Age:
50
+ - '0'
51
+ X-Served-By:
52
+ - cache-fra1221-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": 4,
67
+ "skip": 0,
68
+ "limit": 100,
69
+ "items": [
70
+ {
71
+ "fields": [
72
+ {
73
+ "id": "name",
74
+ "name": "Name",
75
+ "type": "Text",
76
+ "required": true,
77
+ "localized": true
78
+ },
79
+ {
80
+ "id": "likes",
81
+ "name": "Likes",
82
+ "type": "Array",
83
+ "required": false,
84
+ "localized": false,
85
+ "items": {
86
+ "type": "Symbol"
87
+ }
88
+ },
89
+ {
90
+ "id": "color",
91
+ "name": "Color",
92
+ "type": "Symbol",
93
+ "required": false,
94
+ "localized": false
95
+ },
96
+ {
97
+ "id": "bestFriend",
98
+ "name": "Best Friend",
99
+ "type": "Link",
100
+ "required": false,
101
+ "localized": false,
102
+ "linkType": "Entry"
103
+ },
104
+ {
105
+ "id": "birthday",
106
+ "name": "Birthday",
107
+ "type": "Date",
108
+ "required": false,
109
+ "localized": false
110
+ },
111
+ {
112
+ "id": "lifes",
113
+ "name": "Lifes left",
114
+ "type": "Integer",
115
+ "required": false,
116
+ "localized": false,
117
+ "disabled": true
118
+ },
119
+ {
120
+ "id": "lives",
121
+ "name": "Lives left",
122
+ "type": "Integer",
123
+ "required": false,
124
+ "localized": false
125
+ },
126
+ {
127
+ "id": "image",
128
+ "name": "Image",
129
+ "required": false,
130
+ "localized": false,
131
+ "type": "Link",
132
+ "linkType": "Asset"
133
+ }
134
+ ],
135
+ "name": "Cat",
136
+ "displayField": "name",
137
+ "description": "Meow.",
138
+ "sys": {
139
+ "space": {
140
+ "sys": {
141
+ "type": "Link",
142
+ "linkType": "Space",
143
+ "id": "cfexampleapi"
144
+ }
145
+ },
146
+ "type": "ContentType",
147
+ "id": "cat",
148
+ "revision": 2,
149
+ "createdAt": "2013-06-27T22:46:12.852Z",
150
+ "updatedAt": "2013-09-02T13:14:47.863Z"
151
+ }
152
+ },
153
+ {
154
+ "fields": [
155
+ {
156
+ "id": "name",
157
+ "name": "Name",
158
+ "type": "Text",
159
+ "required": true,
160
+ "localized": false
161
+ },
162
+ {
163
+ "id": "description",
164
+ "name": "Description",
165
+ "type": "Text",
166
+ "required": false,
167
+ "localized": false
168
+ },
169
+ {
170
+ "id": "image",
171
+ "name": "Image",
172
+ "required": false,
173
+ "localized": false,
174
+ "type": "Link",
175
+ "linkType": "Asset"
176
+ }
177
+ ],
178
+ "name": "Dog",
179
+ "description": "Bark!",
180
+ "displayField": "name",
181
+ "sys": {
182
+ "space": {
183
+ "sys": {
184
+ "type": "Link",
185
+ "linkType": "Space",
186
+ "id": "cfexampleapi"
187
+ }
188
+ },
189
+ "type": "ContentType",
190
+ "id": "dog",
191
+ "revision": 2,
192
+ "createdAt": "2013-06-27T22:46:13.498Z",
193
+ "updatedAt": "2013-09-02T14:32:11.837Z"
194
+ }
195
+ },
196
+ {
197
+ "fields": [
198
+ {
199
+ "id": "name",
200
+ "name": "Name",
201
+ "type": "Text",
202
+ "required": true,
203
+ "localized": false
204
+ },
205
+ {
206
+ "id": "description",
207
+ "name": "Description",
208
+ "type": "Text",
209
+ "required": false,
210
+ "localized": false
211
+ },
212
+ {
213
+ "id": "likes",
214
+ "name": "Likes",
215
+ "type": "Array",
216
+ "required": false,
217
+ "localized": false,
218
+ "items": {
219
+ "type": "Symbol"
220
+ }
221
+ },
222
+ {
223
+ "id": "image",
224
+ "name": "Image",
225
+ "required": false,
226
+ "localized": false,
227
+ "type": "Array",
228
+ "items": {
229
+ "type": "Link",
230
+ "linkType": "Asset"
231
+ },
232
+ "disabled": true
233
+ }
234
+ ],
235
+ "name": "Human",
236
+ "displayField": "name",
237
+ "sys": {
238
+ "space": {
239
+ "sys": {
240
+ "type": "Link",
241
+ "linkType": "Space",
242
+ "id": "cfexampleapi"
243
+ }
244
+ },
245
+ "type": "ContentType",
246
+ "id": "human",
247
+ "revision": 3,
248
+ "createdAt": "2013-06-27T22:46:14.133Z",
249
+ "updatedAt": "2013-09-02T15:10:26.818Z"
250
+ }
251
+ },
252
+ {
253
+ "fields": [
254
+ {
255
+ "name": "Name",
256
+ "id": "name",
257
+ "type": "Text",
258
+ "required": true
259
+ },
260
+ {
261
+ "name": "Center",
262
+ "id": "center",
263
+ "type": "Location",
264
+ "required": true
265
+ }
266
+ ],
267
+ "name": "City",
268
+ "sys": {
269
+ "space": {
270
+ "sys": {
271
+ "type": "Link",
272
+ "linkType": "Space",
273
+ "id": "cfexampleapi"
274
+ }
275
+ },
276
+ "type": "ContentType",
277
+ "id": "1t9IbcfdCk6m04uISSsaIK",
278
+ "revision": 1,
279
+ "createdAt": "2014-02-21T13:42:33.009Z",
280
+ "updatedAt": "2014-02-21T13:42:33.009Z"
281
+ },
282
+ "displayField": "name"
283
+ }
284
+ ]
285
+ }
286
+ http_version:
287
+ recorded_at: Wed, 05 Mar 2014 21:15:53 GMT
288
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,106 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=2&skip=3
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
+ - Thu, 13 Mar 2014 10:01:16 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-830975684
31
+ Etag:
32
+ - "\"098a04921c0747087815e148a98bcacf\""
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
+ - '813'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Via:
48
+ - 1.1 varnish
49
+ Age:
50
+ - '0'
51
+ X-Served-By:
52
+ - cache-am70-AMS
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": 4,
67
+ "skip": 3,
68
+ "limit": 2,
69
+ "items": [
70
+ {
71
+ "fields": [
72
+ {
73
+ "name": "Name",
74
+ "id": "name",
75
+ "type": "Text",
76
+ "required": true
77
+ },
78
+ {
79
+ "name": "Center",
80
+ "id": "center",
81
+ "type": "Location",
82
+ "required": true
83
+ }
84
+ ],
85
+ "name": "City",
86
+ "sys": {
87
+ "space": {
88
+ "sys": {
89
+ "type": "Link",
90
+ "linkType": "Space",
91
+ "id": "cfexampleapi"
92
+ }
93
+ },
94
+ "type": "ContentType",
95
+ "id": "1t9IbcfdCk6m04uISSsaIK",
96
+ "revision": 1,
97
+ "createdAt": "2014-02-21T13:42:33.009Z",
98
+ "updatedAt": "2014-02-21T13:42:33.009Z"
99
+ },
100
+ "displayField": "name"
101
+ }
102
+ ]
103
+ }
104
+ http_version:
105
+ recorded_at: Thu, 13 Mar 2014 10:01:16 GMT
106
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,73 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=2&skip=5
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
+ - Thu, 13 Mar 2014 10:14:58 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-830975822
31
+ Etag:
32
+ - "\"2746811e75b9a95dce07c642289df92a\""
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
+ - '95'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Via:
48
+ - 1.1 varnish
49
+ Age:
50
+ - '0'
51
+ X-Served-By:
52
+ - cache-am77-AMS
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": 4,
67
+ "skip": 5,
68
+ "limit": 2,
69
+ "items": []
70
+ }
71
+ http_version:
72
+ recorded_at: Thu, 13 Mar 2014 10:14:58 GMT
73
+ recorded_with: VCR 2.8.0