wcc-contentful 0.3.0.pre.rc3 → 1.0.0.pre.rc1

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 (69) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +1 -0
  3. data/Guardfile +101 -0
  4. data/README.md +161 -11
  5. data/app/controllers/wcc/contentful/webhook_controller.rb +25 -24
  6. data/app/jobs/wcc/contentful/webhook_enable_job.rb +36 -2
  7. data/config/routes.rb +1 -1
  8. data/doc/wcc-contentful.png +0 -0
  9. data/lib/tasks/download_schema.rake +12 -0
  10. data/lib/wcc/contentful.rb +70 -16
  11. data/lib/wcc/contentful/active_record_shim.rb +72 -0
  12. data/lib/wcc/contentful/configuration.rb +177 -46
  13. data/lib/wcc/contentful/content_type_indexer.rb +14 -0
  14. data/lib/wcc/contentful/downloads_schema.rb +112 -0
  15. data/lib/wcc/contentful/engine.rb +33 -14
  16. data/lib/wcc/contentful/event.rb +171 -0
  17. data/lib/wcc/contentful/events.rb +41 -0
  18. data/lib/wcc/contentful/exceptions.rb +3 -0
  19. data/lib/wcc/contentful/indexed_representation.rb +2 -2
  20. data/lib/wcc/contentful/instrumentation.rb +31 -0
  21. data/lib/wcc/contentful/link.rb +28 -0
  22. data/lib/wcc/contentful/link_visitor.rb +122 -0
  23. data/lib/wcc/contentful/middleware.rb +7 -0
  24. data/lib/wcc/contentful/middleware/store.rb +158 -0
  25. data/lib/wcc/contentful/middleware/store/caching_middleware.rb +114 -0
  26. data/lib/wcc/contentful/model.rb +37 -3
  27. data/lib/wcc/contentful/model_builder.rb +1 -0
  28. data/lib/wcc/contentful/model_methods.rb +40 -15
  29. data/lib/wcc/contentful/model_singleton_methods.rb +47 -30
  30. data/lib/wcc/contentful/rake.rb +3 -0
  31. data/lib/wcc/contentful/rspec.rb +46 -0
  32. data/lib/wcc/contentful/services.rb +61 -27
  33. data/lib/wcc/contentful/simple_client.rb +81 -25
  34. data/lib/wcc/contentful/simple_client/management.rb +43 -10
  35. data/lib/wcc/contentful/simple_client/response.rb +61 -22
  36. data/lib/wcc/contentful/simple_client/typhoeus_adapter.rb +17 -17
  37. data/lib/wcc/contentful/store.rb +7 -66
  38. data/lib/wcc/contentful/store/README.md +85 -0
  39. data/lib/wcc/contentful/store/base.rb +34 -119
  40. data/lib/wcc/contentful/store/cdn_adapter.rb +71 -12
  41. data/lib/wcc/contentful/store/factory.rb +186 -0
  42. data/lib/wcc/contentful/store/instrumentation.rb +55 -0
  43. data/lib/wcc/contentful/store/interface.rb +82 -0
  44. data/lib/wcc/contentful/store/memory_store.rb +27 -24
  45. data/lib/wcc/contentful/store/postgres_store.rb +268 -101
  46. data/lib/wcc/contentful/store/postgres_store/schema_1.sql +73 -0
  47. data/lib/wcc/contentful/store/postgres_store/schema_2.sql +21 -0
  48. data/lib/wcc/contentful/store/query.rb +246 -0
  49. data/lib/wcc/contentful/store/query/interface.rb +63 -0
  50. data/lib/wcc/contentful/store/rspec_examples.rb +48 -0
  51. data/lib/wcc/contentful/store/rspec_examples/basic_store.rb +629 -0
  52. data/lib/wcc/contentful/store/rspec_examples/include_param.rb +283 -0
  53. data/lib/wcc/contentful/store/rspec_examples/nested_queries.rb +342 -0
  54. data/lib/wcc/contentful/sync_engine.rb +181 -0
  55. data/lib/wcc/contentful/test.rb +7 -0
  56. data/lib/wcc/contentful/test/attributes.rb +56 -0
  57. data/lib/wcc/contentful/test/double.rb +76 -0
  58. data/lib/wcc/contentful/test/factory.rb +101 -0
  59. data/lib/wcc/contentful/version.rb +1 -1
  60. data/wcc-contentful.gemspec +22 -10
  61. metadata +282 -103
  62. data/Gemfile +0 -8
  63. data/app/jobs/wcc/contentful/delayed_sync_job.rb +0 -63
  64. data/lib/wcc/contentful/client_ext.rb +0 -28
  65. data/lib/wcc/contentful/graphql.rb +0 -14
  66. data/lib/wcc/contentful/graphql/builder.rb +0 -177
  67. data/lib/wcc/contentful/graphql/types.rb +0 -54
  68. data/lib/wcc/contentful/simple_client/http_adapter.rb +0 -24
  69. data/lib/wcc/contentful/store/lazy_cache_store.rb +0 -161
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-contentful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.rc3
4
+ version: 1.0.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-12 00:00:00.000000000 Z
11
+ date: 2021-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 11.0.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 11.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: dotenv
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +52,20 @@ dependencies:
24
52
  - - "~>"
25
53
  - !ruby/object:Gem::Version
26
54
  version: '2.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: erb_lint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.26
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.26
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: httplog
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +86,14 @@ dependencies:
44
86
  requirements:
45
87
  - - "~>"
46
88
  - !ruby/object:Gem::Version
47
- version: '10.0'
89
+ version: '13.0'
48
90
  type: :development
49
91
  prerelease: false
50
92
  version_requirements: !ruby/object:Gem::Requirement
51
93
  requirements:
52
94
  - - "~>"
53
95
  - !ruby/object:Gem::Version
54
- version: '10.0'
96
+ version: '13.0'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: rspec
57
99
  requirement: !ruby/object:Gem::Requirement
@@ -66,34 +108,76 @@ dependencies:
66
108
  - - "~>"
67
109
  - !ruby/object:Gem::Version
68
110
  version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-instrumentation-matcher
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
69
125
  - !ruby/object:Gem::Dependency
70
126
  name: rspec_junit_formatter
71
127
  requirement: !ruby/object:Gem::Requirement
72
128
  requirements:
73
129
  - - "~>"
74
130
  - !ruby/object:Gem::Version
75
- version: 0.3.0
131
+ version: 0.4.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.4.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: '0.68'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: '0.68'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.16.1
76
160
  type: :development
77
161
  prerelease: false
78
162
  version_requirements: !ruby/object:Gem::Requirement
79
163
  requirements:
80
164
  - - "~>"
81
165
  - !ruby/object:Gem::Version
82
- version: 0.3.0
166
+ version: 0.16.1
83
167
  - !ruby/object:Gem::Dependency
84
168
  name: vcr
85
169
  requirement: !ruby/object:Gem::Requirement
86
170
  requirements:
87
171
  - - "~>"
88
172
  - !ruby/object:Gem::Version
89
- version: '4.0'
173
+ version: '5.0'
90
174
  type: :development
91
175
  prerelease: false
92
176
  version_requirements: !ruby/object:Gem::Requirement
93
177
  requirements:
94
178
  - - "~>"
95
179
  - !ruby/object:Gem::Version
96
- version: '4.0'
180
+ version: '5.0'
97
181
  - !ruby/object:Gem::Dependency
98
182
  name: webmock
99
183
  requirement: !ruby/object:Gem::Requirement
@@ -109,117 +193,145 @@ dependencies:
109
193
  - !ruby/object:Gem::Version
110
194
  version: '3.0'
111
195
  - !ruby/object:Gem::Dependency
112
- name: generator_spec
196
+ name: wisper-rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: guard
113
211
  requirement: !ruby/object:Gem::Requirement
114
212
  requirements:
115
213
  - - "~>"
116
214
  - !ruby/object:Gem::Version
117
- version: 0.9.4
215
+ version: '2.14'
118
216
  type: :development
119
217
  prerelease: false
120
218
  version_requirements: !ruby/object:Gem::Requirement
121
219
  requirements:
122
220
  - - "~>"
123
221
  - !ruby/object:Gem::Version
124
- version: 0.9.4
222
+ version: '2.14'
125
223
  - !ruby/object:Gem::Dependency
126
- name: rails
224
+ name: guard-rspec
127
225
  requirement: !ruby/object:Gem::Requirement
128
226
  requirements:
129
227
  - - "~>"
130
228
  - !ruby/object:Gem::Version
131
- version: '5.1'
229
+ version: '4.7'
132
230
  type: :development
133
231
  prerelease: false
134
232
  version_requirements: !ruby/object:Gem::Requirement
135
233
  requirements:
136
234
  - - "~>"
137
235
  - !ruby/object:Gem::Version
138
- version: '5.1'
236
+ version: '4.7'
139
237
  - !ruby/object:Gem::Dependency
140
- name: rspec-rails
238
+ name: guard-rubocop
141
239
  requirement: !ruby/object:Gem::Requirement
142
240
  requirements:
143
241
  - - "~>"
144
242
  - !ruby/object:Gem::Version
145
- version: '3.7'
243
+ version: 1.3.0
146
244
  type: :development
147
245
  prerelease: false
148
246
  version_requirements: !ruby/object:Gem::Requirement
149
247
  requirements:
150
248
  - - "~>"
151
249
  - !ruby/object:Gem::Version
152
- version: '3.7'
250
+ version: 1.3.0
153
251
  - !ruby/object:Gem::Dependency
154
- name: sqlite3
252
+ name: guard-shell
155
253
  requirement: !ruby/object:Gem::Requirement
156
254
  requirements:
157
- - - ">="
255
+ - - "~>"
158
256
  - !ruby/object:Gem::Version
159
- version: '0'
257
+ version: 0.7.1
160
258
  type: :development
161
259
  prerelease: false
162
260
  version_requirements: !ruby/object:Gem::Requirement
163
261
  requirements:
164
- - - ">="
262
+ - - "~>"
165
263
  - !ruby/object:Gem::Version
166
- version: '0'
264
+ version: 0.7.1
167
265
  - !ruby/object:Gem::Dependency
168
- name: timecop
266
+ name: generator_spec
169
267
  requirement: !ruby/object:Gem::Requirement
170
268
  requirements:
171
269
  - - "~>"
172
270
  - !ruby/object:Gem::Version
173
- version: 0.9.1
271
+ version: 0.9.4
174
272
  type: :development
175
273
  prerelease: false
176
274
  version_requirements: !ruby/object:Gem::Requirement
177
275
  requirements:
178
276
  - - "~>"
179
277
  - !ruby/object:Gem::Version
180
- version: 0.9.1
278
+ version: 0.9.4
181
279
  - !ruby/object:Gem::Dependency
182
- name: contentful
280
+ name: sqlite3
183
281
  requirement: !ruby/object:Gem::Requirement
184
282
  requirements:
185
- - - '='
283
+ - - "~>"
186
284
  - !ruby/object:Gem::Version
187
- version: 2.6.0
285
+ version: 1.3.6
188
286
  type: :development
189
287
  prerelease: false
190
288
  version_requirements: !ruby/object:Gem::Requirement
191
289
  requirements:
192
- - - '='
290
+ - - "~>"
193
291
  - !ruby/object:Gem::Version
194
- version: 2.6.0
292
+ version: 1.3.6
195
293
  - !ruby/object:Gem::Dependency
196
- name: contentful-management
294
+ name: timecop
197
295
  requirement: !ruby/object:Gem::Requirement
198
296
  requirements:
199
- - - '='
297
+ - - "~>"
200
298
  - !ruby/object:Gem::Version
201
- version: 2.0.2
299
+ version: 0.9.1
202
300
  type: :development
203
301
  prerelease: false
204
302
  version_requirements: !ruby/object:Gem::Requirement
205
303
  requirements:
206
- - - '='
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: 0.9.1
307
+ - !ruby/object:Gem::Dependency
308
+ name: connection_pool
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: '2.2'
314
+ type: :development
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
207
319
  - !ruby/object:Gem::Version
208
- version: 2.0.2
320
+ version: '2.2'
209
321
  - !ruby/object:Gem::Dependency
210
- name: graphql
322
+ name: faraday
211
323
  requirement: !ruby/object:Gem::Requirement
212
324
  requirements:
213
325
  - - "~>"
214
326
  - !ruby/object:Gem::Version
215
- version: '1.7'
327
+ version: '0.9'
216
328
  type: :development
217
329
  prerelease: false
218
330
  version_requirements: !ruby/object:Gem::Requirement
219
331
  requirements:
220
332
  - - "~>"
221
333
  - !ruby/object:Gem::Version
222
- version: '1.7'
334
+ version: '0.9'
223
335
  - !ruby/object:Gem::Dependency
224
336
  name: http
225
337
  requirement: !ruby/object:Gem::Requirement
@@ -283,33 +395,33 @@ dependencies:
283
395
  - !ruby/object:Gem::Version
284
396
  version: '5'
285
397
  - !ruby/object:Gem::Dependency
286
- name: dry-validation
398
+ name: wcc-base
287
399
  requirement: !ruby/object:Gem::Requirement
288
400
  requirements:
289
401
  - - "~>"
290
402
  - !ruby/object:Gem::Version
291
- version: 0.11.1
403
+ version: 0.3.1
292
404
  type: :runtime
293
405
  prerelease: false
294
406
  version_requirements: !ruby/object:Gem::Requirement
295
407
  requirements:
296
408
  - - "~>"
297
409
  - !ruby/object:Gem::Version
298
- version: 0.11.1
410
+ version: 0.3.1
299
411
  - !ruby/object:Gem::Dependency
300
- name: wcc-base
412
+ name: wisper
301
413
  requirement: !ruby/object:Gem::Requirement
302
414
  requirements:
303
415
  - - "~>"
304
416
  - !ruby/object:Gem::Version
305
- version: 0.3.1
417
+ version: 2.0.0
306
418
  type: :runtime
307
419
  prerelease: false
308
420
  version_requirements: !ruby/object:Gem::Requirement
309
421
  requirements:
310
422
  - - "~>"
311
423
  - !ruby/object:Gem::Version
312
- version: 0.3.1
424
+ version: 2.0.0
313
425
  description: Contentful API wrapper library exposing an ActiveRecord-like interface
314
426
  email:
315
427
  - dev@watermark.org
@@ -318,11 +430,10 @@ extensions: []
318
430
  extra_rdoc_files: []
319
431
  files:
320
432
  - ".rspec"
321
- - Gemfile
433
+ - Guardfile
322
434
  - README.md
323
435
  - app/controllers/wcc/contentful/application_controller.rb
324
436
  - app/controllers/wcc/contentful/webhook_controller.rb
325
- - app/jobs/wcc/contentful/delayed_sync_job.rb
326
437
  - app/jobs/wcc/contentful/webhook_enable_job.rb
327
438
  - bin/console
328
439
  - bin/rails
@@ -330,42 +441,67 @@ files:
330
441
  - bin/setup
331
442
  - config/initializers/mime_types.rb
332
443
  - config/routes.rb
444
+ - doc/wcc-contentful.png
445
+ - lib/tasks/download_schema.rake
333
446
  - lib/wcc/contentful.rb
334
- - lib/wcc/contentful/client_ext.rb
447
+ - lib/wcc/contentful/active_record_shim.rb
335
448
  - lib/wcc/contentful/configuration.rb
336
449
  - lib/wcc/contentful/content_type_indexer.rb
450
+ - lib/wcc/contentful/downloads_schema.rb
337
451
  - lib/wcc/contentful/engine.rb
452
+ - lib/wcc/contentful/event.rb
453
+ - lib/wcc/contentful/events.rb
338
454
  - lib/wcc/contentful/exceptions.rb
339
- - lib/wcc/contentful/graphql.rb
340
- - lib/wcc/contentful/graphql/builder.rb
341
- - lib/wcc/contentful/graphql/types.rb
342
455
  - lib/wcc/contentful/helpers.rb
343
456
  - lib/wcc/contentful/indexed_representation.rb
457
+ - lib/wcc/contentful/instrumentation.rb
458
+ - lib/wcc/contentful/link.rb
459
+ - lib/wcc/contentful/link_visitor.rb
460
+ - lib/wcc/contentful/middleware.rb
461
+ - lib/wcc/contentful/middleware/store.rb
462
+ - lib/wcc/contentful/middleware/store/caching_middleware.rb
344
463
  - lib/wcc/contentful/model.rb
345
464
  - lib/wcc/contentful/model_builder.rb
346
465
  - lib/wcc/contentful/model_methods.rb
347
466
  - lib/wcc/contentful/model_singleton_methods.rb
348
467
  - lib/wcc/contentful/rails.rb
468
+ - lib/wcc/contentful/rake.rb
469
+ - lib/wcc/contentful/rspec.rb
349
470
  - lib/wcc/contentful/services.rb
350
471
  - lib/wcc/contentful/simple_client.rb
351
- - lib/wcc/contentful/simple_client/http_adapter.rb
352
472
  - lib/wcc/contentful/simple_client/management.rb
353
473
  - lib/wcc/contentful/simple_client/response.rb
354
474
  - lib/wcc/contentful/simple_client/typhoeus_adapter.rb
355
475
  - lib/wcc/contentful/store.rb
476
+ - lib/wcc/contentful/store/README.md
356
477
  - lib/wcc/contentful/store/base.rb
357
478
  - lib/wcc/contentful/store/cdn_adapter.rb
358
- - lib/wcc/contentful/store/lazy_cache_store.rb
479
+ - lib/wcc/contentful/store/factory.rb
480
+ - lib/wcc/contentful/store/instrumentation.rb
481
+ - lib/wcc/contentful/store/interface.rb
359
482
  - lib/wcc/contentful/store/memory_store.rb
360
483
  - lib/wcc/contentful/store/postgres_store.rb
484
+ - lib/wcc/contentful/store/postgres_store/schema_1.sql
485
+ - lib/wcc/contentful/store/postgres_store/schema_2.sql
486
+ - lib/wcc/contentful/store/query.rb
487
+ - lib/wcc/contentful/store/query/interface.rb
488
+ - lib/wcc/contentful/store/rspec_examples.rb
489
+ - lib/wcc/contentful/store/rspec_examples/basic_store.rb
490
+ - lib/wcc/contentful/store/rspec_examples/include_param.rb
491
+ - lib/wcc/contentful/store/rspec_examples/nested_queries.rb
492
+ - lib/wcc/contentful/sync_engine.rb
361
493
  - lib/wcc/contentful/sys.rb
494
+ - lib/wcc/contentful/test.rb
495
+ - lib/wcc/contentful/test/attributes.rb
496
+ - lib/wcc/contentful/test/double.rb
497
+ - lib/wcc/contentful/test/factory.rb
362
498
  - lib/wcc/contentful/version.rb
363
499
  - wcc-contentful.gemspec
364
500
  homepage: https://github.com/watermarkchurch/wcc-contentful/wcc-contentful
365
501
  licenses:
366
502
  - MIT
367
503
  metadata: {}
368
- post_install_message:
504
+ post_install_message:
369
505
  rdoc_options: []
370
506
  require_paths:
371
507
  - lib
@@ -380,30 +516,33 @@ required_rubygems_version: !ruby/object:Gem::Requirement
380
516
  - !ruby/object:Gem::Version
381
517
  version: 1.3.1
382
518
  requirements: []
383
- rubyforge_project:
384
- rubygems_version: 2.6.11
385
- signing_key:
519
+ rubyforge_project:
520
+ rubygems_version: 2.7.6.2
521
+ signing_key:
386
522
  specification_version: 4
387
- summary: '[![Gem Version](https://badge.fury.io/rb/wcc-contentful.svg)](https://badge.fury.io/rb/wcc-contentful)
388
- [![CircleCI](https://circleci.com/gh/watermarkchurch/wcc-contentful.svg?style=svg)](https://circleci.com/gh/watermarkchurch/wcc-contentful) Full
389
- documentation: https://www.rubydoc.info/github/watermarkchurch/wcc-contentful #
390
- WCC::Contentful ## Installation Add this line to your application''s Gemfile: ```ruby
391
- gem ''wcc-contentful'', require: ''wcc/contentful/rails'' ``` And then execute: $
392
- bundle Or install it yourself as: $ gem install wcc-contentful ## Configure ```ruby
393
- WCC::Contentful.configure do |config| config.access_token = <CONTENTFUL_ACCESS_TOKEN>
394
- config.space = <CONTENTFUL_SPACE_ID> end WCC::Contentful.init! ``` ## Usage ###
395
- WCC::Contentful::Model API The WCC::Contentful::Model API exposes Contentful data
396
- as a set of dynamically generated Ruby objects. These objects are based on the
397
- content types in your Contentful space. All these objects are generated by WCC::Contentful.init! The
398
- following examples show how to use this API to find entries of the `page` content
399
- type: ```ruby # Find objects by id WCC::Contentful::Model::Page.find(''1E2ucWSdacxxf233sfa3'')
400
- # => #<WCC::Contentful::Model::Page:0x0000000005c71a78 @created_at=2018-04-16 18:41:17
401
- UTC...> # Find objects by field WCC::Contentful::Model::Page.find_by(slug: ''/some-slug'')
402
- # => #<WCC::Contentful::Model::Page:0x0000000005c71a78 @created_at=2018-04-16 18:41:17
403
- UTC...> # Use operators to filter by a field # must use full notation for sys attributes
404
- (except ID) WCC::Contentful::Model::Page.find_all(''sys.created_at'' => { lte: Date.today
405
- }) # => [#<WCC::Contentful::Model::Page:0x0000000005c71a78 @created_at=2018-04-16
406
- 18:41:17 UTC...>, ... ] # Nest queries to mimick joins WCC::Contentful::Model::Page.find_by(subpages:
523
+ summary: '[![Gem Version](https://badge.fury.io/rb/wcc-contentful.svg)](https://rubygems.org/gems/wcc-contentful)
524
+ [![Build Status](https://travis-ci.org/watermarkchurch/wcc-contentful.svg?branch=master)](https://travis-ci.org/watermarkchurch/wcc-contentful)
525
+ [![Coverage Status](https://coveralls.io/repos/github/watermarkchurch/wcc-contentful/badge.svg?branch=master)](https://coveralls.io/github/watermarkchurch/wcc-contentful?branch=master) Full
526
+ documentation: https://www.rubydoc.info/gems/wcc-contentful # WCC::Contentful ##
527
+ Installation Add this line to your application''s Gemfile: ```ruby gem ''wcc-contentful'',
528
+ require: ''wcc/contentful/rails'' ``` If you''re not using rails, exclude the `require:`
529
+ parameter. ```ruby gem ''wcc-contentful'' ``` And then execute: ``` $ bundle ```
530
+ Or install it yourself as: ``` $ gem install wcc-contentful ``` ## Configure Put
531
+ this in an initializer: ```ruby # config/initializers/wcc_contentful.rb WCC::Contentful.configure
532
+ do |config| config.access_token = <CONTENTFUL_ACCESS_TOKEN> config.space = <CONTENTFUL_SPACE_ID>
533
+ end WCC::Contentful.init! ``` All configuration options can be found [in the rubydoc](https://www.rubydoc.info/gems/wcc-contentful/WCC/Contentful/Configuration)
534
+ under {WCC::Contentful::Configuration} ## Usage ### WCC::Contentful::Model API The
535
+ WCC::Contentful::Model API exposes Contentful data as a set of dynamically generated
536
+ Ruby objects. These objects are based on the content types in your Contentful space. All
537
+ these objects are generated by `WCC::Contentful.init!` The following examples show
538
+ how to use this API to find entries of the `page` content type: ```ruby # Find
539
+ objects by id WCC::Contentful::Model::Page.find(''1E2ucWSdacxxf233sfa3'') # => #<WCC::Contentful::Model::Page:0x0000000005c71a78
540
+ @created_at=2018-04-16 18:41:17 UTC...> # Find objects by field WCC::Contentful::Model::Page.find_by(slug:
541
+ ''/some-slug'') # => #<WCC::Contentful::Model::Page:0x0000000005c71a78 @created_at=2018-04-16
542
+ 18:41:17 UTC...> # Use operators to filter by a field # must use full notation
543
+ for sys attributes (except ID) WCC::Contentful::Model::Page.find_all(''sys.created_at''
544
+ => { lte: Date.today }) # => [#<WCC::Contentful::Model::Page:0x0000000005c71a78
545
+ @created_at=2018-04-16 18:41:17 UTC...>, ... ] # Nest queries to mimick joins WCC::Contentful::Model::Page.find_by(subpages:
407
546
  { slug: ''/some-slug'' }) # => #<WCC::Contentful::Model::Page:0x0000000005c71a78
408
547
  @created_at=2018-04-16 18:41:17 UTC...> # Pass the preview flag to use the preview
409
548
  client (must have set preview_token config param) preview_redirect = WCC::Contentful::Model::Redirect.find_by({
@@ -436,32 +575,72 @@ summary: '[![Gem Version](https://badge.fury.io/rb/wcc-contentful.svg)](https://
436
575
  # {"sys"=> ...} # "6Fwukxxkxa6qQCC04WCaqg"=> # {"sys"=> ...} # ...} ``` The
437
576
  client handles Paging automatically within the lazy iterator returned by #items.
438
577
  This lazy iterator does not respect the `limit` param - that param is only passed
439
- through to the API to set the page size. Entries included via the `include` parameter
440
- are made available on the #includes field. This is a hash of `<entry ID> => <raw
441
- entry>` and makes it easy to grab links. This hash is added to lazily as you enumerate
442
- the pages. See the {WCC::Contentful::SimpleClient} documentation for more details. ###
443
- Accessing the APIs within application code The Model API is best exposed by defining
444
- your own model classes in the `app/models` directory which inherit from the WCC::Contentful
445
- models. ```ruby # app/models/page.rb class Page < WCC::Contentful::Model::Page #
446
- You can add additional methods here end # app/controllers/pages_controller.rb class
447
- PagesController < ApplicationController def show @page = Page.find_by(slug: params[:slug])
448
- raise Exceptions::PageNotFoundError, params[:slug] unless @page end end ``` The
449
- {WCC::Contentful::Services} singleton gives access to the other configured services.
450
- You can also include the {WCC::Contentful::ServiceAccessors} concern to define these
451
- services as attributes in a class. ```ruby class MyJob < ApplicationJob include
452
- WCC::Contentful::ServiceAccessors def perform Page.find(...) store.find(...) client.entries(...)
453
- end end ``` ## Development After checking out the repo, run `bin/setup` to install
454
- dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console`
455
- for an interactive prompt that will allow you to experiment. To install this gem
456
- onto your local machine, run `bundle exec rake install`. To release a new version,
457
- update the version number in `version.rb`, and then run `bundle exec rake release`,
458
- which will create a git tag for the version, push git commits and tags, and push
459
- the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports
460
- and pull requests are welcome on GitHub at https://github.com/watermarkchurch/wcc-contentful.
461
- This project is intended to be a safe, welcoming space for collaboration, and contributors
462
- are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org)
463
- code of conduct. ## License The gem is available as open source under the terms
464
- of the [MIT License](http://opensource.org/licenses/MIT). ## Code of Conduct Everyone
578
+ through to the API to set the page size. If you truly want a limited subset of
579
+ response items, use [`response.items.take(n)`](https://ruby-doc.org/core-2.5.3/Enumerable.html#method-i-take) Entries
580
+ included via the `include` parameter are made available on the #includes field. This
581
+ is a hash of `<entry ID> => <raw entry>` and makes it easy to grab links. This
582
+ hash is added to lazily as you enumerate the pages. See the {WCC::Contentful::SimpleClient}
583
+ documentation for more details. ### Accessing the APIs within application code The
584
+ Model API is best exposed by defining your own model classes in the `app/models`
585
+ directory which inherit from the WCC::Contentful models. ```ruby # app/models/page.rb
586
+ class Page < WCC::Contentful::Model::Page # You can add additional methods here
587
+ end # app/controllers/pages_controller.rb class PagesController < ApplicationController
588
+ def show @page = Page.find_by(slug: params[:slug]) raise Exceptions::PageNotFoundError,
589
+ params[:slug] unless @page end end ``` The {WCC::Contentful::Services} singleton
590
+ gives access to the other configured services. You can also include the {WCC::Contentful::ServiceAccessors}
591
+ concern to define these services as attributes in a class. ```ruby class MyJob
592
+ < ApplicationJob include WCC::Contentful::ServiceAccessors def perform Page.find(...) store.find(...) client.entries(...)
593
+ end end ``` ## Architecture ![wcc-contentful diagram](./doc/wcc-contentful.png) ##
594
+ Test Helpers To use the test helpers, include the following in your rails_helper.rb: ```ruby
595
+ require ''wcc/contentful/rspec'' ``` This adds the following helpers to all your
596
+ specs: ```ruby ## # Builds a in-memory instance of the Contentful model for the
597
+ given content_type. # All attributes that are known to be required fields on the
598
+ content type # will return a default value based on the field type. instance = contentful_create(''my-content-type'',
599
+ my_field: ''some-value'') # => #<WCC::Contentful::Model::MyContentType:0x0000000005c71a78
600
+ @created_at=2018-04-16 18:41:17 UTC...> instance.my_field # => "some-value" instance.other_required_field
601
+ # => "default-value" instance.other_optional_field # => nil instance.not_a_field
602
+ # NoMethodError: undefined method `not_a_field'' for #<MyContentType:0x00007fbac81ee490> ##
603
+ # Builds a rspec double of the Contentful model for the given content_type. # All
604
+ attributes that are known to be required fields on the content type # will return
605
+ a default value based on the field type. dbl = contentful_double(''my-content-type'',
606
+ my_field: ''other-value'') # => #<Double (anonymous)> dbl.my_field # => "other-value" dbl.other_optional_field
607
+ # => nil dbl.not_a_field # => #<Double (anonymous)> received unexpected message
608
+ :not_a_field with (no args) ## # Builds out a fake Contentful entry for the given
609
+ content type, and then # stubs the Model API to return that content type for `.find`
610
+ and `.find_by` # query methods. stubbed = contentful_stub(''my-content-type'', id:
611
+ ''1234'', my_field: ''test'') WCC::Contentful::Model.find(''1234'') == stubbed
612
+ # => true MyContentType.find(''1234'') == stubbed # => true MyContentType.find_by(my_field:
613
+ ''test'') == stubbed # => true ``` ## Advanced Configuration Example Here''s an
614
+ example containing all the configuration options, and a sample setup for automatic
615
+ deployment to Heroku. This is intended to make you aware of what is possible, and
616
+ not as a general recommendation of what your setup should look like. ```ruby #
617
+ config/initializers/wcc_contentful.rb WCC::Contentful.configure do |config| config.access_token
618
+ = ENV[''CONTENTFUL_ACCESS_TOKEN''] config.space = ENV[''CONTENTFUL_SPACE_ID''] config.environment
619
+ = ENV[''CONTENTFUL_ENVIRONMENT''] config.preview_token = ENV[''CONTENTFUL_PREVIEW_ACCESS_TOKEN''] #
620
+ You may or may not want to provide this to your production server... config.management_token
621
+ = ENV[''CONTENTFUL_MANAGEMENT_TOKEN''] unless Rails.env.production? config.app_url
622
+ = "https://#{ENV[''HOSTNAME'']}" config.webhook_username = ''my-app-webhook'' config.webhook_password
623
+ = Rails.application.secrets.webhook_password config.webhook_jobs << MyOnWebhookJob config.store
624
+ = :lazy_sync, Rails.cache if Rails.env.production? # config.store = MyCustomStore.new #
625
+ Use a custom Faraday connection config.connection = Faraday.new do |builder| f.request
626
+ :retry f.request MyFaradayRequestAdapter.new ... end # OR implement some adapter
627
+ like this to use another HTTP client config.connection = MyNetHttpAdapter.new config.update_schema_file
628
+ = :never end WCC::Contentful.init! ``` For Heroku: ```yaml # Procfile web: bundle
629
+ exec rails s worker: bundle exec sidekiq release: bin/release ``` ```sh # bin/release
630
+ #!/bin/sh set -e echo "Migrating database..." bin/rake db:migrate echo "Migrating
631
+ contentful..." migrations_to_be_run=$( ... ) # somehow figure this out node_modules/.bin/contentful-migration
632
+ \ -s $CONTENTFUL_SPACE_ID -a $CONTENTFUL_MANAGEMENT_TOKEN \ -y -p "$migrations_to_be_run" echo
633
+ "Updating schema file..." rake wcc_contentful:download_schema ``` All configuration
634
+ options can be found [in the rubydoc](https://www.rubydoc.info/gems/wcc-contentful/WCC/Contentful/Configuration)
635
+ under {WCC::Contentful::Configuration} ## Development After checking out the
636
+ repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to
637
+ run the tests. You can also run `bin/console` for an interactive prompt that will
638
+ allow you to experiment. ## Contributing Bug reports and pull requests are welcome
639
+ on GitHub at https://github.com/watermarkchurch/wcc-contentful. This project is
640
+ intended to be a safe, welcoming space for collaboration, and contributors are expected
641
+ to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
642
+ conduct. ## License The gem is available as open source under the terms of the
643
+ [MIT License](http://opensource.org/licenses/MIT). ## Code of Conduct Everyone
465
644
  interacting in the WCC::Contentful project''s codebases, issue trackers, chat rooms
466
645
  and mailing lists is expected to follow the [code of conduct](https://github.com/watermarkchurch/wcc-contentful/blob/master/CODE_OF_CONDUCT.md).'
467
646
  test_files: []