wcc-contentful 1.2.0 → 1.3.1
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.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/app/controllers/wcc/contentful/webhook_controller.rb +2 -0
- data/lib/tasks/download_schema.rake +1 -1
- data/lib/wcc/contentful/configuration.rb +37 -18
- data/lib/wcc/contentful/downloads_schema.rb +5 -4
- data/lib/wcc/contentful/engine.rb +2 -4
- data/lib/wcc/contentful/event.rb +2 -3
- data/lib/wcc/contentful/exceptions.rb +2 -3
- data/lib/wcc/contentful/indexed_representation.rb +2 -6
- data/lib/wcc/contentful/instrumentation.rb +2 -1
- data/lib/wcc/contentful/link.rb +1 -3
- data/lib/wcc/contentful/link_visitor.rb +2 -4
- data/lib/wcc/contentful/middleware/store/caching_middleware.rb +4 -8
- data/lib/wcc/contentful/middleware/store.rb +4 -6
- data/lib/wcc/contentful/model_api.rb +3 -5
- data/lib/wcc/contentful/model_builder.rb +5 -4
- data/lib/wcc/contentful/model_methods.rb +10 -12
- data/lib/wcc/contentful/model_singleton_methods.rb +1 -1
- data/lib/wcc/contentful/rich_text/node.rb +1 -3
- data/lib/wcc/contentful/rich_text.rb +1 -1
- data/lib/wcc/contentful/rspec.rb +1 -3
- data/lib/wcc/contentful/services.rb +9 -0
- data/lib/wcc/contentful/simple_client/cdn.rb +126 -0
- data/lib/wcc/contentful/simple_client/preview.rb +17 -0
- data/lib/wcc/contentful/simple_client/response.rb +24 -19
- data/lib/wcc/contentful/simple_client.rb +13 -118
- data/lib/wcc/contentful/store/base.rb +19 -27
- data/lib/wcc/contentful/store/cdn_adapter.rb +1 -1
- data/lib/wcc/contentful/store/factory.rb +1 -1
- data/lib/wcc/contentful/store/memory_store.rb +10 -7
- data/lib/wcc/contentful/store/postgres_store.rb +52 -42
- data/lib/wcc/contentful/store/query.rb +2 -2
- data/lib/wcc/contentful/store/rspec_examples/include_param.rb +6 -4
- data/lib/wcc/contentful/store/rspec_examples/operators.rb +1 -1
- data/lib/wcc/contentful/sync_engine.rb +58 -34
- data/lib/wcc/contentful/sys.rb +2 -1
- data/lib/wcc/contentful/test/double.rb +3 -5
- data/lib/wcc/contentful/test/factory.rb +4 -6
- data/lib/wcc/contentful/version.rb +1 -1
- data/lib/wcc/contentful.rb +9 -12
- data/wcc-contentful.gemspec +5 -5
- metadata +37 -30
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: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -136,20 +136,6 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
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
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: simplecov
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -466,7 +452,9 @@ files:
|
|
466
452
|
- lib/wcc/contentful/rspec.rb
|
467
453
|
- lib/wcc/contentful/services.rb
|
468
454
|
- lib/wcc/contentful/simple_client.rb
|
455
|
+
- lib/wcc/contentful/simple_client/cdn.rb
|
469
456
|
- lib/wcc/contentful/simple_client/management.rb
|
457
|
+
- lib/wcc/contentful/simple_client/preview.rb
|
470
458
|
- lib/wcc/contentful/simple_client/response.rb
|
471
459
|
- lib/wcc/contentful/simple_client/typhoeus_adapter.rb
|
472
460
|
- lib/wcc/contentful/store.rb
|
@@ -503,7 +491,8 @@ homepage: https://github.com/watermarkchurch/wcc-contentful/wcc-contentful
|
|
503
491
|
licenses:
|
504
492
|
- MIT
|
505
493
|
metadata:
|
506
|
-
documentation_uri: https://watermarkchurch.github.io/wcc-contentful/1.
|
494
|
+
documentation_uri: https://watermarkchurch.github.io/wcc-contentful/1.3/wcc-contentful
|
495
|
+
rubygems_mfa_required: 'true'
|
507
496
|
post_install_message:
|
508
497
|
rdoc_options: []
|
509
498
|
require_paths:
|
@@ -512,7 +501,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
512
501
|
requirements:
|
513
502
|
- - ">="
|
514
503
|
- !ruby/object:Gem::Version
|
515
|
-
version: '2.
|
504
|
+
version: '2.7'
|
516
505
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
517
506
|
requirements:
|
518
507
|
- - ">="
|
@@ -777,14 +766,19 @@ summary: '[](https://
|
|
777
766
|
step. However the gem is also capable of connecting to multiple spaces within the
|
778
767
|
same ruby process! You just have to create and initialize a namespace. The {WCC::Contentful::ModelAPI}
|
779
768
|
concern makes this straightforward. Start by creating your Namespace and including
|
780
|
-
the concern: ```ruby #
|
781
|
-
|
782
|
-
|
769
|
+
the concern: ```ruby # lib/my_second_space.rb # Note: This class must be in the
|
770
|
+
"lib" folder in :zeitwerk mode, otherwise Rails 6+ will unload all your constants
|
771
|
+
# that were created in the initializer. Your models which subclass this namespace
|
772
|
+
may reside in the app/models directory. class MySecondSpace include WCC::Contentful::ModelAPI
|
773
|
+
end # app/models/other_page.rb class OtherPage < MySecondSpace::Page end ``` Then
|
774
|
+
configure it in an initializer: ```ruby # config/initializers/my_second_space.rb
|
783
775
|
MySecondSpace.configure do |config| # Make sure to point to a different schema file
|
784
776
|
from your first space! config.schema_file = Rails.root.join(''db/second-contentful-schema.json'') config.access_token
|
785
777
|
= ENV[''SECOND_CONTENTFUL_ACCESS_TOKEN''] config.preview_token = ENV[''SECOND_CONTENTFUL_PREVIEW_ACCESS_TOKEN'']
|
786
778
|
config.space = ENV[''SECOND_CONTENTFUL_SPACE_ID''] config.environment = ENV[''CONTENTFUL_ENVIRONMENT'']
|
787
|
-
end
|
779
|
+
end # Ensure that models are reloaded in Rails development mode Rails.application.config.to_prepare
|
780
|
+
do MySecondSpace.reload! end ``` Finally, use it: ```ruby OtherPage.find(''1234'')
|
781
|
+
# GET https://cdn.contentful.com/spaces/other-space/environments/other-env/entries/1234
|
788
782
|
# => #<OtherPage:0x0000000005c71a78 @created_at=2018-04-16 18:41:17 UTC...> Page.find(''1234'')
|
789
783
|
# GET https://cdn.contentful.com/spaces/first-space/environments/first-env/entries/1234
|
790
784
|
# => #<Page:0x0000000001271b70 @created_at=2018-04-15 12:02:14 UTC...> ``` The
|
@@ -794,14 +788,27 @@ summary: '[](https://
|
|
794
788
|
preview_client = MySecondSpace.services.preview_client # => #<WCC::Contentful::SimpleClient::Preview:0x00007f888ccafa00
|
795
789
|
sync_engine = MySecondSpace.services.sync_engine # => #<WCC::Contentful::SyncEngine:0x00007f88960b6b40
|
796
790
|
``` Note that the above services are not accessible on {WCC::Contentful::Services.instance}
|
797
|
-
or via the {WCC::Contentful::ServiceAccessors}.
|
798
|
-
|
799
|
-
will
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
791
|
+
or via the {WCC::Contentful::ServiceAccessors}. #### Important Note when using
|
792
|
+
Zeitwerk with Rails 6+ When using Rails >= 6 with `config.autoloader = :zeitwerk`,
|
793
|
+
Rails will remove any models defined in `app/models` after initialization and then
|
794
|
+
load them again when they are referenced. If you `include WCC::Contentful::ModelAPI`
|
795
|
+
in a class defined inside the `app` directory, this will have the effect of deleting
|
796
|
+
all configuration that was set in the initializer as well as the constants generated
|
797
|
+
from your schema. This will result in one of two errors: * `NameError (uninitialized
|
798
|
+
constant MySecondSpace::MyContentType)` if you try to reference a subclass such
|
799
|
+
as `MyContentType < MySecondSpace::MyContentType` * `ArgumentError (Not yet configured!)`
|
800
|
+
if you try to `MySecondSpace.find(''xxxx'')` to load an Entry or Asset The solution
|
801
|
+
is to have your secondary namespace in a folder which is not in the `autoload_paths`.
|
802
|
+
We suggest using `lib`, which will work so long as you have not added the `lib`
|
803
|
+
folder to the `autoload_paths` as some uninformed StackOverflow answers suggest
|
804
|
+
you do. ### Using a sync store with a second space If you use something other
|
805
|
+
than the CDNAdapter with your second space, you will need to find a way to trigger
|
806
|
+
`MySecondSpace.services.sync_engine.next` to keep it up-to-date. The {WCC::Contentful::Engine}
|
807
|
+
will only manage the global SyncEngine configured by the global {WCC::Contentful.configure}. The
|
808
|
+
easiest way to do this is to set up your own Rails route to respond to Contentful
|
809
|
+
webhooks and then configure the second Contentful space to send webhooks to this
|
810
|
+
route. You could also do this by triggering it periodically in a background job
|
811
|
+
using Sidekiq and [sidekiq-scheduler](https://github.com/Moove-it/sidekiq-scheduler). ##
|
805
812
|
Development After checking out the repo, run `bin/setup` to install dependencies.
|
806
813
|
Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for
|
807
814
|
an interactive prompt that will allow you to experiment. ## Contributing Bug reports
|