consyncful 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +0 -2
- data/README.md +1 -1
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/consyncful.gemspec +16 -15
- data/docker-compose.yml +1 -1
- data/lib/consyncful.rb +7 -5
- data/lib/consyncful/sync.rb +11 -5
- data/lib/consyncful/tasks/consyncful.rake +1 -1
- data/lib/consyncful/version.rb +3 -1
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 258e4fe9fbea3099f0d78615c79b1e49658841c7b706f296a1d5402115c5ed7d
|
4
|
+
data.tar.gz: 8d47ad368c228b87a1f04fc5d1c4c236c16d6d3106bae1dda6a49de0a74a9c9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b498a8a55c814edf02fabec13c54d93a6653aae0e1e87143ea9e2d637d3eb61e6beaf045201660ad065bb745f4df97b411fa6f451bbd02858d45b1e041aa24
|
7
|
+
data.tar.gz: 841216be1a7c0149aea9e6136369cdd2bd3a1e5d9edb9854b677f98d2ef1596b7df3273370054713915fd798016578263398f24d8e23460360caa2bb5751871d
|
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.5
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in consyncful.gemspec
|
6
8
|
gemspec
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -90,7 +90,7 @@ To run a syncronization process run:
|
|
90
90
|
|
91
91
|
The first time you run this it will download all the contentful content, it will then check every 15 seconds for changes to the content and update/delete records in the database when changes are made in contentful.
|
92
92
|
|
93
|
-
If you want to
|
93
|
+
If you want to syncronise from scratch run:
|
94
94
|
|
95
95
|
$ rake consyncful:refresh
|
96
96
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'consyncful'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "consyncful"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/consyncful.gemspec
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'consyncful/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'consyncful'
|
8
9
|
spec.version = Consyncful::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Andy Anastasiadis-Gray', 'Montgomery Anderson']
|
11
|
+
spec.email = ['andy@boost.co.nz', 'montgomery@boost.co.nz']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
|
14
|
-
spec.license =
|
13
|
+
spec.summary = 'Contentful to local database synchronisation for Rails'
|
14
|
+
spec.homepage = 'https://github.com/boost/consyncful'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -25,15 +26,15 @@ Gem::Specification.new do |spec|
|
|
25
26
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
27
|
f.match(%r{^(test|spec|features)/})
|
27
28
|
end
|
28
|
-
spec.bindir =
|
29
|
+
spec.bindir = 'exe'
|
29
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = [
|
31
|
+
spec.require_paths = ['lib']
|
31
32
|
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
36
|
|
36
|
-
spec.add_dependency
|
37
|
-
spec.add_dependency
|
37
|
+
spec.add_dependency 'contentful', ['>=2.11.1', '<3.0.0']
|
38
|
+
spec.add_dependency 'mongoid', ['>=7.0.2', '<8.0.0']
|
38
39
|
spec.add_dependency 'term-ansicolor'
|
39
40
|
end
|
data/docker-compose.yml
CHANGED
data/lib/consyncful.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'consyncful/version'
|
2
4
|
|
3
5
|
require 'mongoid'
|
4
6
|
require 'contentful'
|
5
7
|
|
6
|
-
require
|
7
|
-
require
|
8
|
+
require 'consyncful/base'
|
9
|
+
require 'consyncful/sync'
|
8
10
|
|
9
|
-
require
|
11
|
+
require 'consyncful/railtie' if defined?(Rails)
|
10
12
|
|
11
13
|
module Consyncful
|
12
14
|
class << self
|
@@ -32,7 +34,7 @@ module Consyncful
|
|
32
34
|
DEFAULT_CLIENT_OPTIONS = {
|
33
35
|
reuse_entries: true,
|
34
36
|
api_url: 'cdn.contentful.com'
|
35
|
-
}
|
37
|
+
}.freeze
|
36
38
|
|
37
39
|
def self.client
|
38
40
|
@client ||= begin
|
data/lib/consyncful/sync.rb
CHANGED
@@ -21,14 +21,15 @@ module Consyncful
|
|
21
21
|
last || new
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.
|
24
|
+
def self.fresh
|
25
25
|
destroy_all
|
26
|
-
|
26
|
+
latest
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
29
|
+
def drop_stale
|
30
|
+
stale = Base.where(:sync_id.ne => id, :sync_id.exists => true)
|
31
|
+
puts "Dropping #{stale.count} records that haven't been touched in this sync".red
|
32
|
+
stale.destroy
|
32
33
|
end
|
33
34
|
|
34
35
|
def run
|
@@ -39,6 +40,8 @@ module Consyncful
|
|
39
40
|
|
40
41
|
sync_items(sync, stats)
|
41
42
|
|
43
|
+
drop_stale
|
44
|
+
|
42
45
|
self.next_url = sync.next_sync_url
|
43
46
|
self.last_run_at = Time.current
|
44
47
|
save
|
@@ -49,6 +52,7 @@ module Consyncful
|
|
49
52
|
|
50
53
|
def load_all_models
|
51
54
|
return unless defined? Rails
|
55
|
+
|
52
56
|
Rails.application.eager_load!
|
53
57
|
end
|
54
58
|
|
@@ -99,6 +103,8 @@ module Consyncful
|
|
99
103
|
instance[field] = value
|
100
104
|
end
|
101
105
|
|
106
|
+
instance[:sync_id] = id
|
107
|
+
|
102
108
|
instance.save
|
103
109
|
end
|
104
110
|
|
@@ -9,7 +9,7 @@ namespace :consyncful do
|
|
9
9
|
Consyncful::Sync.fresh.run
|
10
10
|
end
|
11
11
|
|
12
|
-
task :sync, [:seconds] => [
|
12
|
+
task :sync, [:seconds] => %i[environment update_model_names] do |_task, args|
|
13
13
|
seconds = args[:seconds].to_i
|
14
14
|
seconds = 15 if seconds.zero?
|
15
15
|
loop do
|
data/lib/consyncful/version.rb
CHANGED
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Anastasiadis-Gray
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -54,45 +54,45 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: contentful
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 2.11.1
|
63
63
|
- - "<"
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
65
|
+
version: 3.0.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
72
|
+
version: 2.11.1
|
73
73
|
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 3.0.0
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
77
|
+
name: mongoid
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 7.0.2
|
83
83
|
- - "<"
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 8.0.0
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
92
|
+
version: 7.0.2
|
93
93
|
- - "<"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 8.0.0
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
97
|
name: term-ansicolor
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,6 +117,8 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
|
+
- ".rubocop.yml"
|
121
|
+
- ".ruby-version"
|
120
122
|
- ".travis.yml"
|
121
123
|
- Gemfile
|
122
124
|
- Gemfile.lock
|
@@ -136,7 +138,7 @@ files:
|
|
136
138
|
- lib/consyncful/sync.rb
|
137
139
|
- lib/consyncful/tasks/consyncful.rake
|
138
140
|
- lib/consyncful/version.rb
|
139
|
-
homepage:
|
141
|
+
homepage: https://github.com/boost/consyncful
|
140
142
|
licenses:
|
141
143
|
- MIT
|
142
144
|
metadata: {}
|
@@ -156,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
158
|
version: '0'
|
157
159
|
requirements: []
|
158
160
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.7.6
|
161
|
+
rubygems_version: 2.7.6.2
|
160
162
|
signing_key:
|
161
163
|
specification_version: 4
|
162
164
|
summary: Contentful to local database synchronisation for Rails
|