wcc-contentful 0.2.2 → 0.3.0.pre.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/README.md +181 -8
- data/app/controllers/wcc/contentful/webhook_controller.rb +42 -2
- data/app/jobs/wcc/contentful/delayed_sync_job.rb +52 -3
- data/app/jobs/wcc/contentful/webhook_enable_job.rb +43 -0
- data/bin/console +4 -3
- data/bin/rails +2 -0
- data/config/initializers/mime_types.rb +10 -1
- data/lib/wcc/contentful.rb +14 -142
- data/lib/wcc/contentful/client_ext.rb +17 -4
- data/lib/wcc/contentful/configuration.rb +25 -84
- data/lib/wcc/contentful/engine.rb +19 -0
- data/lib/wcc/contentful/exceptions.rb +25 -28
- data/lib/wcc/contentful/graphql.rb +0 -1
- data/lib/wcc/contentful/graphql/types.rb +1 -1
- data/lib/wcc/contentful/helpers.rb +3 -2
- data/lib/wcc/contentful/indexed_representation.rb +6 -0
- data/lib/wcc/contentful/model.rb +68 -34
- data/lib/wcc/contentful/model_builder.rb +65 -67
- data/lib/wcc/contentful/model_methods.rb +189 -0
- data/lib/wcc/contentful/model_singleton_methods.rb +83 -0
- data/lib/wcc/contentful/services.rb +146 -0
- data/lib/wcc/contentful/simple_client.rb +35 -33
- data/lib/wcc/contentful/simple_client/http_adapter.rb +9 -0
- data/lib/wcc/contentful/simple_client/management.rb +81 -0
- data/lib/wcc/contentful/simple_client/response.rb +61 -37
- data/lib/wcc/contentful/simple_client/typhoeus_adapter.rb +12 -0
- data/lib/wcc/contentful/store.rb +45 -18
- data/lib/wcc/contentful/store/base.rb +128 -8
- data/lib/wcc/contentful/store/cdn_adapter.rb +92 -22
- data/lib/wcc/contentful/store/lazy_cache_store.rb +94 -9
- data/lib/wcc/contentful/store/memory_store.rb +13 -8
- data/lib/wcc/contentful/store/postgres_store.rb +44 -11
- data/lib/wcc/contentful/sys.rb +28 -0
- data/lib/wcc/contentful/version.rb +1 -1
- data/wcc-contentful.gemspec +3 -9
- metadata +87 -107
- data/.circleci/config.yml +0 -51
- data/.gitignore +0 -26
- data/.rubocop.yml +0 -243
- data/.rubocop_todo.yml +0 -13
- data/.travis.yml +0 -5
- data/CHANGELOG.md +0 -45
- data/CODE_OF_CONDUCT.md +0 -74
- data/Guardfile +0 -58
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -8
- data/lib/generators/wcc/USAGE +0 -24
- data/lib/generators/wcc/model_generator.rb +0 -90
- data/lib/generators/wcc/templates/.keep +0 -0
- data/lib/generators/wcc/templates/Procfile +0 -3
- data/lib/generators/wcc/templates/contentful_shell_wrapper +0 -385
- data/lib/generators/wcc/templates/menu/generated_add_menus.ts +0 -90
- data/lib/generators/wcc/templates/menu/models/menu.rb +0 -23
- data/lib/generators/wcc/templates/menu/models/menu_button.rb +0 -23
- data/lib/generators/wcc/templates/page/generated_add_pages.ts +0 -50
- data/lib/generators/wcc/templates/page/models/page.rb +0 -23
- data/lib/generators/wcc/templates/release +0 -9
- data/lib/generators/wcc/templates/wcc_contentful.rb +0 -17
- data/lib/wcc/contentful/model/menu.rb +0 -7
- data/lib/wcc/contentful/model/menu_button.rb +0 -15
- data/lib/wcc/contentful/model/page.rb +0 -8
- data/lib/wcc/contentful/model/redirect.rb +0 -19
- data/lib/wcc/contentful/model_validators.rb +0 -115
- data/lib/wcc/contentful/model_validators/dsl.rb +0 -165
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
WCC::Contentful::Sys =
|
4
|
+
Struct.new(
|
5
|
+
:id,
|
6
|
+
:type,
|
7
|
+
:locale,
|
8
|
+
:space,
|
9
|
+
:created_at,
|
10
|
+
:updated_at,
|
11
|
+
:revision,
|
12
|
+
:context
|
13
|
+
) do
|
14
|
+
|
15
|
+
ATTRIBUTES = %i[
|
16
|
+
id
|
17
|
+
type
|
18
|
+
locale
|
19
|
+
space
|
20
|
+
created_at
|
21
|
+
updated_at
|
22
|
+
revision
|
23
|
+
context
|
24
|
+
].freeze
|
25
|
+
|
26
|
+
undef []=
|
27
|
+
ATTRIBUTES.each { |a| __send__(:undef_method, "#{a}=") }
|
28
|
+
end
|
data/wcc-contentful.gemspec
CHANGED
@@ -10,9 +10,9 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ['Watermark Dev']
|
11
11
|
spec.email = ['dev@watermark.org']
|
12
12
|
|
13
|
-
spec.summary = File.readlines('README.md').join
|
14
|
-
spec.description = 'Contentful API wrapper library
|
15
|
-
spec.homepage = 'https://github.com/watermarkchurch/wcc-contentful'
|
13
|
+
spec.summary = File.readlines(File.expand_path('README.md', __dir__)).join
|
14
|
+
spec.description = 'Contentful API wrapper library exposing an ActiveRecord-like interface'
|
15
|
+
spec.homepage = 'https://github.com/watermarkchurch/wcc-contentful/wcc-contentful'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.required_ruby_version = '>= 2.3'
|
@@ -29,15 +29,9 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
31
|
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.3.0'
|
32
|
-
spec.add_development_dependency 'rubocop', '~> 0.52'
|
33
32
|
spec.add_development_dependency 'vcr', '~> 4.0'
|
34
33
|
spec.add_development_dependency 'webmock', '~> 3.0'
|
35
34
|
|
36
|
-
# Makes testing easy via `bundle exec guard`
|
37
|
-
spec.add_development_dependency 'guard', '~> 2.14'
|
38
|
-
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
39
|
-
spec.add_development_dependency 'guard-rubocop', '~> 1.3.0'
|
40
|
-
|
41
35
|
# for generators
|
42
36
|
spec.add_development_dependency 'generator_spec', '~> 0.9.4'
|
43
37
|
spec.add_development_dependency 'rails', '~> 5.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wcc-contentful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.pre.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.3.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0.52'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0.52'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: vcr
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,48 +108,6 @@ dependencies:
|
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '3.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: guard
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '2.14'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '2.14'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: guard-rspec
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '4.7'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '4.7'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: guard-rubocop
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 1.3.0
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 1.3.0
|
167
111
|
- !ruby/object:Gem::Dependency
|
168
112
|
name: generator_spec
|
169
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -366,47 +310,26 @@ dependencies:
|
|
366
310
|
- - "~>"
|
367
311
|
- !ruby/object:Gem::Version
|
368
312
|
version: 0.3.1
|
369
|
-
description: Contentful API wrapper library
|
313
|
+
description: Contentful API wrapper library exposing an ActiveRecord-like interface
|
370
314
|
email:
|
371
315
|
- dev@watermark.org
|
372
316
|
executables: []
|
373
317
|
extensions: []
|
374
318
|
extra_rdoc_files: []
|
375
319
|
files:
|
376
|
-
- ".circleci/config.yml"
|
377
|
-
- ".gitignore"
|
378
320
|
- ".rspec"
|
379
|
-
- ".rubocop.yml"
|
380
|
-
- ".rubocop_todo.yml"
|
381
|
-
- ".travis.yml"
|
382
|
-
- CHANGELOG.md
|
383
|
-
- CODE_OF_CONDUCT.md
|
384
321
|
- Gemfile
|
385
|
-
- Guardfile
|
386
|
-
- LICENSE.txt
|
387
322
|
- README.md
|
388
|
-
- Rakefile
|
389
323
|
- app/controllers/wcc/contentful/application_controller.rb
|
390
324
|
- app/controllers/wcc/contentful/webhook_controller.rb
|
391
325
|
- app/jobs/wcc/contentful/delayed_sync_job.rb
|
326
|
+
- app/jobs/wcc/contentful/webhook_enable_job.rb
|
392
327
|
- bin/console
|
393
328
|
- bin/rails
|
394
329
|
- bin/rspec
|
395
330
|
- bin/setup
|
396
331
|
- config/initializers/mime_types.rb
|
397
332
|
- config/routes.rb
|
398
|
-
- lib/generators/wcc/USAGE
|
399
|
-
- lib/generators/wcc/model_generator.rb
|
400
|
-
- lib/generators/wcc/templates/.keep
|
401
|
-
- lib/generators/wcc/templates/Procfile
|
402
|
-
- lib/generators/wcc/templates/contentful_shell_wrapper
|
403
|
-
- lib/generators/wcc/templates/menu/generated_add_menus.ts
|
404
|
-
- lib/generators/wcc/templates/menu/models/menu.rb
|
405
|
-
- lib/generators/wcc/templates/menu/models/menu_button.rb
|
406
|
-
- lib/generators/wcc/templates/page/generated_add_pages.ts
|
407
|
-
- lib/generators/wcc/templates/page/models/page.rb
|
408
|
-
- lib/generators/wcc/templates/release
|
409
|
-
- lib/generators/wcc/templates/wcc_contentful.rb
|
410
333
|
- lib/wcc/contentful.rb
|
411
334
|
- lib/wcc/contentful/client_ext.rb
|
412
335
|
- lib/wcc/contentful/configuration.rb
|
@@ -419,16 +342,14 @@ files:
|
|
419
342
|
- lib/wcc/contentful/helpers.rb
|
420
343
|
- lib/wcc/contentful/indexed_representation.rb
|
421
344
|
- lib/wcc/contentful/model.rb
|
422
|
-
- lib/wcc/contentful/model/menu.rb
|
423
|
-
- lib/wcc/contentful/model/menu_button.rb
|
424
|
-
- lib/wcc/contentful/model/page.rb
|
425
|
-
- lib/wcc/contentful/model/redirect.rb
|
426
345
|
- lib/wcc/contentful/model_builder.rb
|
427
|
-
- lib/wcc/contentful/
|
428
|
-
- lib/wcc/contentful/
|
346
|
+
- lib/wcc/contentful/model_methods.rb
|
347
|
+
- lib/wcc/contentful/model_singleton_methods.rb
|
429
348
|
- lib/wcc/contentful/rails.rb
|
349
|
+
- lib/wcc/contentful/services.rb
|
430
350
|
- lib/wcc/contentful/simple_client.rb
|
431
351
|
- lib/wcc/contentful/simple_client/http_adapter.rb
|
352
|
+
- lib/wcc/contentful/simple_client/management.rb
|
432
353
|
- lib/wcc/contentful/simple_client/response.rb
|
433
354
|
- lib/wcc/contentful/simple_client/typhoeus_adapter.rb
|
434
355
|
- lib/wcc/contentful/store.rb
|
@@ -437,9 +358,10 @@ files:
|
|
437
358
|
- lib/wcc/contentful/store/lazy_cache_store.rb
|
438
359
|
- lib/wcc/contentful/store/memory_store.rb
|
439
360
|
- lib/wcc/contentful/store/postgres_store.rb
|
361
|
+
- lib/wcc/contentful/sys.rb
|
440
362
|
- lib/wcc/contentful/version.rb
|
441
363
|
- wcc-contentful.gemspec
|
442
|
-
homepage: https://github.com/watermarkchurch/wcc-contentful
|
364
|
+
homepage: https://github.com/watermarkchurch/wcc-contentful/wcc-contentful
|
443
365
|
licenses:
|
444
366
|
- MIT
|
445
367
|
metadata: {}
|
@@ -454,34 +376,92 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
454
376
|
version: '2.3'
|
455
377
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
456
378
|
requirements:
|
457
|
-
- - "
|
379
|
+
- - ">"
|
458
380
|
- !ruby/object:Gem::Version
|
459
|
-
version:
|
381
|
+
version: 1.3.1
|
460
382
|
requirements: []
|
461
383
|
rubyforge_project:
|
462
384
|
rubygems_version: 2.6.11
|
463
385
|
signing_key:
|
464
386
|
specification_version: 4
|
465
|
-
summary: '
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
= WCC::Contentful
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
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:
|
407
|
+
{ slug: ''/some-slug'' }) # => #<WCC::Contentful::Model::Page:0x0000000005c71a78
|
408
|
+
@created_at=2018-04-16 18:41:17 UTC...> # Pass the preview flag to use the preview
|
409
|
+
client (must have set preview_token config param) preview_redirect = WCC::Contentful::Model::Redirect.find_by({
|
410
|
+
slug: ''draft-redirect'' }, preview: true) # => #<WCC::Contentful::Model::Redirect:0x0000000005d879ad
|
411
|
+
@created_at=2018-04-16 18:41:17 UTC...> preview_redirect_object.href # => ''http://www.somesite.com/slug-for-redirect''
|
412
|
+
``` See the {WCC::Contentful::Model} documentation for more details. ### Store
|
413
|
+
API The Store layer is used by the Model API to access Contentful data in a raw
|
414
|
+
form. The Store layer returns entries as hashes parsed from JSON, conforming to
|
415
|
+
the object structure returned from the Contentful CDN. The following examples show
|
416
|
+
how to use the Store API to retrieve raw data from the store: ```ruby store = WCC::Contentful::Services.instance.store
|
417
|
+
# => #<WCC::Contentful::Store::CDNAdapter:0x00007fb92a221498 store.find(''5FsqsbMECsM62e04U8sY4Y'')
|
418
|
+
# => {"sys"=> # ... # "fields"=> # ...} store.find_by(content_type: ''page'',
|
419
|
+
filter: { slug: ''/some-slug'' }) # => {"sys"=> # ... # "fields"=> # ...} query
|
420
|
+
= store.find_all(content_type: ''page'').eq(''group'', ''some-group'') # => #<WCC::Contentful::Store::CDNAdapter::Query:0x00007fa3d40b84f0
|
421
|
+
query.first # => {"sys"=> # ... # "fields"=> # ...} query.result # => #<Enumerator::Lazy:
|
422
|
+
...> query.result.force # => [{"sys"=> ...}, {"sys"=> ...}, ...] ``` See the {WCC::Contentful::Store}
|
423
|
+
documentation for more details. ### Direct CDN API (SimpleClient) The SimpleClient
|
424
|
+
is the bottom layer, and is used to get raw data directly from the Contentful CDN. It
|
425
|
+
handles response parsing and paging, but does not resolve links or transform the
|
426
|
+
result into a Model class. The following examples show how to use the SimpleClient
|
427
|
+
to retrieve data directly from the Contentful CDN: ```ruby client = WCC::Contentful::Services.instance.client
|
428
|
+
# => #<WCC::Contentful::SimpleClient::Cdn:0x00007fa3cde89310 response = client.entry(''5FsqsbMECsM62e04U8sY4Y'')
|
429
|
+
# => #<WCC::Contentful::SimpleClient::Response:0x00007fa3d103a4e0 response.body
|
430
|
+
# => "{\n \"sys\": {\n ... response.raw # => {"sys"=> # ... # "fields"=> # ...} client.asset(''5FsqsbMECsM62e04U8sY4Y'').raw
|
431
|
+
# => {"sys"=> # ... # "fields"=> # ...} response = client.entries(''fields.group''
|
432
|
+
=> ''some-group'', ''limit'' => 5) # => #<WCC::Contentful::SimpleClient::Response:0x00007fa3d103a4e0
|
433
|
+
response.count # => 99 response.first # => {"sys"=> # ... # "fields"=> # ...} response.items
|
434
|
+
=> #<Enumerator::Lazy: ...> response.items.count # Careful! This evaluates the
|
435
|
+
lazy iterator and gets all pages # => 99 response.includes # => {"4xNnFJ77egkSMEogE2yISa"=>
|
436
|
+
# {"sys"=> ...} # "6Fwukxxkxa6qQCC04WCaqg"=> # {"sys"=> ...} # ...} ``` The
|
437
|
+
client handles Paging automatically within the lazy iterator returned by #items.
|
438
|
+
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.
|
481
461
|
This project is intended to be a safe, welcoming space for collaboration, and contributors
|
482
462
|
are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org)
|
483
463
|
code of conduct. ## License The gem is available as open source under the terms
|
484
464
|
of the [MIT License](http://opensource.org/licenses/MIT). ## Code of Conduct Everyone
|
485
465
|
interacting in the WCC::Contentful project''s codebases, issue trackers, chat rooms
|
486
|
-
and mailing lists is expected to follow the [code of conduct](https://github.com/
|
466
|
+
and mailing lists is expected to follow the [code of conduct](https://github.com/watermarkchurch/wcc-contentful/blob/master/CODE_OF_CONDUCT.md).'
|
487
467
|
test_files: []
|
data/.circleci/config.yml
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
version: 2
|
2
|
-
jobs:
|
3
|
-
build:
|
4
|
-
docker:
|
5
|
-
- image: circleci/ruby:2.3.3-node
|
6
|
-
environment:
|
7
|
-
RAILS_ENV: test
|
8
|
-
POSTGRES_CONNECTION: postgresql://ubuntu:@127.0.0.1:5432/circle_ruby_test
|
9
|
-
- image: postgres:10
|
10
|
-
environment:
|
11
|
-
- POSTGRES_USER: ubuntu
|
12
|
-
- POSTGRES_DB: circle_ruby_test
|
13
|
-
steps:
|
14
|
-
- checkout
|
15
|
-
# Restore bundle cache
|
16
|
-
- restore_cache:
|
17
|
-
key: rails-{{ checksum "wcc-contentful.gemspec" }}
|
18
|
-
|
19
|
-
# Bundle install dependencies
|
20
|
-
- run: bundle install --path /tmp/vendor/bundle
|
21
|
-
|
22
|
-
# Store bundle cache
|
23
|
-
- save_cache:
|
24
|
-
key: rails-{{ checksum "wcc-contentful.gemspec" }}
|
25
|
-
paths:
|
26
|
-
- /tmp/vendor/bundle
|
27
|
-
|
28
|
-
# run Danger
|
29
|
-
# - type: shell
|
30
|
-
# command: |
|
31
|
-
# bundle exec danger
|
32
|
-
|
33
|
-
# run rubocop
|
34
|
-
- type: shell
|
35
|
-
command: |
|
36
|
-
bundle exec rubocop
|
37
|
-
|
38
|
-
# Run rspec in parallel
|
39
|
-
- type: shell
|
40
|
-
command: |
|
41
|
-
bundle exec rspec --profile 10 \
|
42
|
-
--format RspecJunitFormatter \
|
43
|
-
--out test_results/rspec.xml \
|
44
|
-
--format documentation \
|
45
|
-
--order rand \
|
46
|
-
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
47
|
-
|
48
|
-
# Save test results for timing analysis
|
49
|
-
- store_test_results:
|
50
|
-
path: test_results
|
51
|
-
|
data/.gitignore
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/_yardoc/
|
4
|
-
/coverage/
|
5
|
-
/doc/
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/tmp/
|
9
|
-
|
10
|
-
# rspec failure tracking
|
11
|
-
.rspec_status
|
12
|
-
|
13
|
-
Gemfile.lock
|
14
|
-
|
15
|
-
# exports and error logs from contentful
|
16
|
-
contentful-export*
|
17
|
-
contentful-*-error-log-*
|
18
|
-
|
19
|
-
# User local env
|
20
|
-
.envrc
|
21
|
-
.env*
|
22
|
-
|
23
|
-
node_modules
|
24
|
-
|
25
|
-
log/
|
26
|
-
tmp/
|
data/.rubocop.yml
DELETED
@@ -1,243 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
|
-
AllCops:
|
4
|
-
DisplayCopNames: true
|
5
|
-
TargetRubyVersion: 2.3
|
6
|
-
Exclude:
|
7
|
-
# generated by rails/binstubs
|
8
|
-
- 'bin/**/*'
|
9
|
-
|
10
|
-
# auto generated by rails
|
11
|
-
|
12
|
-
# Config files
|
13
|
-
- 'Guardfile'
|
14
|
-
- 'Dangerfile'
|
15
|
-
|
16
|
-
# 3rd party
|
17
|
-
- 'vendor/**/*'
|
18
|
-
|
19
|
-
# generator templates
|
20
|
-
- '**/templates/**/*'
|
21
|
-
- 'tmp/**/*'
|
22
|
-
|
23
|
-
# dummy app for testing
|
24
|
-
- 'spec/dummy/**/*'
|
25
|
-
|
26
|
-
Style/Documentation:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
Style/BlockDelimiters:
|
30
|
-
Exclude:
|
31
|
-
# we like the `let(:foo) {}` syntax in specs
|
32
|
-
- 'spec/**/*.rb'
|
33
|
-
|
34
|
-
Style/ClassAndModuleChildren:
|
35
|
-
EnforcedStyle: compact
|
36
|
-
Exclude:
|
37
|
-
- 'lib/wcc/contentful/version.rb'
|
38
|
-
# Generators need to define the "Wcc" module so it doesnt get underscored.
|
39
|
-
- 'lib/generators/**/*.rb'
|
40
|
-
|
41
|
-
Style/FormatStringToken:
|
42
|
-
EnforcedStyle: template
|
43
|
-
|
44
|
-
Metrics/BlockLength:
|
45
|
-
Exclude:
|
46
|
-
# config files where we expect long blocks
|
47
|
-
- 'danger-wcc.gemspec'
|
48
|
-
# spec files that might have a big describe
|
49
|
-
- 'spec/**/*.rb'
|
50
|
-
# dsl files https://stackoverflow.com/a/41187163
|
51
|
-
|
52
|
-
Metrics/CyclomaticComplexity:
|
53
|
-
Enabled: false
|
54
|
-
|
55
|
-
Metrics/AbcSize:
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
Metrics/PerceivedComplexity:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
Metrics/BlockLength:
|
62
|
-
Enabled: false
|
63
|
-
|
64
|
-
Metrics/MethodLength:
|
65
|
-
Enabled: false
|
66
|
-
|
67
|
-
Metrics/ClassLength:
|
68
|
-
Enabled: false
|
69
|
-
|
70
|
-
Metrics/ModuleLength:
|
71
|
-
Exclude:
|
72
|
-
- 'spec/**/*.rb'
|
73
|
-
|
74
|
-
Performance/UnfreezeString:
|
75
|
-
Exclude:
|
76
|
-
- 'spec/**/*.rb'
|
77
|
-
|
78
|
-
Style/BracesAroundHashParameters:
|
79
|
-
Enabled: false
|
80
|
-
|
81
|
-
Lint/AssignmentInCondition:
|
82
|
-
Enabled: false
|
83
|
-
|
84
|
-
Lint/AmbiguousBlockAssociation:
|
85
|
-
Exclude:
|
86
|
-
- 'spec/generators/**/*.rb'
|
87
|
-
|
88
|
-
Style/EmptyMethod:
|
89
|
-
EnforcedStyle: expanded
|
90
|
-
|
91
|
-
Style/Alias:
|
92
|
-
EnforcedStyle: prefer_alias_method
|
93
|
-
|
94
|
-
Style/NumericPredicate:
|
95
|
-
EnforcedStyle: comparison
|
96
|
-
|
97
|
-
Style/RegexpLiteral:
|
98
|
-
Enabled: false
|
99
|
-
|
100
|
-
Style/ModuleFunction:
|
101
|
-
EnforcedStyle: extend_self
|
102
|
-
|
103
|
-
# Danger uses the 'fail' keyword for reporting errors
|
104
|
-
Style/SignalException:
|
105
|
-
Enabled: false
|
106
|
-
|
107
|
-
Layout/AlignParameters:
|
108
|
-
EnforcedStyle: with_fixed_indentation
|
109
|
-
|
110
|
-
Layout/IndentHash:
|
111
|
-
EnforcedStyle: consistent
|
112
|
-
|
113
|
-
Layout/AlignHash:
|
114
|
-
# allow coder to get around alignment rules by explicitly defining the hash param
|
115
|
-
EnforcedLastArgumentHashStyle: ignore_explicit
|
116
|
-
|
117
|
-
Layout/MultilineMethodCallIndentation:
|
118
|
-
EnforcedStyle: indented
|
119
|
-
|
120
|
-
Layout/MultilineOperationIndentation:
|
121
|
-
EnforcedStyle: indented
|
122
|
-
|
123
|
-
|
124
|
-
# These are all the cops that are disabled in the default configuration.
|
125
|
-
|
126
|
-
Layout/FirstArrayElementLineBreak:
|
127
|
-
Description: >-
|
128
|
-
Checks for a line break before the first element in a
|
129
|
-
multi-line array.
|
130
|
-
Enabled: true
|
131
|
-
|
132
|
-
Layout/FirstHashElementLineBreak:
|
133
|
-
Description: >-
|
134
|
-
Checks for a line break before the first element in a
|
135
|
-
multi-line hash.
|
136
|
-
Enabled: true
|
137
|
-
|
138
|
-
Layout/FirstMethodArgumentLineBreak:
|
139
|
-
Description: >-
|
140
|
-
Checks for a line break before the first argument in a
|
141
|
-
multi-line method call.
|
142
|
-
Enabled: false
|
143
|
-
|
144
|
-
Layout/FirstMethodParameterLineBreak:
|
145
|
-
Description: >-
|
146
|
-
Checks for a line break before the first parameter in a
|
147
|
-
multi-line method parameter definition.
|
148
|
-
Enabled: true
|
149
|
-
|
150
|
-
Layout/MultilineAssignmentLayout:
|
151
|
-
Description: 'Check for a newline after the assignment operator in multi-line assignments.'
|
152
|
-
StyleGuide: '#indent-conditional-assignment'
|
153
|
-
Enabled: true
|
154
|
-
|
155
|
-
Lint/MissingCopEnableDirective:
|
156
|
-
Exclude:
|
157
|
-
- 'spec/fixtures/**/*'
|
158
|
-
|
159
|
-
Style/AutoResourceCleanup:
|
160
|
-
Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
|
161
|
-
Enabled: true
|
162
|
-
|
163
|
-
Style/CollectionMethods:
|
164
|
-
Description: 'Preferred collection methods.'
|
165
|
-
StyleGuide: '#map-find-select-reduce-size'
|
166
|
-
Enabled: true
|
167
|
-
|
168
|
-
Style/Copyright:
|
169
|
-
Description: 'Include a copyright notice in each file before any code.'
|
170
|
-
Enabled: false
|
171
|
-
|
172
|
-
Style/DocumentationMethod:
|
173
|
-
Description: 'Public methods.'
|
174
|
-
Enabled: false
|
175
|
-
Exclude:
|
176
|
-
- 'spec/**/*'
|
177
|
-
- 'test/**/*'
|
178
|
-
|
179
|
-
Style/ImplicitRuntimeError:
|
180
|
-
Description: >-
|
181
|
-
Use `raise` or `fail` with an explicit exception class and
|
182
|
-
message, rather than just a message.
|
183
|
-
Enabled: true
|
184
|
-
|
185
|
-
Style/InlineComment:
|
186
|
-
Description: 'Avoid trailing inline comments.'
|
187
|
-
Enabled: true
|
188
|
-
|
189
|
-
|
190
|
-
Style/Lambda:
|
191
|
-
EnforcedStyle: literal
|
192
|
-
|
193
|
-
Style/MethodCallWithArgsParentheses:
|
194
|
-
Description: 'Use parentheses for method calls with arguments.'
|
195
|
-
StyleGuide: '#method-invocation-parens'
|
196
|
-
Enabled: false
|
197
|
-
|
198
|
-
Style/MethodCalledOnDoEndBlock:
|
199
|
-
Description: 'Avoid chaining a method call on a do...end block.'
|
200
|
-
StyleGuide: '#single-line-blocks'
|
201
|
-
Enabled: true
|
202
|
-
Exclude:
|
203
|
-
- 'spec/**/*'
|
204
|
-
|
205
|
-
Style/MissingElse:
|
206
|
-
Description: >-
|
207
|
-
Require if/case expressions to have an else branches.
|
208
|
-
If enabled, it is recommended that
|
209
|
-
Style/UnlessElse and Style/EmptyElse be enabled.
|
210
|
-
This will conflict with Style/EmptyElse if
|
211
|
-
Style/EmptyElse is configured to style "both"
|
212
|
-
Enabled: false
|
213
|
-
EnforcedStyle: both
|
214
|
-
SupportedStyles:
|
215
|
-
# if - warn when an if expression is missing an else branch
|
216
|
-
# case - warn when a case expression is missing an else branch
|
217
|
-
# both - warn when an if or case expression is missing an else branch
|
218
|
-
- if
|
219
|
-
- case
|
220
|
-
- both
|
221
|
-
|
222
|
-
Style/OptionHash:
|
223
|
-
Description: "Don't use option hashes when you can use keyword arguments."
|
224
|
-
Enabled: false
|
225
|
-
|
226
|
-
Style/ReturnNil:
|
227
|
-
Description: 'Use return instead of return nil.'
|
228
|
-
Enabled: true
|
229
|
-
|
230
|
-
Style/Send:
|
231
|
-
Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
|
232
|
-
StyleGuide: '#prefer-public-send'
|
233
|
-
Enabled: true
|
234
|
-
Exclude:
|
235
|
-
- 'spec/**/*'
|
236
|
-
|
237
|
-
Style/StringMethods:
|
238
|
-
Description: 'Checks if configured preferred methods are used over non-preferred.'
|
239
|
-
Enabled: false
|
240
|
-
|
241
|
-
Style/SingleLineBlockParams:
|
242
|
-
Description: 'Enforces the names of some block params.'
|
243
|
-
Enabled: false
|