contentful_model 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/contentful_model.rb +17 -13
- data/lib/contentful_model/asset.rb +30 -0
- data/lib/contentful_model/asset_dimension_query.rb +70 -0
- data/lib/contentful_model/asset_dimensions.rb +54 -0
- data/lib/contentful_model/associations/associations.rb +10 -4
- data/lib/contentful_model/associations/belongs_to.rb +9 -4
- data/lib/contentful_model/associations/belongs_to_many.rb +22 -45
- data/lib/contentful_model/associations/has_many.rb +15 -13
- data/lib/contentful_model/associations/has_many_nested.rb +39 -37
- data/lib/contentful_model/associations/has_one.rb +22 -14
- data/lib/contentful_model/base.rb +115 -74
- data/lib/contentful_model/client.rb +14 -3
- data/lib/contentful_model/errors.rb +0 -1
- data/lib/contentful_model/manageable.rb +49 -21
- data/lib/contentful_model/management.rb +1 -0
- data/lib/contentful_model/migrations/content_type.rb +24 -24
- data/lib/contentful_model/migrations/content_type_factory.rb +9 -6
- data/lib/contentful_model/migrations/migration.rb +9 -4
- data/lib/contentful_model/queries.rb +60 -9
- data/lib/contentful_model/query.rb +148 -5
- data/lib/contentful_model/validations/lambda_validation.rb +17 -0
- data/lib/contentful_model/validations/validates_presence_of.rb +4 -1
- data/lib/contentful_model/validations/validations.rb +56 -8
- data/lib/contentful_model/version.rb +1 -1
- data/spec/asset_spec.rb +141 -0
- data/spec/associations/belongs_to_many_spec.rb +38 -0
- data/spec/associations/belongs_to_spec.rb +22 -0
- data/spec/associations/has_many_nested_spec.rb +321 -0
- data/spec/associations/has_many_spec.rb +33 -0
- data/spec/associations/has_one_spec.rb +32 -0
- data/spec/base_spec.rb +199 -0
- data/spec/chainable_queries_spec.rb +199 -0
- data/spec/client_spec.rb +11 -0
- data/spec/contentful_model_spec.rb +25 -0
- data/spec/fixtures/vcr_cassettes/asset/all.yml +161 -0
- data/spec/fixtures/vcr_cassettes/asset/find.yml +118 -0
- data/spec/fixtures/vcr_cassettes/association/belongs_to_many.yml +439 -0
- data/spec/fixtures/vcr_cassettes/association/has_many.yml +161 -0
- data/spec/fixtures/vcr_cassettes/association/has_one.yml +161 -0
- data/spec/fixtures/vcr_cassettes/association/nested_with_root_root.yml +240 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_child_higher_include.yml +123 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_child_parent.yml +609 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_childless.yml +688 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_middle.yml +319 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_middle_higher_include.yml +161 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_middle_parent.yml +489 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_parentless.yml +331 -0
- data/spec/fixtures/vcr_cassettes/association/nested_without_root_parentless_higher_include.yml +82 -0
- data/spec/fixtures/vcr_cassettes/associations/nested_without_root_middle.yml +161 -0
- data/spec/fixtures/vcr_cassettes/associations/nested_without_root_middle_higher_include.yml +82 -0
- data/spec/fixtures/vcr_cassettes/base/content_type.yml +185 -0
- data/spec/fixtures/vcr_cassettes/base/return_nil_for_empty.yml +202 -0
- data/spec/fixtures/vcr_cassettes/base/return_nil_for_empty_with_value.yml +124 -0
- data/spec/fixtures/vcr_cassettes/client.yml +98 -0
- data/spec/fixtures/vcr_cassettes/dog.yml +161 -0
- data/spec/fixtures/vcr_cassettes/human.yml +199 -0
- data/spec/fixtures/vcr_cassettes/management/client.yml +1362 -0
- data/spec/fixtures/vcr_cassettes/management/nyancat.yml +1449 -0
- data/spec/fixtures/vcr_cassettes/management/nyancat_2.yml +1449 -0
- data/spec/fixtures/vcr_cassettes/management/nyancat_publish.yml +481 -0
- data/spec/fixtures/vcr_cassettes/management/nyancat_refetch_and_fail.yml +558 -0
- data/spec/fixtures/vcr_cassettes/management/nyancat_refetch_and_save.yml +620 -0
- data/spec/fixtures/vcr_cassettes/management/nyancat_save.yml +479 -0
- data/spec/fixtures/vcr_cassettes/management/nyancat_save_2.yml +479 -0
- data/spec/fixtures/vcr_cassettes/nyancat.yml +196 -0
- data/spec/fixtures/vcr_cassettes/playground/nyancat.yml +177 -0
- data/spec/fixtures/vcr_cassettes/query/each_entry.yml +319 -0
- data/spec/fixtures/vcr_cassettes/query/each_page.yml +319 -0
- data/spec/fixtures/vcr_cassettes/query/empty.yml +180 -0
- data/spec/fixtures/vcr_cassettes/query/load.yml +197 -0
- data/spec/fixtures/vcr_cassettes/query/manual_pagination.yml +161 -0
- data/spec/fixtures/vcr_cassettes/query/nyancat_invalid_elements.yml +247 -0
- data/spec/manageable_spec.rb +186 -0
- data/spec/management_spec.rb +17 -0
- data/spec/migrations/content_type_factory_spec.rb +41 -0
- data/spec/migrations/content_type_spec.rb +176 -0
- data/spec/migrations/migration_spec.rb +75 -0
- data/spec/queries_spec.rb +85 -0
- data/spec/query_spec.rb +126 -0
- data/spec/spec_helper.rb +58 -0
- data/spec/validations/validations_spec.rb +182 -0
- metadata +213 -19
- data/lib/contentful_model/chainable_queries.rb +0 -104
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Contentful GmbH (David Litvak Bruno)
|
7
8
|
- Error Creative Studio
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2018-05-02 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: contentful
|
@@ -16,28 +17,28 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
+
version: '2.7'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
+
version: '2.7'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: contentful-management
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
+
version: '2.0'
|
34
35
|
type: :runtime
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
39
|
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
+
version: '2.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: redcarpet
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,13 +68,13 @@ dependencies:
|
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
+
name: vcr
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
74
|
- - ">="
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: '0'
|
76
|
-
type: :
|
77
|
+
type: :development
|
77
78
|
prerelease: false
|
78
79
|
version_requirements: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
@@ -81,7 +82,7 @@ dependencies:
|
|
81
82
|
- !ruby/object:Gem::Version
|
82
83
|
version: '0'
|
83
84
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
+
name: pry
|
85
86
|
requirement: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
88
|
- - ">="
|
@@ -96,6 +97,20 @@ dependencies:
|
|
96
97
|
version: '0'
|
97
98
|
- !ruby/object:Gem::Dependency
|
98
99
|
name: rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rake
|
99
114
|
requirement: !ruby/object:Gem::Requirement
|
100
115
|
requirements:
|
101
116
|
- - ">="
|
@@ -109,7 +124,7 @@ dependencies:
|
|
109
124
|
- !ruby/object:Gem::Version
|
110
125
|
version: '0'
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
127
|
+
name: guard
|
113
128
|
requirement: !ruby/object:Gem::Requirement
|
114
129
|
requirements:
|
115
130
|
- - ">="
|
@@ -123,7 +138,7 @@ dependencies:
|
|
123
138
|
- !ruby/object:Gem::Version
|
124
139
|
version: '0'
|
125
140
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: guard
|
141
|
+
name: guard-rspec
|
127
142
|
requirement: !ruby/object:Gem::Requirement
|
128
143
|
requirements:
|
129
144
|
- - ">="
|
@@ -137,7 +152,21 @@ dependencies:
|
|
137
152
|
- !ruby/object:Gem::Version
|
138
153
|
version: '0'
|
139
154
|
- !ruby/object:Gem::Dependency
|
140
|
-
name: guard-
|
155
|
+
name: guard-rubocop
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: guard-yard
|
141
170
|
requirement: !ruby/object:Gem::Requirement
|
142
171
|
requirements:
|
143
172
|
- - ">="
|
@@ -152,6 +181,40 @@ dependencies:
|
|
152
181
|
version: '0'
|
153
182
|
- !ruby/object:Gem::Dependency
|
154
183
|
name: webmock
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '1'
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: 1.17.3
|
192
|
+
type: :development
|
193
|
+
prerelease: false
|
194
|
+
version_requirements: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - "~>"
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '1'
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 1.17.3
|
202
|
+
- !ruby/object:Gem::Dependency
|
203
|
+
name: tins
|
204
|
+
requirement: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 1.6.0
|
209
|
+
type: :development
|
210
|
+
prerelease: false
|
211
|
+
version_requirements: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 1.6.0
|
216
|
+
- !ruby/object:Gem::Dependency
|
217
|
+
name: simplecov
|
155
218
|
requirement: !ruby/object:Gem::Requirement
|
156
219
|
requirements:
|
157
220
|
- - ">="
|
@@ -164,9 +227,23 @@ dependencies:
|
|
164
227
|
- - ">="
|
165
228
|
- !ruby/object:Gem::Version
|
166
229
|
version: '0'
|
167
|
-
|
168
|
-
|
230
|
+
- !ruby/object:Gem::Dependency
|
231
|
+
name: rubocop
|
232
|
+
requirement: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: 0.49.0
|
237
|
+
type: :development
|
238
|
+
prerelease: false
|
239
|
+
version_requirements: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: 0.49.0
|
244
|
+
description: An ActiveModel-like wrapper for the Contentful SDKs
|
169
245
|
email:
|
246
|
+
- david.litvak@contentful.com
|
170
247
|
- hosting@errorstudio.co.uk
|
171
248
|
executables: []
|
172
249
|
extensions: []
|
@@ -175,6 +252,9 @@ files:
|
|
175
252
|
- MIT-LICENSE
|
176
253
|
- Rakefile
|
177
254
|
- lib/contentful_model.rb
|
255
|
+
- lib/contentful_model/asset.rb
|
256
|
+
- lib/contentful_model/asset_dimension_query.rb
|
257
|
+
- lib/contentful_model/asset_dimensions.rb
|
178
258
|
- lib/contentful_model/associations/associations.rb
|
179
259
|
- lib/contentful_model/associations/belongs_to.rb
|
180
260
|
- lib/contentful_model/associations/belongs_to_many.rb
|
@@ -182,7 +262,6 @@ files:
|
|
182
262
|
- lib/contentful_model/associations/has_many_nested.rb
|
183
263
|
- lib/contentful_model/associations/has_one.rb
|
184
264
|
- lib/contentful_model/base.rb
|
185
|
-
- lib/contentful_model/chainable_queries.rb
|
186
265
|
- lib/contentful_model/client.rb
|
187
266
|
- lib/contentful_model/errors.rb
|
188
267
|
- lib/contentful_model/manageable.rb
|
@@ -193,11 +272,69 @@ files:
|
|
193
272
|
- lib/contentful_model/migrations/migration.rb
|
194
273
|
- lib/contentful_model/queries.rb
|
195
274
|
- lib/contentful_model/query.rb
|
275
|
+
- lib/contentful_model/validations/lambda_validation.rb
|
196
276
|
- lib/contentful_model/validations/validates_presence_of.rb
|
197
277
|
- lib/contentful_model/validations/validations.rb
|
198
278
|
- lib/contentful_model/version.rb
|
199
279
|
- lib/tasks/contentful_rails_tasks.rake
|
200
|
-
|
280
|
+
- spec/asset_spec.rb
|
281
|
+
- spec/associations/belongs_to_many_spec.rb
|
282
|
+
- spec/associations/belongs_to_spec.rb
|
283
|
+
- spec/associations/has_many_nested_spec.rb
|
284
|
+
- spec/associations/has_many_spec.rb
|
285
|
+
- spec/associations/has_one_spec.rb
|
286
|
+
- spec/base_spec.rb
|
287
|
+
- spec/chainable_queries_spec.rb
|
288
|
+
- spec/client_spec.rb
|
289
|
+
- spec/contentful_model_spec.rb
|
290
|
+
- spec/fixtures/vcr_cassettes/asset/all.yml
|
291
|
+
- spec/fixtures/vcr_cassettes/asset/find.yml
|
292
|
+
- spec/fixtures/vcr_cassettes/association/belongs_to_many.yml
|
293
|
+
- spec/fixtures/vcr_cassettes/association/has_many.yml
|
294
|
+
- spec/fixtures/vcr_cassettes/association/has_one.yml
|
295
|
+
- spec/fixtures/vcr_cassettes/association/nested_with_root_root.yml
|
296
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_child_higher_include.yml
|
297
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_child_parent.yml
|
298
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_childless.yml
|
299
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_middle.yml
|
300
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_middle_higher_include.yml
|
301
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_middle_parent.yml
|
302
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_parentless.yml
|
303
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_parentless_higher_include.yml
|
304
|
+
- spec/fixtures/vcr_cassettes/associations/nested_without_root_middle.yml
|
305
|
+
- spec/fixtures/vcr_cassettes/associations/nested_without_root_middle_higher_include.yml
|
306
|
+
- spec/fixtures/vcr_cassettes/base/content_type.yml
|
307
|
+
- spec/fixtures/vcr_cassettes/base/return_nil_for_empty.yml
|
308
|
+
- spec/fixtures/vcr_cassettes/base/return_nil_for_empty_with_value.yml
|
309
|
+
- spec/fixtures/vcr_cassettes/client.yml
|
310
|
+
- spec/fixtures/vcr_cassettes/dog.yml
|
311
|
+
- spec/fixtures/vcr_cassettes/human.yml
|
312
|
+
- spec/fixtures/vcr_cassettes/management/client.yml
|
313
|
+
- spec/fixtures/vcr_cassettes/management/nyancat.yml
|
314
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_2.yml
|
315
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_publish.yml
|
316
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_refetch_and_fail.yml
|
317
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_refetch_and_save.yml
|
318
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_save.yml
|
319
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_save_2.yml
|
320
|
+
- spec/fixtures/vcr_cassettes/nyancat.yml
|
321
|
+
- spec/fixtures/vcr_cassettes/playground/nyancat.yml
|
322
|
+
- spec/fixtures/vcr_cassettes/query/each_entry.yml
|
323
|
+
- spec/fixtures/vcr_cassettes/query/each_page.yml
|
324
|
+
- spec/fixtures/vcr_cassettes/query/empty.yml
|
325
|
+
- spec/fixtures/vcr_cassettes/query/load.yml
|
326
|
+
- spec/fixtures/vcr_cassettes/query/manual_pagination.yml
|
327
|
+
- spec/fixtures/vcr_cassettes/query/nyancat_invalid_elements.yml
|
328
|
+
- spec/manageable_spec.rb
|
329
|
+
- spec/management_spec.rb
|
330
|
+
- spec/migrations/content_type_factory_spec.rb
|
331
|
+
- spec/migrations/content_type_spec.rb
|
332
|
+
- spec/migrations/migration_spec.rb
|
333
|
+
- spec/queries_spec.rb
|
334
|
+
- spec/query_spec.rb
|
335
|
+
- spec/spec_helper.rb
|
336
|
+
- spec/validations/validations_spec.rb
|
337
|
+
homepage: https://github.com/contentful/contentful_model
|
201
338
|
licenses:
|
202
339
|
- MIT
|
203
340
|
metadata: {}
|
@@ -217,8 +354,65 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
354
|
version: '0'
|
218
355
|
requirements: []
|
219
356
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.
|
357
|
+
rubygems_version: 2.7.6
|
221
358
|
signing_key:
|
222
359
|
specification_version: 4
|
223
|
-
summary:
|
224
|
-
test_files:
|
360
|
+
summary: An ActiveModel-like wrapper for the Contentful SDKs
|
361
|
+
test_files:
|
362
|
+
- spec/asset_spec.rb
|
363
|
+
- spec/associations/belongs_to_many_spec.rb
|
364
|
+
- spec/associations/belongs_to_spec.rb
|
365
|
+
- spec/associations/has_many_nested_spec.rb
|
366
|
+
- spec/associations/has_many_spec.rb
|
367
|
+
- spec/associations/has_one_spec.rb
|
368
|
+
- spec/base_spec.rb
|
369
|
+
- spec/chainable_queries_spec.rb
|
370
|
+
- spec/client_spec.rb
|
371
|
+
- spec/contentful_model_spec.rb
|
372
|
+
- spec/fixtures/vcr_cassettes/asset/all.yml
|
373
|
+
- spec/fixtures/vcr_cassettes/asset/find.yml
|
374
|
+
- spec/fixtures/vcr_cassettes/association/belongs_to_many.yml
|
375
|
+
- spec/fixtures/vcr_cassettes/association/has_many.yml
|
376
|
+
- spec/fixtures/vcr_cassettes/association/has_one.yml
|
377
|
+
- spec/fixtures/vcr_cassettes/association/nested_with_root_root.yml
|
378
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_child_higher_include.yml
|
379
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_child_parent.yml
|
380
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_childless.yml
|
381
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_middle.yml
|
382
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_middle_higher_include.yml
|
383
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_middle_parent.yml
|
384
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_parentless.yml
|
385
|
+
- spec/fixtures/vcr_cassettes/association/nested_without_root_parentless_higher_include.yml
|
386
|
+
- spec/fixtures/vcr_cassettes/associations/nested_without_root_middle.yml
|
387
|
+
- spec/fixtures/vcr_cassettes/associations/nested_without_root_middle_higher_include.yml
|
388
|
+
- spec/fixtures/vcr_cassettes/base/content_type.yml
|
389
|
+
- spec/fixtures/vcr_cassettes/base/return_nil_for_empty.yml
|
390
|
+
- spec/fixtures/vcr_cassettes/base/return_nil_for_empty_with_value.yml
|
391
|
+
- spec/fixtures/vcr_cassettes/client.yml
|
392
|
+
- spec/fixtures/vcr_cassettes/dog.yml
|
393
|
+
- spec/fixtures/vcr_cassettes/human.yml
|
394
|
+
- spec/fixtures/vcr_cassettes/management/client.yml
|
395
|
+
- spec/fixtures/vcr_cassettes/management/nyancat.yml
|
396
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_2.yml
|
397
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_publish.yml
|
398
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_refetch_and_fail.yml
|
399
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_refetch_and_save.yml
|
400
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_save.yml
|
401
|
+
- spec/fixtures/vcr_cassettes/management/nyancat_save_2.yml
|
402
|
+
- spec/fixtures/vcr_cassettes/nyancat.yml
|
403
|
+
- spec/fixtures/vcr_cassettes/playground/nyancat.yml
|
404
|
+
- spec/fixtures/vcr_cassettes/query/each_entry.yml
|
405
|
+
- spec/fixtures/vcr_cassettes/query/each_page.yml
|
406
|
+
- spec/fixtures/vcr_cassettes/query/empty.yml
|
407
|
+
- spec/fixtures/vcr_cassettes/query/load.yml
|
408
|
+
- spec/fixtures/vcr_cassettes/query/manual_pagination.yml
|
409
|
+
- spec/fixtures/vcr_cassettes/query/nyancat_invalid_elements.yml
|
410
|
+
- spec/manageable_spec.rb
|
411
|
+
- spec/management_spec.rb
|
412
|
+
- spec/migrations/content_type_factory_spec.rb
|
413
|
+
- spec/migrations/content_type_spec.rb
|
414
|
+
- spec/migrations/migration_spec.rb
|
415
|
+
- spec/queries_spec.rb
|
416
|
+
- spec/query_spec.rb
|
417
|
+
- spec/spec_helper.rb
|
418
|
+
- spec/validations/validations_spec.rb
|
@@ -1,104 +0,0 @@
|
|
1
|
-
module ContentfulModel
|
2
|
-
module ChainableQueries
|
3
|
-
def self.included(base)
|
4
|
-
base.include ContentfulModel::Queries
|
5
|
-
base.extend ClassMethods
|
6
|
-
end
|
7
|
-
|
8
|
-
module ClassMethods
|
9
|
-
|
10
|
-
def all
|
11
|
-
raise ArgumentError, 'You need to set self.content_type in your model class' if @content_type_id.nil?
|
12
|
-
self
|
13
|
-
end
|
14
|
-
|
15
|
-
def params(options)
|
16
|
-
@query << options
|
17
|
-
self
|
18
|
-
end
|
19
|
-
|
20
|
-
def first
|
21
|
-
@query << {'limit' => 1}
|
22
|
-
load.first
|
23
|
-
end
|
24
|
-
|
25
|
-
def offset(n)
|
26
|
-
@query << {'skip' => n}
|
27
|
-
self
|
28
|
-
end
|
29
|
-
|
30
|
-
def limit(n)
|
31
|
-
@query << {'limit' => n}
|
32
|
-
self
|
33
|
-
end
|
34
|
-
|
35
|
-
def locale(locale_code)
|
36
|
-
@query << {'locale' => locale_code}
|
37
|
-
self
|
38
|
-
end
|
39
|
-
|
40
|
-
def load_children(n)
|
41
|
-
@query << {'include' => n}
|
42
|
-
self
|
43
|
-
end
|
44
|
-
|
45
|
-
def order(args)
|
46
|
-
prefix = ''
|
47
|
-
if args.is_a?(Hash)
|
48
|
-
column = args.first.first.to_s
|
49
|
-
prefix = '-' if args.first.last == :desc
|
50
|
-
elsif args.is_a?(Symbol)
|
51
|
-
column = args.to_s
|
52
|
-
prefix = ''
|
53
|
-
else
|
54
|
-
column = args.to_s
|
55
|
-
end
|
56
|
-
@query << {'order' => "#{prefix}fields.#{column.camelize(:lower)}"}
|
57
|
-
self
|
58
|
-
end
|
59
|
-
|
60
|
-
alias_method :skip, :offset
|
61
|
-
|
62
|
-
def find_by(*args)
|
63
|
-
args.each do |query|
|
64
|
-
#query is a hash
|
65
|
-
if query.values.first.is_a?(Array) #we need to do an 'in' query
|
66
|
-
@query << {"fields.#{query.keys.first.to_s.camelize(:lower)}[in]" => query.values.first.join(",")}
|
67
|
-
elsif query.values.first.is_a?(String) || query.values.first.is_a?(Numeric) || [TrueClass,FalseClass].member?(query.values.first.class)
|
68
|
-
@query << {"fields.#{query.keys.first.to_s.camelize(:lower)}" => query.values.first}
|
69
|
-
elsif query.values.first.is_a?(Hash)
|
70
|
-
# if the search is a hash, use the key to specify the search field operator
|
71
|
-
# For example
|
72
|
-
# Model.search(start_date: {gte: DateTime.now}) => "fields.start_date[gte]" => DateTime.now
|
73
|
-
query.each do |field, condition|
|
74
|
-
search_predicate, search_value = *condition.flatten
|
75
|
-
@query << {"fields.#{field.to_s.camelize(:lower)}[#{search_predicate}]" => search_value}
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
self
|
80
|
-
end
|
81
|
-
|
82
|
-
def search(parameters)
|
83
|
-
if parameters.is_a?(Hash)
|
84
|
-
parameters.each do |field, search|
|
85
|
-
# if the search is a hash, use the key to specify the search field operator
|
86
|
-
# For example
|
87
|
-
# Model.search(start_date: {gte: DateTime.now}) => "fields.start_date[gte]" => DateTime.now
|
88
|
-
if search.is_a?(Hash)
|
89
|
-
search_key, search_value = *search.flatten
|
90
|
-
@query << {"fields.#{field.to_s.camelize(:lower)}[#{search_key}]" => search_value}
|
91
|
-
else
|
92
|
-
@query << {"fields.#{field.to_s.camelize(:lower)}[match]" => search}
|
93
|
-
end
|
94
|
-
end
|
95
|
-
elsif parameters.is_a?(String)
|
96
|
-
@query << {"query" => parameters}
|
97
|
-
end
|
98
|
-
self
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|