consyncful 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +42 -0
- data/.rubocop_todo.yml +6 -14
- data/.ruby-version +1 -1
- data/Gemfile.lock +21 -22
- data/README.md +63 -17
- data/lib/consyncful/base.rb +6 -3
- data/lib/consyncful/item_mapper.rb +38 -20
- data/lib/consyncful/persisted_item.rb +2 -1
- data/lib/consyncful/railtie.rb +1 -0
- data/lib/consyncful/sync.rb +7 -4
- data/lib/consyncful/tasks/consyncful.rake +1 -1
- data/lib/consyncful/version.rb +1 -1
- data/lib/consyncful.rb +26 -15
- metadata +8 -8
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10b3daa6395ab09a3eefac1c3d6e8795530b346b8ce5d4d1248527e98719a785
|
4
|
+
data.tar.gz: f2948c392596ff652ae67f4153b0e407f73b5424315de19df348842f1ee1d181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b136cbf030b12667c3a590bb6361ec8b6aa6ac45fcb452af7401c116f926afb227ba02c31293ec3f55e084e96aaa428551358b39b6ec5d63d4f094d533a1e78
|
7
|
+
data.tar.gz: 3419eba7818aadf3f472fde9013a12043ac22227cd36562ae3c29e392bf73e65cb4525b9711aade7c1bd25460b8543b1b99d73517bd466ef04a2860340f5922e
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
ci_checks:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby:
|
15
|
+
- 2.7.5
|
16
|
+
- 3.0.3
|
17
|
+
- 3.1.1
|
18
|
+
mongodb:
|
19
|
+
- 4.2
|
20
|
+
- 4.4
|
21
|
+
- 5.0
|
22
|
+
|
23
|
+
name: Ruby ${{ matrix.ruby }} sample
|
24
|
+
|
25
|
+
steps:
|
26
|
+
- name: Checkout this repo
|
27
|
+
uses: actions/checkout@v2
|
28
|
+
|
29
|
+
- name: Install Ruby and Bundler
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
bundler-cache: true
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
|
35
|
+
- name: Start MongoDB
|
36
|
+
uses: supercharge/mongodb-github-action@1.7.0
|
37
|
+
with:
|
38
|
+
mongodb-version: ${{ matrix.mongodb }}
|
39
|
+
|
40
|
+
- name: Run tests
|
41
|
+
run: |
|
42
|
+
bundle exec rspec
|
data/.rubocop_todo.yml
CHANGED
@@ -1,27 +1,20 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2022-05-03 14:45:03 +1200 using RuboCop version 0.79.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
# Cop supports --auto-correct.
|
11
|
-
# Configuration parameters: AllowInHeredoc.
|
12
|
-
Layout/TrailingWhitespace:
|
13
|
-
Exclude:
|
14
|
-
- 'lib/consyncful/item_mapper.rb'
|
15
|
-
|
16
|
-
# Offense count: 1
|
9
|
+
# Offense count: 2
|
17
10
|
Metrics/AbcSize:
|
18
11
|
Max: 19
|
19
12
|
|
20
|
-
# Offense count:
|
13
|
+
# Offense count: 12
|
21
14
|
# Configuration parameters: CountComments, ExcludedMethods.
|
22
15
|
# ExcludedMethods: refine
|
23
16
|
Metrics/BlockLength:
|
24
|
-
Max:
|
17
|
+
Max: 211
|
25
18
|
|
26
19
|
# Offense count: 3
|
27
20
|
# Cop supports --auto-correct.
|
@@ -32,15 +25,14 @@ Style/ClassAndModuleChildren:
|
|
32
25
|
- 'lib/consyncful/railtie.rb'
|
33
26
|
- 'spec/consyncful/base_spec.rb'
|
34
27
|
|
35
|
-
# Offense count:
|
28
|
+
# Offense count: 1
|
36
29
|
Style/Documentation:
|
37
30
|
Exclude:
|
38
31
|
- 'spec/**/*'
|
39
32
|
- 'test/**/*'
|
40
33
|
- 'lib/consyncful.rb'
|
41
|
-
- 'lib/consyncful/railtie.rb'
|
42
34
|
|
43
|
-
# Offense count:
|
35
|
+
# Offense count: 57
|
44
36
|
# Cop supports --auto-correct.
|
45
37
|
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
46
38
|
# URISchemes: http, https
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
consyncful (0.
|
4
|
+
consyncful (0.7.0)
|
5
5
|
contentful (>= 2.11.1, < 3.0.0)
|
6
6
|
hooks (>= 0.4.1)
|
7
7
|
mongoid (>= 7.0.2, < 8.0.0)
|
@@ -10,27 +10,26 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activemodel (
|
14
|
-
activesupport (=
|
15
|
-
activesupport (
|
13
|
+
activemodel (7.0.2.4)
|
14
|
+
activesupport (= 7.0.2.4)
|
15
|
+
activesupport (7.0.2.4)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>=
|
18
|
-
minitest (
|
19
|
-
tzinfo (~>
|
20
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
21
20
|
addressable (2.7.0)
|
22
21
|
public_suffix (>= 2.0.2, < 5.0)
|
23
22
|
ast (2.4.0)
|
24
|
-
bson (4.
|
25
|
-
concurrent-ruby (1.1.
|
26
|
-
contentful (2.
|
23
|
+
bson (4.15.0)
|
24
|
+
concurrent-ruby (1.1.10)
|
25
|
+
contentful (2.16.0)
|
27
26
|
http (> 0.8, < 5.0)
|
28
27
|
multi_json (~> 1)
|
29
28
|
database_cleaner (1.8.3)
|
30
29
|
diff-lcs (1.3)
|
31
30
|
domain_name (0.5.20190701)
|
32
31
|
unf (>= 0.0.5, < 1.0.0)
|
33
|
-
ffi (1.
|
32
|
+
ffi (1.15.0)
|
34
33
|
ffi-compiler (1.0.1)
|
35
34
|
ffi (>= 1.0.0)
|
36
35
|
rake
|
@@ -46,15 +45,16 @@ GEM
|
|
46
45
|
http-form_data (2.3.0)
|
47
46
|
http-parser (1.2.3)
|
48
47
|
ffi-compiler (>= 1.0, < 2.0)
|
49
|
-
i18n (1.
|
48
|
+
i18n (1.10.0)
|
50
49
|
concurrent-ruby (~> 1.0)
|
51
50
|
jaro_winkler (1.5.4)
|
52
|
-
minitest (5.
|
53
|
-
mongo (2.
|
51
|
+
minitest (5.15.0)
|
52
|
+
mongo (2.17.1)
|
54
53
|
bson (>= 4.8.2, < 5.0.0)
|
55
|
-
mongoid (7.
|
56
|
-
activemodel (>= 5.1, <
|
54
|
+
mongoid (7.4.0)
|
55
|
+
activemodel (>= 5.1, < 7.1, != 7.0.0)
|
57
56
|
mongo (>= 2.10.5, < 3.0.0)
|
57
|
+
ruby2_keywords (~> 0.0.5)
|
58
58
|
multi_json (1.15.0)
|
59
59
|
parallel (1.19.1)
|
60
60
|
parser (2.7.0.2)
|
@@ -83,15 +83,14 @@ GEM
|
|
83
83
|
ruby-progressbar (~> 1.7)
|
84
84
|
unicode-display_width (>= 1.4.0, < 1.7)
|
85
85
|
ruby-progressbar (1.10.1)
|
86
|
-
|
87
|
-
tzinfo (
|
88
|
-
|
86
|
+
ruby2_keywords (0.0.5)
|
87
|
+
tzinfo (2.0.4)
|
88
|
+
concurrent-ruby (~> 1.0)
|
89
89
|
uber (0.0.15)
|
90
90
|
unf (0.1.4)
|
91
91
|
unf_ext
|
92
92
|
unf_ext (0.0.7.7)
|
93
93
|
unicode-display_width (1.6.1)
|
94
|
-
zeitwerk (2.4.2)
|
95
94
|
|
96
95
|
PLATFORMS
|
97
96
|
ruby
|
@@ -105,4 +104,4 @@ DEPENDENCIES
|
|
105
104
|
rubocop (= 0.79.0)
|
106
105
|
|
107
106
|
BUNDLED WITH
|
108
|
-
2.
|
107
|
+
2.3.7
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Consyncful
|
1
|
+
# Consyncful
|
2
2
|
|
3
3
|
Contentful -> local database synchronisation for Rails
|
4
4
|
|
@@ -8,10 +8,21 @@ Once the content is available locally, finding and interact with contentful data
|
|
8
8
|
|
9
9
|
This gem doesn't provide any integration with the management API, or any way to update Contentful models from the local store. It is strictly read only.
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
- [Installation](#installation)
|
12
|
+
- [Usage](#usage)
|
13
|
+
- [Creating contentful models in your Rails app](#creating-contentful-models-in-your-rails-app)
|
14
|
+
- [Synchronizing contentful data](#synchronizing-contentful-data)
|
15
|
+
- [Finding and interacting with models](#finding-and-interacting-with-models)
|
16
|
+
- [Querying](#querying)
|
17
|
+
- [References](#references)
|
18
|
+
- [Finding entries from different content types](#finding-entries-from-different-content-types)
|
19
|
+
- [Sync callbacks](#sync-callbacks)
|
20
|
+
- [Using Locales for specific fields](#using-locales-for-specific-fields)
|
21
|
+
- [Configuring what Mongo database Consyncful uses](#configuring-what-mongo-database-consyncful-uses)
|
22
|
+
- [Why do I have to use MongoDB?](#why-do-i-have-to-use-mongodb)
|
23
|
+
- [Development](#development)
|
24
|
+
- [Contributing](#contributing)
|
25
|
+
- [License](#license)
|
15
26
|
|
16
27
|
## Installation
|
17
28
|
|
@@ -32,17 +43,17 @@ If you don't already use Mongoid, generate a mongoid.yml by running:
|
|
32
43
|
Add an initializer:
|
33
44
|
|
34
45
|
Consyncful uses [contentful.rb](https://github.com/contentful/contentful.rb); client options are as documented there.
|
35
|
-
```
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
```rb
|
47
|
+
Consyncful.configure do |config|
|
48
|
+
config.locale = 'en-NZ'
|
49
|
+
config.contentful_client_options = {
|
50
|
+
api_url: 'cdn.contentful.com',
|
51
|
+
space: 'space_id',
|
52
|
+
access_token: 'ACCESS TOKEN',
|
53
|
+
environment: 'master', # optional
|
54
|
+
logger: Logger.new(STDOUT) # optional for debugging
|
55
|
+
}
|
56
|
+
end
|
46
57
|
```
|
47
58
|
|
48
59
|
## Usage
|
@@ -129,7 +140,7 @@ instance.other_things.in_order # ordered the same as in Contentful
|
|
129
140
|
Because all Contentful models are stored as polymorphic subtypes of `Consyncful::Base`, you can query all entries without knowing what type you are looking for:
|
130
141
|
|
131
142
|
```ruby
|
132
|
-
|
143
|
+
Consyncful::Base.where(title: 'a title') # [ #<ModelName>, #<OtherModelName> ]
|
133
144
|
```
|
134
145
|
|
135
146
|
### Sync callbacks
|
@@ -154,6 +165,41 @@ end
|
|
154
165
|
|
155
166
|
If fields have multiple locales then the default locale will be mapped to the field name. Additional locales will have a suffix (lower snake case) on the field name. e.g title (default), title_mi_nz (New Zealand Maori mi-NZ)
|
156
167
|
|
168
|
+
### Sync specific contents using [Contentful Tag](https://www.contentful.com/help/tags/).
|
169
|
+
You can configure Consyncful to sync or ignore specific contents using Contentful Tag.
|
170
|
+
|
171
|
+
```rb
|
172
|
+
Consyncful.configure do |config|
|
173
|
+
# Any contents tagged with 'myTag' will be stored in the database.
|
174
|
+
# Other contents without 'myTag' would be ignored.
|
175
|
+
config.content_tags = ['myTag'] # defaults to []
|
176
|
+
end
|
177
|
+
```
|
178
|
+
|
179
|
+
Also, you can ignore contents with specific Tags.
|
180
|
+
|
181
|
+
```rb
|
182
|
+
Consyncful.configure do |config|
|
183
|
+
# Any contents tagged with 'ignoreTag' won't be stored in the database.
|
184
|
+
config.ignore_content_tags = ['ignoreTag'] # defaults to []
|
185
|
+
end
|
186
|
+
```
|
187
|
+
|
188
|
+
### Configuring what Mongo database Consyncful uses
|
189
|
+
|
190
|
+
You can also configure what Mongoid client Consyncful uses and the name of the collection the entries are stored under. This is useful if you want to have your consyncful data hosted in a different mongo database than your application-specific mongo database.
|
191
|
+
|
192
|
+
```rb
|
193
|
+
Consyncful.configure do |config|
|
194
|
+
config.mongo_client = :consyncful # defaults to :default (referencing the clients in mongoid.yml)
|
195
|
+
config.mongo_collection = 'contentful_models' # this is the default
|
196
|
+
end
|
197
|
+
```
|
198
|
+
|
199
|
+
### Why do I have to use MongoDB?
|
200
|
+
|
201
|
+
Consyncful currently only supports Mongoid ODM because models have dynamic schemas. And that's all we've had a chance to work out so far. The same pattern might be able to be extended to work with ActiveRecord, but having to migrate the local database as well as your contentful content type's seems tedious.
|
202
|
+
|
157
203
|
## Development
|
158
204
|
|
159
205
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/consyncful/base.rb
CHANGED
@@ -8,10 +8,11 @@ module Consyncful
|
|
8
8
|
include Mongoid::Document
|
9
9
|
include Mongoid::Attributes::Dynamic
|
10
10
|
|
11
|
-
store_in collection: 'contentful_models'
|
12
|
-
|
13
11
|
cattr_accessor :model_map
|
14
12
|
|
13
|
+
store_in collection: -> { Consyncful.configuration.mongo_collection },
|
14
|
+
client: -> { Consyncful.configuration.mongo_client }
|
15
|
+
|
15
16
|
def self.contentful_model_name(name)
|
16
17
|
self.model_map ||= {}
|
17
18
|
|
@@ -22,7 +23,9 @@ module Consyncful
|
|
22
23
|
def self.references_many(name)
|
23
24
|
has_and_belongs_to_many name.to_sym, class_name: 'Consyncful::Base', inverse_of: nil do
|
24
25
|
def in_order
|
25
|
-
_target.to_a.sort_by
|
26
|
+
_target.to_a.sort_by do |reference|
|
27
|
+
_base[foreign_key].index(reference.id)
|
28
|
+
end
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
@@ -13,11 +13,17 @@ module Consyncful
|
|
13
13
|
@item.is_a?(Contentful::DeletedEntry) || @item.is_a?(Contentful::DeletedAsset)
|
14
14
|
end
|
15
15
|
|
16
|
+
def excluded_by_tag?
|
17
|
+
return (Consyncful.configuration.content_tags & item_tag_ids).empty? if Consyncful.configuration.content_tags.any?
|
18
|
+
return (Consyncful.configuration.ignore_content_tags & item_tag_ids).any? if Consyncful.configuration.ignore_content_tags.any?
|
19
|
+
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
16
23
|
def type
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
'asset'
|
24
|
+
case @item.type
|
25
|
+
when 'Entry' then @item.content_type.id
|
26
|
+
when 'Asset' then 'asset'
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
@@ -36,14 +42,18 @@ module Consyncful
|
|
36
42
|
|
37
43
|
private
|
38
44
|
|
45
|
+
def item_tag_ids
|
46
|
+
return [] if @item.nil?
|
47
|
+
|
48
|
+
@item._metadata[:tags].map(&:id)
|
49
|
+
end
|
50
|
+
|
39
51
|
def generic_fields
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
fields[:synced_at] = Time.current
|
46
|
-
fields
|
52
|
+
{ created_at: @item.created_at,
|
53
|
+
updated_at: @item.updated_at,
|
54
|
+
revision: @item.revision,
|
55
|
+
contentful_type: type,
|
56
|
+
synced_at: Time.current }
|
47
57
|
end
|
48
58
|
|
49
59
|
def localized_fields(default_locale)
|
@@ -52,9 +62,10 @@ module Consyncful
|
|
52
62
|
@item.fields_with_locales.each do |field, value_with_locales|
|
53
63
|
value_with_locales.each do |locale_code, value|
|
54
64
|
next if value.is_a? Contentful::File # assets are handeled below
|
55
|
-
|
56
|
-
|
57
|
-
|
65
|
+
|
66
|
+
field_name = localized_field_name(field, locale_code, default_locale)
|
67
|
+
field_name, value = mapped_field_entry_for(field_name, value)
|
68
|
+
fields[field_name] = value
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
@@ -66,13 +77,20 @@ module Consyncful
|
|
66
77
|
files_by_locale = @item.raw.dig('fields', 'file') || {}
|
67
78
|
|
68
79
|
files_by_locale.each do |locale_code, details|
|
69
|
-
|
70
|
-
fields[
|
80
|
+
field_name = localized_field_name('file', locale_code, default_locale)
|
81
|
+
fields[field_name.to_sym] = details
|
71
82
|
end
|
72
83
|
|
73
84
|
fields
|
74
85
|
end
|
75
86
|
|
87
|
+
# Suffixes the field with the locale unless it's the default locale.
|
88
|
+
def localized_field_name(field, locale_code, default_locale)
|
89
|
+
return field if locale_code.to_s == default_locale.to_s
|
90
|
+
|
91
|
+
"#{field}_#{locale_code.to_s.underscore}".to_sym
|
92
|
+
end
|
93
|
+
|
76
94
|
def reference_value?(value)
|
77
95
|
single_reference?(value) || many_reference?(value)
|
78
96
|
end
|
@@ -85,14 +103,14 @@ module Consyncful
|
|
85
103
|
value.is_a?(Array) && single_reference?(value.first)
|
86
104
|
end
|
87
105
|
|
88
|
-
def
|
106
|
+
def mapped_field_entry_for(field, value)
|
89
107
|
if single_reference?(value)
|
90
|
-
|
108
|
+
[ActiveSupport::Inflector.foreign_key(field).to_sym, value.id]
|
91
109
|
elsif many_reference?(value)
|
92
110
|
ids_field_name = field.to_s.singularize + '_ids' # fk field name
|
93
|
-
|
111
|
+
[ids_field_name.to_sym, value.map(&:id)]
|
94
112
|
else
|
95
|
-
|
113
|
+
[field, value]
|
96
114
|
end
|
97
115
|
end
|
98
116
|
end
|
data/lib/consyncful/railtie.rb
CHANGED
data/lib/consyncful/sync.rb
CHANGED
@@ -19,6 +19,8 @@ module Consyncful
|
|
19
19
|
include Mongoid::Document
|
20
20
|
include Hooks
|
21
21
|
|
22
|
+
store_in client: -> { Consyncful.configuration.mongo_client }
|
23
|
+
|
22
24
|
define_hook :before_run
|
23
25
|
define_hook :after_run
|
24
26
|
|
@@ -100,10 +102,11 @@ module Consyncful
|
|
100
102
|
ids
|
101
103
|
end
|
102
104
|
|
103
|
-
def sync_item(
|
104
|
-
puts Rainbow("syncing: #{
|
105
|
-
PersistedItem.new(
|
106
|
-
|
105
|
+
def sync_item(item_mapper, stats)
|
106
|
+
puts Rainbow("syncing: #{item_mapper.id}").yellow
|
107
|
+
PersistedItem.new(item_mapper, id, stats).persist
|
108
|
+
|
109
|
+
item_mapper.id
|
107
110
|
end
|
108
111
|
end
|
109
112
|
end
|
@@ -19,7 +19,7 @@ namespace :consyncful do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
task update_model_names: [:environment] do
|
22
|
-
if
|
22
|
+
if Rails.autoloaders.zeitwerk_enabled?
|
23
23
|
Zeitwerk::Loader.eager_load_all
|
24
24
|
else
|
25
25
|
Rails.application.eager_load!
|
data/lib/consyncful/version.rb
CHANGED
data/lib/consyncful.rb
CHANGED
@@ -11,23 +11,24 @@ require 'consyncful/sync'
|
|
11
11
|
require 'consyncful/railtie' if defined?(Rails)
|
12
12
|
|
13
13
|
module Consyncful
|
14
|
-
|
15
|
-
attr_accessor :configuration
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.configure
|
19
|
-
self.configuration ||= Configuration.new
|
20
|
-
yield(configuration)
|
21
|
-
end
|
22
|
-
|
14
|
+
# Handles Rails configurations for Consynful
|
23
15
|
class Configuration
|
24
|
-
attr_accessor :contentful_client_options,
|
16
|
+
attr_accessor :contentful_client_options,
|
17
|
+
:locale,
|
18
|
+
:mongo_client,
|
19
|
+
:mongo_collection,
|
20
|
+
:content_tags,
|
21
|
+
:ignore_content_tags
|
25
22
|
|
26
23
|
def initialize
|
27
24
|
@contentful_client_options = {
|
28
25
|
api_url: 'cdn.contentful.com'
|
29
26
|
}
|
30
27
|
@locale = 'en-NZ'
|
28
|
+
@mongo_client = :default
|
29
|
+
@mongo_collection = 'contentful_models'
|
30
|
+
@content_tags = []
|
31
|
+
@ignore_content_tags = []
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -36,11 +37,21 @@ module Consyncful
|
|
36
37
|
api_url: 'cdn.contentful.com'
|
37
38
|
}.freeze
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
class << self
|
41
|
+
def configuration
|
42
|
+
@configuration ||= Configuration.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def configure
|
46
|
+
yield configuration
|
47
|
+
end
|
48
|
+
|
49
|
+
def client
|
50
|
+
@client ||= begin
|
51
|
+
options = Consyncful.configuration.contentful_client_options
|
52
|
+
options.reverse_merge!(DEFAULT_CLIENT_OPTIONS)
|
53
|
+
Contentful::Client.new(options)
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consyncful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Anastasiadis-Gray
|
8
8
|
- Montgomery Anderson
|
9
9
|
- Greg Rogan
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-05-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description:
|
153
|
+
description:
|
154
154
|
email:
|
155
155
|
- andy@boost.co.nz
|
156
156
|
- montgomery@boost.co.nz
|
@@ -159,12 +159,12 @@ executables: []
|
|
159
159
|
extensions: []
|
160
160
|
extra_rdoc_files: []
|
161
161
|
files:
|
162
|
+
- ".github/workflows/ci.yml"
|
162
163
|
- ".gitignore"
|
163
164
|
- ".rspec"
|
164
165
|
- ".rubocop.yml"
|
165
166
|
- ".rubocop_todo.yml"
|
166
167
|
- ".ruby-version"
|
167
|
-
- ".travis.yml"
|
168
168
|
- Gemfile
|
169
169
|
- Gemfile.lock
|
170
170
|
- LICENSE.txt
|
@@ -188,7 +188,7 @@ homepage: https://github.com/boost/consyncful
|
|
188
188
|
licenses:
|
189
189
|
- MIT
|
190
190
|
metadata: {}
|
191
|
-
post_install_message:
|
191
|
+
post_install_message:
|
192
192
|
rdoc_options: []
|
193
193
|
require_paths:
|
194
194
|
- lib
|
@@ -203,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
207
|
-
signing_key:
|
206
|
+
rubygems_version: 3.2.32
|
207
|
+
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: Contentful to local database synchronisation for Rails
|
210
210
|
test_files: []
|