consyncful 0.6.2 → 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 +14 -14
- data/README.md +21 -1
- data/lib/consyncful/item_mapper.rb +13 -0
- data/lib/consyncful/persisted_item.rb +2 -1
- data/lib/consyncful/sync.rb +5 -4
- data/lib/consyncful/version.rb +1 -1
- data/lib/consyncful.rb +8 -2
- metadata +4 -4
- 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,19 +10,18 @@ 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
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
19
19
|
tzinfo (~> 2.0)
|
20
|
-
zeitwerk (~> 2.3)
|
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.
|
23
|
+
bson (4.15.0)
|
24
|
+
concurrent-ruby (1.1.10)
|
26
25
|
contentful (2.16.0)
|
27
26
|
http (> 0.8, < 5.0)
|
28
27
|
multi_json (~> 1)
|
@@ -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,6 +83,7 @@ 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
|
+
ruby2_keywords (0.0.5)
|
86
87
|
tzinfo (2.0.4)
|
87
88
|
concurrent-ruby (~> 1.0)
|
88
89
|
uber (0.0.15)
|
@@ -90,7 +91,6 @@ GEM
|
|
90
91
|
unf_ext
|
91
92
|
unf_ext (0.0.7.7)
|
92
93
|
unicode-display_width (1.6.1)
|
93
|
-
zeitwerk (2.4.2)
|
94
94
|
|
95
95
|
PLATFORMS
|
96
96
|
ruby
|
@@ -104,4 +104,4 @@ DEPENDENCIES
|
|
104
104
|
rubocop (= 0.79.0)
|
105
105
|
|
106
106
|
BUNDLED WITH
|
107
|
-
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
|
|
@@ -165,6 +165,26 @@ end
|
|
165
165
|
|
166
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)
|
167
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
|
+
|
168
188
|
### Configuring what Mongo database Consyncful uses
|
169
189
|
|
170
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.
|
@@ -13,6 +13,13 @@ 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
24
|
case @item.type
|
18
25
|
when 'Entry' then @item.content_type.id
|
@@ -35,6 +42,12 @@ module Consyncful
|
|
35
42
|
|
36
43
|
private
|
37
44
|
|
45
|
+
def item_tag_ids
|
46
|
+
return [] if @item.nil?
|
47
|
+
|
48
|
+
@item._metadata[:tags].map(&:id)
|
49
|
+
end
|
50
|
+
|
38
51
|
def generic_fields
|
39
52
|
{ created_at: @item.created_at,
|
40
53
|
updated_at: @item.updated_at,
|
data/lib/consyncful/sync.rb
CHANGED
@@ -102,10 +102,11 @@ module Consyncful
|
|
102
102
|
ids
|
103
103
|
end
|
104
104
|
|
105
|
-
def sync_item(
|
106
|
-
puts Rainbow("syncing: #{
|
107
|
-
PersistedItem.new(
|
108
|
-
|
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
|
109
110
|
end
|
110
111
|
end
|
111
112
|
end
|
data/lib/consyncful/version.rb
CHANGED
data/lib/consyncful.rb
CHANGED
@@ -13,8 +13,12 @@ require 'consyncful/railtie' if defined?(Rails)
|
|
13
13
|
module Consyncful
|
14
14
|
# Handles Rails configurations for Consynful
|
15
15
|
class Configuration
|
16
|
-
attr_accessor :contentful_client_options,
|
17
|
-
:
|
16
|
+
attr_accessor :contentful_client_options,
|
17
|
+
:locale,
|
18
|
+
:mongo_client,
|
19
|
+
:mongo_collection,
|
20
|
+
:content_tags,
|
21
|
+
:ignore_content_tags
|
18
22
|
|
19
23
|
def initialize
|
20
24
|
@contentful_client_options = {
|
@@ -23,6 +27,8 @@ module Consyncful
|
|
23
27
|
@locale = 'en-NZ'
|
24
28
|
@mongo_client = :default
|
25
29
|
@mongo_collection = 'contentful_models'
|
30
|
+
@content_tags = []
|
31
|
+
@ignore_content_tags = []
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-05-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -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
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
206
|
+
rubygems_version: 3.2.32
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: Contentful to local database synchronisation for Rails
|