consyncful 0.7.0 → 0.7.1
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 +3 -0
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +20 -10
- data/Gemfile.lock +35 -24
- data/README.md +13 -0
- data/consyncful.gemspec +13 -9
- data/lib/consyncful/item_mapper.rb +13 -3
- data/lib/consyncful/version.rb +1 -1
- data/lib/consyncful.rb +3 -1
- metadata +37 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c882690a75c66e0d0045caf2c574e04c6eb1c86160f767db1d5d1ef309cffc22
|
4
|
+
data.tar.gz: 8223e7a016e55b6ee64b80bb0979eaa4f646d84dbcfb157fdd3fffe2ff30822e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1883a3eba634425d4579d734046e2f44e2bd1798ee4c0ff7e0b4d911df3afb40760aa29bfb78cf1ba770fcf7f1b84a76833e1925a31c50c1e3c108462731f5dc
|
7
|
+
data.tar.gz: da8df93ab4487b5ffb8d626781338a623a988d568b3d0445b357e44adeb5021c8bcbe3c7a14daec9e0c0f37cd5626ee172986d420f7ea28b5ef4d872deb07722
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,24 +1,33 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-05-03
|
3
|
+
# on 2022-05-03 22:33:33 UTC using RuboCop version 1.28.2.
|
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:
|
9
|
+
# Offense count: 3
|
10
|
+
# Configuration parameters: AllowedMethods.
|
11
|
+
# AllowedMethods: enums
|
12
|
+
Lint/ConstantDefinitionInBlock:
|
13
|
+
Exclude:
|
14
|
+
- 'spec/consyncful/base_spec.rb'
|
15
|
+
- 'spec/consyncful/persisted_item_spec.rb'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
10
19
|
Metrics/AbcSize:
|
11
20
|
Max: 19
|
12
21
|
|
13
22
|
# Offense count: 12
|
14
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
-
#
|
23
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
24
|
+
# IgnoredMethods: refine
|
16
25
|
Metrics/BlockLength:
|
17
|
-
Max:
|
26
|
+
Max: 220
|
18
27
|
|
19
28
|
# Offense count: 3
|
20
|
-
#
|
21
|
-
# Configuration parameters:
|
29
|
+
# This cop supports safe auto-correction (--auto-correct).
|
30
|
+
# Configuration parameters: EnforcedStyle.
|
22
31
|
# SupportedStyles: nested, compact
|
23
32
|
Style/ClassAndModuleChildren:
|
24
33
|
Exclude:
|
@@ -26,15 +35,16 @@ Style/ClassAndModuleChildren:
|
|
26
35
|
- 'spec/consyncful/base_spec.rb'
|
27
36
|
|
28
37
|
# Offense count: 1
|
38
|
+
# Configuration parameters: AllowedConstants.
|
29
39
|
Style/Documentation:
|
30
40
|
Exclude:
|
31
41
|
- 'spec/**/*'
|
32
42
|
- 'test/**/*'
|
33
43
|
- 'lib/consyncful.rb'
|
34
44
|
|
35
|
-
# Offense count:
|
36
|
-
#
|
37
|
-
# Configuration parameters:
|
45
|
+
# Offense count: 9
|
46
|
+
# This cop supports safe auto-correction (--auto-correct).
|
47
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
38
48
|
# URISchemes: http, https
|
39
49
|
Layout/LineLength:
|
40
50
|
Max: 226
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
consyncful (0.7.
|
4
|
+
consyncful (0.7.1)
|
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,26 +10,26 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activemodel (7.0.
|
14
|
-
activesupport (= 7.0.
|
15
|
-
activesupport (7.0.
|
13
|
+
activemodel (7.0.3)
|
14
|
+
activesupport (= 7.0.3)
|
15
|
+
activesupport (7.0.3)
|
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
|
-
addressable (2.
|
20
|
+
addressable (2.8.0)
|
21
21
|
public_suffix (>= 2.0.2, < 5.0)
|
22
|
-
ast (2.4.
|
22
|
+
ast (2.4.2)
|
23
23
|
bson (4.15.0)
|
24
24
|
concurrent-ruby (1.1.10)
|
25
|
-
contentful (2.16.
|
25
|
+
contentful (2.16.3)
|
26
26
|
http (> 0.8, < 5.0)
|
27
27
|
multi_json (~> 1)
|
28
28
|
database_cleaner (1.8.3)
|
29
29
|
diff-lcs (1.3)
|
30
30
|
domain_name (0.5.20190701)
|
31
31
|
unf (>= 0.0.5, < 1.0.0)
|
32
|
-
ffi (1.15.
|
32
|
+
ffi (1.15.5)
|
33
33
|
ffi-compiler (1.0.1)
|
34
34
|
ffi (>= 1.0.0)
|
35
35
|
rake
|
@@ -40,15 +40,14 @@ GEM
|
|
40
40
|
http-cookie (~> 1.0)
|
41
41
|
http-form_data (~> 2.2)
|
42
42
|
http-parser (~> 1.2.0)
|
43
|
-
http-cookie (1.0.
|
43
|
+
http-cookie (1.0.5)
|
44
44
|
domain_name (~> 0.5)
|
45
45
|
http-form_data (2.3.0)
|
46
46
|
http-parser (1.2.3)
|
47
47
|
ffi-compiler (>= 1.0, < 2.0)
|
48
48
|
i18n (1.10.0)
|
49
49
|
concurrent-ruby (~> 1.0)
|
50
|
-
|
51
|
-
minitest (5.15.0)
|
50
|
+
minitest (5.16.2)
|
52
51
|
mongo (2.17.1)
|
53
52
|
bson (>= 4.8.2, < 5.0.0)
|
54
53
|
mongoid (7.4.0)
|
@@ -56,12 +55,14 @@ GEM
|
|
56
55
|
mongo (>= 2.10.5, < 3.0.0)
|
57
56
|
ruby2_keywords (~> 0.0.5)
|
58
57
|
multi_json (1.15.0)
|
59
|
-
parallel (1.
|
60
|
-
parser (2.
|
61
|
-
ast (~> 2.4.
|
62
|
-
public_suffix (4.0.
|
63
|
-
rainbow (3.
|
58
|
+
parallel (1.22.1)
|
59
|
+
parser (3.1.2.0)
|
60
|
+
ast (~> 2.4.1)
|
61
|
+
public_suffix (4.0.7)
|
62
|
+
rainbow (3.1.1)
|
64
63
|
rake (13.0.1)
|
64
|
+
regexp_parser (2.3.1)
|
65
|
+
rexml (3.2.5)
|
65
66
|
rspec (3.9.0)
|
66
67
|
rspec-core (~> 3.9.0)
|
67
68
|
rspec-expectations (~> 3.9.0)
|
@@ -75,22 +76,30 @@ GEM
|
|
75
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
77
|
rspec-support (~> 3.9.0)
|
77
78
|
rspec-support (3.9.2)
|
78
|
-
rubocop (
|
79
|
-
jaro_winkler (~> 1.5.1)
|
79
|
+
rubocop (1.28.2)
|
80
80
|
parallel (~> 1.10)
|
81
|
-
parser (>=
|
81
|
+
parser (>= 3.1.0.0)
|
82
82
|
rainbow (>= 2.2.2, < 4.0)
|
83
|
+
regexp_parser (>= 1.8, < 3.0)
|
84
|
+
rexml
|
85
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
83
86
|
ruby-progressbar (~> 1.7)
|
84
|
-
unicode-display_width (>= 1.4.0, <
|
85
|
-
|
87
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
88
|
+
rubocop-ast (1.17.0)
|
89
|
+
parser (>= 3.1.1.0)
|
90
|
+
rubocop-rake (0.6.0)
|
91
|
+
rubocop (~> 1.0)
|
92
|
+
rubocop-rspec (2.10.0)
|
93
|
+
rubocop (~> 1.19)
|
94
|
+
ruby-progressbar (1.11.0)
|
86
95
|
ruby2_keywords (0.0.5)
|
87
96
|
tzinfo (2.0.4)
|
88
97
|
concurrent-ruby (~> 1.0)
|
89
98
|
uber (0.0.15)
|
90
99
|
unf (0.1.4)
|
91
100
|
unf_ext
|
92
|
-
unf_ext (0.0.
|
93
|
-
unicode-display_width (1.
|
101
|
+
unf_ext (0.0.8.2)
|
102
|
+
unicode-display_width (2.1.0)
|
94
103
|
|
95
104
|
PLATFORMS
|
96
105
|
ruby
|
@@ -101,7 +110,9 @@ DEPENDENCIES
|
|
101
110
|
database_cleaner
|
102
111
|
rake (~> 13.0)
|
103
112
|
rspec (~> 3.0)
|
104
|
-
rubocop
|
113
|
+
rubocop
|
114
|
+
rubocop-rake
|
115
|
+
rubocop-rspec
|
105
116
|
|
106
117
|
BUNDLED WITH
|
107
118
|
2.3.7
|
data/README.md
CHANGED
@@ -165,6 +165,19 @@ 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
|
+
### Preserving Contentful timestamps
|
169
|
+
|
170
|
+
If you need to access the timestamps from Contentful, you can enable it by setting `preserve_contentful_timestamps` to `true`.
|
171
|
+
|
172
|
+
```rb
|
173
|
+
Consyncful.configure do |config|
|
174
|
+
# Consyncful models will have two extra fields that contains the value of timestamps in Contentful.
|
175
|
+
# contentful_created_at
|
176
|
+
# contentful_updated_at
|
177
|
+
config.preserve_contentful_timestamps = true # defaults to false
|
178
|
+
end
|
179
|
+
```
|
180
|
+
|
168
181
|
### Sync specific contents using [Contentful Tag](https://www.contentful.com/help/tags/).
|
169
182
|
You can configure Consyncful to sync or ignore specific contents using Contentful Tag.
|
170
183
|
|
data/consyncful.gemspec
CHANGED
@@ -5,14 +5,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'consyncful/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.
|
11
|
-
spec.
|
8
|
+
spec.name = 'consyncful'
|
9
|
+
spec.version = Consyncful::VERSION
|
10
|
+
spec.required_ruby_version = '>= 2.7'
|
11
|
+
spec.authors = ['Andy Anastasiadis-Gray']
|
12
|
+
spec.email = ['andy@boost.co.nz']
|
12
13
|
|
13
|
-
spec.summary
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
14
|
+
spec.summary = 'Contentful to local database synchronisation for Rails'
|
15
|
+
spec.homepage = 'https://github.com/boost/consyncful'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -23,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
23
24
|
# "public gem pushes."
|
24
25
|
# end
|
25
26
|
|
26
|
-
spec.files
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
28
|
f.match(%r{^(test|spec|features)/})
|
28
29
|
end
|
29
30
|
spec.bindir = 'exe'
|
@@ -34,10 +35,13 @@ Gem::Specification.new do |spec|
|
|
34
35
|
spec.add_development_dependency 'database_cleaner'
|
35
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
36
37
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
-
spec.add_development_dependency 'rubocop'
|
38
|
+
spec.add_development_dependency 'rubocop'
|
39
|
+
spec.add_development_dependency 'rubocop-rake'
|
40
|
+
spec.add_development_dependency 'rubocop-rspec'
|
38
41
|
|
39
42
|
spec.add_dependency 'contentful', ['>=2.11.1', '<3.0.0']
|
40
43
|
spec.add_dependency 'hooks', '>=0.4.1'
|
41
44
|
spec.add_dependency 'mongoid', ['>=7.0.2', '<8.0.0']
|
42
45
|
spec.add_dependency 'rainbow'
|
46
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
43
47
|
end
|
@@ -36,6 +36,7 @@ module Consyncful
|
|
36
36
|
|
37
37
|
fields.merge!(localized_fields(default_locale))
|
38
38
|
fields.merge!(localized_asset_fields(default_locale)) if type == 'asset'
|
39
|
+
fields.merge!(contentful_timestamps) if Consyncful.configuration.preserve_contentful_timestamps
|
39
40
|
|
40
41
|
fields
|
41
42
|
end
|
@@ -49,11 +50,13 @@ module Consyncful
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def generic_fields
|
52
|
-
{
|
53
|
+
{
|
54
|
+
created_at: @item.created_at,
|
53
55
|
updated_at: @item.updated_at,
|
54
56
|
revision: @item.revision,
|
55
57
|
contentful_type: type,
|
56
|
-
synced_at: Time.current
|
58
|
+
synced_at: Time.current
|
59
|
+
}
|
57
60
|
end
|
58
61
|
|
59
62
|
def localized_fields(default_locale)
|
@@ -107,11 +110,18 @@ module Consyncful
|
|
107
110
|
if single_reference?(value)
|
108
111
|
[ActiveSupport::Inflector.foreign_key(field).to_sym, value.id]
|
109
112
|
elsif many_reference?(value)
|
110
|
-
ids_field_name = field.to_s.singularize
|
113
|
+
ids_field_name = "#{field.to_s.singularize}_ids" # fk field name
|
111
114
|
[ids_field_name.to_sym, value.map(&:id)]
|
112
115
|
else
|
113
116
|
[field, value]
|
114
117
|
end
|
115
118
|
end
|
119
|
+
|
120
|
+
def contentful_timestamps
|
121
|
+
{
|
122
|
+
contentful_created_at: @item.created_at,
|
123
|
+
contentful_updated_at: @item.updated_at
|
124
|
+
}
|
125
|
+
end
|
116
126
|
end
|
117
127
|
end
|
data/lib/consyncful/version.rb
CHANGED
data/lib/consyncful.rb
CHANGED
@@ -18,7 +18,8 @@ module Consyncful
|
|
18
18
|
:mongo_client,
|
19
19
|
:mongo_collection,
|
20
20
|
:content_tags,
|
21
|
-
:ignore_content_tags
|
21
|
+
:ignore_content_tags,
|
22
|
+
:preserve_contentful_timestamps
|
22
23
|
|
23
24
|
def initialize
|
24
25
|
@contentful_client_options = {
|
@@ -29,6 +30,7 @@ module Consyncful
|
|
29
30
|
@mongo_collection = 'contentful_models'
|
30
31
|
@content_tags = []
|
31
32
|
@ignore_content_tags = []
|
33
|
+
@preserve_contentful_timestamps = false
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
metadata
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consyncful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Anastasiadis-Gray
|
8
|
-
- Montgomery Anderson
|
9
|
-
- Greg Rogan
|
10
8
|
autorequire:
|
11
9
|
bindir: exe
|
12
10
|
cert_chain: []
|
13
|
-
date: 2022-
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
14
12
|
dependencies:
|
15
13
|
- !ruby/object:Gem::Dependency
|
16
14
|
name: bundler
|
@@ -72,16 +70,44 @@ dependencies:
|
|
72
70
|
name: rubocop
|
73
71
|
requirement: !ruby/object:Gem::Requirement
|
74
72
|
requirements:
|
75
|
-
- -
|
73
|
+
- - ">="
|
76
74
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0
|
75
|
+
version: '0'
|
78
76
|
type: :development
|
79
77
|
prerelease: false
|
80
78
|
version_requirements: !ruby/object:Gem::Requirement
|
81
79
|
requirements:
|
82
|
-
- -
|
80
|
+
- - ">="
|
83
81
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
85
111
|
- !ruby/object:Gem::Dependency
|
86
112
|
name: contentful
|
87
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,8 +179,6 @@ dependencies:
|
|
153
179
|
description:
|
154
180
|
email:
|
155
181
|
- andy@boost.co.nz
|
156
|
-
- montgomery@boost.co.nz
|
157
|
-
- greg@boost.co.nz
|
158
182
|
executables: []
|
159
183
|
extensions: []
|
160
184
|
extra_rdoc_files: []
|
@@ -187,7 +211,8 @@ files:
|
|
187
211
|
homepage: https://github.com/boost/consyncful
|
188
212
|
licenses:
|
189
213
|
- MIT
|
190
|
-
metadata:
|
214
|
+
metadata:
|
215
|
+
rubygems_mfa_required: 'true'
|
191
216
|
post_install_message:
|
192
217
|
rdoc_options: []
|
193
218
|
require_paths:
|
@@ -196,7 +221,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
221
|
requirements:
|
197
222
|
- - ">="
|
198
223
|
- !ruby/object:Gem::Version
|
199
|
-
version: '
|
224
|
+
version: '2.7'
|
200
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
226
|
requirements:
|
202
227
|
- - ">="
|