consyncful 0.7.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10b3daa6395ab09a3eefac1c3d6e8795530b346b8ce5d4d1248527e98719a785
4
- data.tar.gz: f2948c392596ff652ae67f4153b0e407f73b5424315de19df348842f1ee1d181
3
+ metadata.gz: c882690a75c66e0d0045caf2c574e04c6eb1c86160f767db1d5d1ef309cffc22
4
+ data.tar.gz: 8223e7a016e55b6ee64b80bb0979eaa4f646d84dbcfb157fdd3fffe2ff30822e
5
5
  SHA512:
6
- metadata.gz: 4b136cbf030b12667c3a590bb6361ec8b6aa6ac45fcb452af7401c116f926afb227ba02c31293ec3f55e084e96aaa428551358b39b6ec5d63d4f094d533a1e78
7
- data.tar.gz: 3419eba7818aadf3f472fde9013a12043ac22227cd36562ae3c29e392bf73e65cb4525b9711aade7c1bd25460b8543b1b99d73517bd466ef04a2860340f5922e
6
+ metadata.gz: 1883a3eba634425d4579d734046e2f44e2bd1798ee4c0ff7e0b4d911df3afb40760aa29bfb78cf1ba770fcf7f1b84a76833e1925a31c50c1e3c108462731f5dc
7
+ data.tar.gz: da8df93ab4487b5ffb8d626781338a623a988d568b3d0445b357e44adeb5021c8bcbe3c7a14daec9e0c0f37cd5626ee172986d420f7ea28b5ef4d872deb07722
@@ -37,6 +37,9 @@ jobs:
37
37
  with:
38
38
  mongodb-version: ${{ matrix.mongodb }}
39
39
 
40
+ - name: Run rubocop
41
+ run: |
42
+ bundle exec rubocop
40
43
  - name: Run tests
41
44
  run: |
42
45
  bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1 +1,5 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.7
5
+ NewCops: enable
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 14:45:03 +1200 using RuboCop version 0.79.0.
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: 2
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
- # ExcludedMethods: refine
23
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
24
+ # IgnoredMethods: refine
16
25
  Metrics/BlockLength:
17
- Max: 211
26
+ Max: 220
18
27
 
19
28
  # Offense count: 3
20
- # Cop supports --auto-correct.
21
- # Configuration parameters: AutoCorrect, EnforcedStyle.
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: 57
36
- # Cop supports --auto-correct.
37
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
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.0)
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.2.4)
14
- activesupport (= 7.0.2.4)
15
- activesupport (7.0.2.4)
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.7.0)
20
+ addressable (2.8.0)
21
21
  public_suffix (>= 2.0.2, < 5.0)
22
- ast (2.4.0)
22
+ ast (2.4.2)
23
23
  bson (4.15.0)
24
24
  concurrent-ruby (1.1.10)
25
- contentful (2.16.0)
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.0)
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.3)
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
- jaro_winkler (1.5.4)
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.19.1)
60
- parser (2.7.0.2)
61
- ast (~> 2.4.0)
62
- public_suffix (4.0.6)
63
- rainbow (3.0.0)
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 (0.79.0)
79
- jaro_winkler (~> 1.5.1)
79
+ rubocop (1.28.2)
80
80
  parallel (~> 1.10)
81
- parser (>= 2.7.0.1)
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, < 1.7)
85
- ruby-progressbar (1.10.1)
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.7.7)
93
- unicode-display_width (1.6.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 (= 0.79.0)
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 = 'consyncful'
9
- spec.version = Consyncful::VERSION
10
- spec.authors = ['Andy Anastasiadis-Gray', 'Montgomery Anderson', 'Greg Rogan']
11
- spec.email = ['andy@boost.co.nz', 'montgomery@boost.co.nz', 'greg@boost.co.nz']
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 = 'Contentful to local database synchronisation for Rails'
14
- spec.homepage = 'https://github.com/boost/consyncful'
15
- spec.license = 'MIT'
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 = `git ls-files -z`.split("\x0").reject do |f|
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', '0.79.0'
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
- { created_at: @item.created_at,
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 + '_ids' # fk field name
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Consyncful
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.1'
5
5
  end
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.0
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-05-03 00:00:00.000000000 Z
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.79.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.79.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: '0'
224
+ version: '2.7'
200
225
  required_rubygems_version: !ruby/object:Gem::Requirement
201
226
  requirements:
202
227
  - - ">="