pub_sub_model_sync 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +33 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +63 -47
- data/lib/pub_sub_model_sync/publisher.rb +4 -2
- data/lib/pub_sub_model_sync/publisher_concern.rb +7 -7
- data/lib/pub_sub_model_sync/version.rb +1 -1
- metadata +4 -5
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7655730b3b89716b76be52db708b7c93ec64176cc158fc84323d4e811f6dcdf1
|
4
|
+
data.tar.gz: 874aa3f5c5c679fd3e7ec02550426f0824481194ebd99b1a0494180df3a22cc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e8406293a7528fa5d697c2a6a30b4cb00cee900b349ef834fad5fd7771ce864a8338ac95bc1bcbe41568d9efa1737111720607cb0f002e684ab532e835ec651
|
7
|
+
data.tar.gz: 0f995774ddf1b916db02fed9051c26b106e549261877c72a718e9e23c45544dff6c9757231e094201c9d466b2c4922d8e6364f8167697820db5833d78ee85c85
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
name: Tests and Code Style
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby 2.6
|
18
|
+
uses: actions/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.6.x
|
21
|
+
|
22
|
+
- name: Install sqlite3
|
23
|
+
run: sudo apt-get install libsqlite3-dev
|
24
|
+
|
25
|
+
- name: Bundle install
|
26
|
+
run: |
|
27
|
+
gem install bundler
|
28
|
+
bundle install --jobs 4 --retry 3
|
29
|
+
- name: Tests (rspec)
|
30
|
+
run: |
|
31
|
+
bundle exec rspec
|
32
|
+
- name: Code style (Rubocop)
|
33
|
+
run: bundle exec rubocop
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,58 +1,71 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pub_sub_model_sync (0.2.
|
4
|
+
pub_sub_model_sync (0.2.4)
|
5
5
|
activesupport
|
6
6
|
rails
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (
|
12
|
-
actionpack (=
|
11
|
+
actioncable (6.0.2.2)
|
12
|
+
actionpack (= 6.0.2.2)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
|
-
|
16
|
-
actionpack (=
|
17
|
-
|
18
|
-
|
15
|
+
actionmailbox (6.0.2.2)
|
16
|
+
actionpack (= 6.0.2.2)
|
17
|
+
activejob (= 6.0.2.2)
|
18
|
+
activerecord (= 6.0.2.2)
|
19
|
+
activestorage (= 6.0.2.2)
|
20
|
+
activesupport (= 6.0.2.2)
|
21
|
+
mail (>= 2.7.1)
|
22
|
+
actionmailer (6.0.2.2)
|
23
|
+
actionpack (= 6.0.2.2)
|
24
|
+
actionview (= 6.0.2.2)
|
25
|
+
activejob (= 6.0.2.2)
|
19
26
|
mail (~> 2.5, >= 2.5.4)
|
20
27
|
rails-dom-testing (~> 2.0)
|
21
|
-
actionpack (
|
22
|
-
actionview (=
|
23
|
-
activesupport (=
|
28
|
+
actionpack (6.0.2.2)
|
29
|
+
actionview (= 6.0.2.2)
|
30
|
+
activesupport (= 6.0.2.2)
|
24
31
|
rack (~> 2.0, >= 2.0.8)
|
25
32
|
rack-test (>= 0.6.3)
|
26
33
|
rails-dom-testing (~> 2.0)
|
27
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
28
|
-
|
29
|
-
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
+
actiontext (6.0.2.2)
|
36
|
+
actionpack (= 6.0.2.2)
|
37
|
+
activerecord (= 6.0.2.2)
|
38
|
+
activestorage (= 6.0.2.2)
|
39
|
+
activesupport (= 6.0.2.2)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
actionview (6.0.2.2)
|
42
|
+
activesupport (= 6.0.2.2)
|
30
43
|
builder (~> 3.1)
|
31
44
|
erubi (~> 1.4)
|
32
45
|
rails-dom-testing (~> 2.0)
|
33
|
-
rails-html-sanitizer (~> 1.
|
34
|
-
activejob (
|
35
|
-
activesupport (=
|
46
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
+
activejob (6.0.2.2)
|
48
|
+
activesupport (= 6.0.2.2)
|
36
49
|
globalid (>= 0.3.6)
|
37
|
-
activemodel (
|
38
|
-
activesupport (=
|
39
|
-
activerecord (
|
40
|
-
activemodel (=
|
41
|
-
activesupport (=
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
activerecord (=
|
50
|
+
activemodel (6.0.2.2)
|
51
|
+
activesupport (= 6.0.2.2)
|
52
|
+
activerecord (6.0.2.2)
|
53
|
+
activemodel (= 6.0.2.2)
|
54
|
+
activesupport (= 6.0.2.2)
|
55
|
+
activestorage (6.0.2.2)
|
56
|
+
actionpack (= 6.0.2.2)
|
57
|
+
activejob (= 6.0.2.2)
|
58
|
+
activerecord (= 6.0.2.2)
|
46
59
|
marcel (~> 0.3.1)
|
47
|
-
activesupport (
|
60
|
+
activesupport (6.0.2.2)
|
48
61
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
49
62
|
i18n (>= 0.7, < 2)
|
50
63
|
minitest (~> 5.1)
|
51
64
|
tzinfo (~> 1.1)
|
65
|
+
zeitwerk (~> 2.2)
|
52
66
|
addressable (2.7.0)
|
53
67
|
public_suffix (>= 2.0.2, < 5.0)
|
54
68
|
amq-protocol (2.3.0)
|
55
|
-
arel (9.0.0)
|
56
69
|
ast (2.4.0)
|
57
70
|
builder (3.2.4)
|
58
71
|
bunny (2.14.3)
|
@@ -106,7 +119,7 @@ GEM
|
|
106
119
|
concurrent-ruby (~> 1.0)
|
107
120
|
jaro_winkler (1.5.4)
|
108
121
|
jwt (2.2.1)
|
109
|
-
loofah (2.
|
122
|
+
loofah (2.5.0)
|
110
123
|
crass (~> 1.0.2)
|
111
124
|
nokogiri (>= 1.5.9)
|
112
125
|
mail (2.7.1)
|
@@ -114,7 +127,7 @@ GEM
|
|
114
127
|
marcel (0.3.3)
|
115
128
|
mimemagic (~> 0.3.2)
|
116
129
|
memoist (0.16.2)
|
117
|
-
method_source (0.
|
130
|
+
method_source (1.0.0)
|
118
131
|
mimemagic (0.3.4)
|
119
132
|
mini_mime (1.0.2)
|
120
133
|
mini_portile2 (2.4.0)
|
@@ -132,30 +145,32 @@ GEM
|
|
132
145
|
rack (2.2.2)
|
133
146
|
rack-test (1.1.0)
|
134
147
|
rack (>= 1.0, < 3)
|
135
|
-
rails (
|
136
|
-
actioncable (=
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
148
|
+
rails (6.0.2.2)
|
149
|
+
actioncable (= 6.0.2.2)
|
150
|
+
actionmailbox (= 6.0.2.2)
|
151
|
+
actionmailer (= 6.0.2.2)
|
152
|
+
actionpack (= 6.0.2.2)
|
153
|
+
actiontext (= 6.0.2.2)
|
154
|
+
actionview (= 6.0.2.2)
|
155
|
+
activejob (= 6.0.2.2)
|
156
|
+
activemodel (= 6.0.2.2)
|
157
|
+
activerecord (= 6.0.2.2)
|
158
|
+
activestorage (= 6.0.2.2)
|
159
|
+
activesupport (= 6.0.2.2)
|
145
160
|
bundler (>= 1.3.0)
|
146
|
-
railties (=
|
161
|
+
railties (= 6.0.2.2)
|
147
162
|
sprockets-rails (>= 2.0.0)
|
148
163
|
rails-dom-testing (2.0.3)
|
149
164
|
activesupport (>= 4.2.0)
|
150
165
|
nokogiri (>= 1.6)
|
151
166
|
rails-html-sanitizer (1.3.0)
|
152
167
|
loofah (~> 2.3)
|
153
|
-
railties (
|
154
|
-
actionpack (=
|
155
|
-
activesupport (=
|
168
|
+
railties (6.0.2.2)
|
169
|
+
actionpack (= 6.0.2.2)
|
170
|
+
activesupport (= 6.0.2.2)
|
156
171
|
method_source
|
157
172
|
rake (>= 0.8.7)
|
158
|
-
thor (>= 0.
|
173
|
+
thor (>= 0.20.3, < 2.0)
|
159
174
|
rainbow (3.0.0)
|
160
175
|
rake (13.0.1)
|
161
176
|
rexml (3.2.4)
|
@@ -189,7 +204,7 @@ GEM
|
|
189
204
|
faraday (~> 0.9)
|
190
205
|
jwt (>= 1.5, < 3.0)
|
191
206
|
multi_json (~> 1.10)
|
192
|
-
sprockets (
|
207
|
+
sprockets (4.0.0)
|
193
208
|
concurrent-ruby (~> 1.0)
|
194
209
|
rack (> 1, < 3)
|
195
210
|
sprockets-rails (3.2.1)
|
@@ -199,12 +214,13 @@ GEM
|
|
199
214
|
sqlite3 (1.4.2)
|
200
215
|
thor (1.0.1)
|
201
216
|
thread_safe (0.3.6)
|
202
|
-
tzinfo (1.2.
|
217
|
+
tzinfo (1.2.7)
|
203
218
|
thread_safe (~> 0.1)
|
204
219
|
unicode-display_width (1.6.1)
|
205
220
|
websocket-driver (0.7.1)
|
206
221
|
websocket-extensions (>= 0.1.0)
|
207
222
|
websocket-extensions (0.1.4)
|
223
|
+
zeitwerk (2.3.0)
|
208
224
|
|
209
225
|
PLATFORMS
|
210
226
|
ruby
|
@@ -221,4 +237,4 @@ DEPENDENCIES
|
|
221
237
|
sqlite3
|
222
238
|
|
223
239
|
BUNDLED WITH
|
224
|
-
2.
|
240
|
+
2.1.4
|
@@ -3,13 +3,15 @@
|
|
3
3
|
module PubSubModelSync
|
4
4
|
class Publisher
|
5
5
|
attr_accessor :connector
|
6
|
+
delegate :publish, to: :connector
|
7
|
+
|
6
8
|
def initialize
|
7
9
|
@connector = PubSubModelSync::Connector.new
|
8
10
|
end
|
9
11
|
|
10
12
|
def publish_data(klass, data, action)
|
11
13
|
attributes = self.class.build_attrs(klass, action)
|
12
|
-
|
14
|
+
publish(data, attributes)
|
13
15
|
end
|
14
16
|
|
15
17
|
# @param settings (Hash): { attrs: [], as_klass: nil, id: nil }
|
@@ -23,7 +25,7 @@ module PubSubModelSync
|
|
23
25
|
res_before = model.ps_before_sync(action, data)
|
24
26
|
return if res_before == :cancel
|
25
27
|
|
26
|
-
|
28
|
+
publish(data.symbolize_keys, attributes)
|
27
29
|
model.ps_after_sync(action, data)
|
28
30
|
end
|
29
31
|
|
@@ -31,7 +31,7 @@ module PubSubModelSync
|
|
31
31
|
end
|
32
32
|
|
33
33
|
module ClassMethods
|
34
|
-
# Permit to publish crud actions (:create, :update, :destroy)
|
34
|
+
# Permit to configure to publish crud actions (:create, :update, :destroy)
|
35
35
|
# @param settings (Hash): { actions: nil, as_klass: nil, id: nil }
|
36
36
|
def ps_publish(attrs, settings = {})
|
37
37
|
actions = settings.delete(:actions) || %i[create update destroy]
|
@@ -42,6 +42,12 @@ module PubSubModelSync
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# On demand class level publisher
|
46
|
+
def ps_class_publish(data, action:, as_klass: nil)
|
47
|
+
as_klass = (as_klass || name).to_s
|
48
|
+
ps_publisher_service.publish_data(as_klass, data, action.to_sym)
|
49
|
+
end
|
50
|
+
|
45
51
|
# Publisher info for specific action
|
46
52
|
def ps_publisher_info(action = :create)
|
47
53
|
PubSubModelSync::Config.publishers.select do |listener|
|
@@ -49,12 +55,6 @@ module PubSubModelSync
|
|
49
55
|
end.last
|
50
56
|
end
|
51
57
|
|
52
|
-
# On demand class level publisher
|
53
|
-
def ps_class_publish(data, action:, as_klass: nil)
|
54
|
-
as_klass = (as_klass || name).to_s
|
55
|
-
ps_publisher_service.publish_data(as_klass, data, action.to_sym)
|
56
|
-
end
|
57
|
-
|
58
58
|
def ps_publisher_service
|
59
59
|
PubSubModelSync::Publisher.new
|
60
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pub_sub_model_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -101,10 +101,10 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- ".github/workflows/ruby.yml"
|
104
105
|
- ".gitignore"
|
105
106
|
- ".rspec"
|
106
107
|
- ".rubocop.yml"
|
107
|
-
- ".travis.yml"
|
108
108
|
- CHANGELOG.md
|
109
109
|
- CODE_OF_CONDUCT.md
|
110
110
|
- Gemfile
|
@@ -155,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
- !ruby/object:Gem::Version
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
|
-
|
159
|
-
rubygems_version: 2.7.7
|
158
|
+
rubygems_version: 3.0.8
|
160
159
|
signing_key:
|
161
160
|
specification_version: 4
|
162
161
|
summary: Permit to sync models between apps through pub/sub
|
data/.travis.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
language: ruby
|
4
|
-
cache: bundler
|
5
|
-
rvm:
|
6
|
-
- 2.3.1
|
7
|
-
before_install: gem install bundler
|
8
|
-
|
9
|
-
script:
|
10
|
-
- bundle install
|
11
|
-
# disabled cause of: An error occurred while Style/PercentLiteralDelimiters cop
|
12
|
-
# - bundle exec rubocop
|
13
|
-
- bundle exec rspec
|