external_services 0.5.2 → 0.5.4
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 +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +139 -109
- data/Rakefile +2 -0
- data/app/jobs/external_services/api_job.rb +2 -0
- data/app/models/concerns/external_services/action.rb +2 -0
- data/app/models/external_services/api_action.rb +6 -3
- data/app/models/external_services/service.rb +6 -3
- data/bin/rails +5 -3
- data/external_services.gemspec +6 -4
- data/lib/external_services/active_record.rb +28 -32
- data/lib/external_services/api.rb +2 -0
- data/lib/external_services/engine.rb +2 -0
- data/lib/external_services/version.rb +3 -1
- data/lib/external_services.rb +12 -10
- data/lib/generators/install_generator.rb +3 -1
- data/lib/generators/service_generator.rb +2 -0
- data/lib/rspec/configuration.rb +3 -1
- data/lib/rspec/disabler.rb +2 -0
- data/lib/rspec/helpers.rb +2 -0
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08f5895f6fa74286ed5c60a14c9840aa765bbf4179070311293ca8aca9cdc5b7'
|
|
4
|
+
data.tar.gz: 8ebfb1bd40b695f3039e692ea02546e9ff60b729a25aa0869f51c120e8ed2953
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 988c94bd9e499f7c611f41e3d76ae763c95959d414639b990921d71b6a17f58beb167319f797425200e42aecb0da9c325787c5155589b5e5c93993acde16c134
|
|
7
|
+
data.tar.gz: bc1dbcff05bc31f0cebc4cb85c703e487bdea514a2c8a21fd79677ce70eb07e0d6ef1044642a09e30e1b1eeb028cf39b1d6b724f844636f99b31248a26feb281
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
3
5
|
# Specify your gem's dependencies in external_services.gemspec
|
|
@@ -6,10 +8,10 @@ gemspec
|
|
|
6
8
|
gem 'rake', '~> 13.0'
|
|
7
9
|
gem 'sqlite3'
|
|
8
10
|
|
|
11
|
+
gem 'net-smtp', require: false # HACK: for pre 7.0.1 rails and 3.1 ruby
|
|
9
12
|
gem 'overcommit'
|
|
10
13
|
gem 'rubocop', '~> 1.0', require: false
|
|
11
14
|
gem 'rubocop-rspec'
|
|
12
|
-
gem 'net-smtp', require: false # hack for pre 7.0.1 rails and 3.1 ruby
|
|
13
15
|
|
|
14
16
|
gem 'pry', '>= 0.14'
|
|
15
17
|
gem 'pry-rails', '~> 0.3.9'
|
data/Gemfile.lock
CHANGED
|
@@ -1,84 +1,102 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
external_services (0.5.
|
|
4
|
+
external_services (0.5.4)
|
|
5
5
|
faraday (>= 1.4, < 2)
|
|
6
6
|
faraday_middleware (>= 1.0, < 2)
|
|
7
|
-
rails (>= 4.2.5, <
|
|
7
|
+
rails (>= 4.2.5, < 8)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
actioncable (
|
|
13
|
-
actionpack (=
|
|
14
|
-
activesupport (=
|
|
12
|
+
actioncable (7.1.3.3)
|
|
13
|
+
actionpack (= 7.1.3.3)
|
|
14
|
+
activesupport (= 7.1.3.3)
|
|
15
15
|
nio4r (~> 2.0)
|
|
16
16
|
websocket-driver (>= 0.6.1)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
zeitwerk (~> 2.6)
|
|
18
|
+
actionmailbox (7.1.3.3)
|
|
19
|
+
actionpack (= 7.1.3.3)
|
|
20
|
+
activejob (= 7.1.3.3)
|
|
21
|
+
activerecord (= 7.1.3.3)
|
|
22
|
+
activestorage (= 7.1.3.3)
|
|
23
|
+
activesupport (= 7.1.3.3)
|
|
23
24
|
mail (>= 2.7.1)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
net-imap
|
|
26
|
+
net-pop
|
|
27
|
+
net-smtp
|
|
28
|
+
actionmailer (7.1.3.3)
|
|
29
|
+
actionpack (= 7.1.3.3)
|
|
30
|
+
actionview (= 7.1.3.3)
|
|
31
|
+
activejob (= 7.1.3.3)
|
|
32
|
+
activesupport (= 7.1.3.3)
|
|
29
33
|
mail (~> 2.5, >= 2.5.4)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
net-imap
|
|
35
|
+
net-pop
|
|
36
|
+
net-smtp
|
|
37
|
+
rails-dom-testing (~> 2.2)
|
|
38
|
+
actionpack (7.1.3.3)
|
|
39
|
+
actionview (= 7.1.3.3)
|
|
40
|
+
activesupport (= 7.1.3.3)
|
|
41
|
+
nokogiri (>= 1.8.5)
|
|
42
|
+
racc
|
|
43
|
+
rack (>= 2.2.4)
|
|
44
|
+
rack-session (>= 1.0.1)
|
|
35
45
|
rack-test (>= 0.6.3)
|
|
36
|
-
rails-dom-testing (~> 2.
|
|
37
|
-
rails-html-sanitizer (~> 1.
|
|
38
|
-
actiontext (
|
|
39
|
-
actionpack (=
|
|
40
|
-
activerecord (=
|
|
41
|
-
activestorage (=
|
|
42
|
-
activesupport (=
|
|
46
|
+
rails-dom-testing (~> 2.2)
|
|
47
|
+
rails-html-sanitizer (~> 1.6)
|
|
48
|
+
actiontext (7.1.3.3)
|
|
49
|
+
actionpack (= 7.1.3.3)
|
|
50
|
+
activerecord (= 7.1.3.3)
|
|
51
|
+
activestorage (= 7.1.3.3)
|
|
52
|
+
activesupport (= 7.1.3.3)
|
|
53
|
+
globalid (>= 0.6.0)
|
|
43
54
|
nokogiri (>= 1.8.5)
|
|
44
|
-
actionview (
|
|
45
|
-
activesupport (=
|
|
55
|
+
actionview (7.1.3.3)
|
|
56
|
+
activesupport (= 7.1.3.3)
|
|
46
57
|
builder (~> 3.1)
|
|
47
|
-
erubi (~> 1.
|
|
48
|
-
rails-dom-testing (~> 2.
|
|
49
|
-
rails-html-sanitizer (~> 1.
|
|
50
|
-
activejob (
|
|
51
|
-
activesupport (=
|
|
58
|
+
erubi (~> 1.11)
|
|
59
|
+
rails-dom-testing (~> 2.2)
|
|
60
|
+
rails-html-sanitizer (~> 1.6)
|
|
61
|
+
activejob (7.1.3.3)
|
|
62
|
+
activesupport (= 7.1.3.3)
|
|
52
63
|
globalid (>= 0.3.6)
|
|
53
|
-
activemodel (
|
|
54
|
-
activesupport (=
|
|
55
|
-
activerecord (
|
|
56
|
-
activemodel (=
|
|
57
|
-
activesupport (=
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
activemodel (7.1.3.3)
|
|
65
|
+
activesupport (= 7.1.3.3)
|
|
66
|
+
activerecord (7.1.3.3)
|
|
67
|
+
activemodel (= 7.1.3.3)
|
|
68
|
+
activesupport (= 7.1.3.3)
|
|
69
|
+
timeout (>= 0.4.0)
|
|
70
|
+
activestorage (7.1.3.3)
|
|
71
|
+
actionpack (= 7.1.3.3)
|
|
72
|
+
activejob (= 7.1.3.3)
|
|
73
|
+
activerecord (= 7.1.3.3)
|
|
74
|
+
activesupport (= 7.1.3.3)
|
|
63
75
|
marcel (~> 1.0)
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
activesupport (7.1.3.3)
|
|
77
|
+
base64
|
|
78
|
+
bigdecimal
|
|
66
79
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
80
|
+
connection_pool (>= 2.2.5)
|
|
81
|
+
drb
|
|
67
82
|
i18n (>= 1.6, < 2)
|
|
68
83
|
minitest (>= 5.1)
|
|
84
|
+
mutex_m
|
|
69
85
|
tzinfo (~> 2.0)
|
|
70
|
-
zeitwerk (~> 2.3)
|
|
71
86
|
ast (2.4.2)
|
|
87
|
+
base64 (0.2.0)
|
|
88
|
+
bigdecimal (3.1.8)
|
|
72
89
|
builder (3.2.4)
|
|
73
90
|
childprocess (0.9.0)
|
|
74
91
|
ffi (~> 1.0, >= 1.0.11)
|
|
75
92
|
coderay (1.1.3)
|
|
76
|
-
concurrent-ruby (1.
|
|
93
|
+
concurrent-ruby (1.2.3)
|
|
94
|
+
connection_pool (2.4.1)
|
|
77
95
|
crass (1.0.6)
|
|
78
|
-
date (3.3.
|
|
96
|
+
date (3.3.4)
|
|
79
97
|
diff-lcs (1.4.4)
|
|
80
|
-
|
|
81
|
-
erubi (1.
|
|
98
|
+
drb (2.2.1)
|
|
99
|
+
erubi (1.12.0)
|
|
82
100
|
factory_bot (4.11.1)
|
|
83
101
|
activesupport (>= 3.0.0)
|
|
84
102
|
factory_bot_rails (4.11.1)
|
|
@@ -110,39 +128,42 @@ GEM
|
|
|
110
128
|
faraday_middleware (1.2.0)
|
|
111
129
|
faraday (~> 1.0)
|
|
112
130
|
ffi (1.15.5)
|
|
113
|
-
globalid (1.1
|
|
114
|
-
activesupport (>=
|
|
115
|
-
i18n (1.
|
|
131
|
+
globalid (1.2.1)
|
|
132
|
+
activesupport (>= 6.1)
|
|
133
|
+
i18n (1.14.5)
|
|
116
134
|
concurrent-ruby (~> 1.0)
|
|
117
135
|
iniparse (1.4.4)
|
|
118
|
-
|
|
136
|
+
io-console (0.7.2)
|
|
137
|
+
irb (1.13.1)
|
|
138
|
+
rdoc (>= 4.0.0)
|
|
139
|
+
reline (>= 0.4.2)
|
|
140
|
+
loofah (2.22.0)
|
|
119
141
|
crass (~> 1.0.2)
|
|
120
|
-
nokogiri (>= 1.
|
|
142
|
+
nokogiri (>= 1.12.0)
|
|
121
143
|
mail (2.8.1)
|
|
122
144
|
mini_mime (>= 0.1.1)
|
|
123
145
|
net-imap
|
|
124
146
|
net-pop
|
|
125
147
|
net-smtp
|
|
126
|
-
marcel (1.0.
|
|
127
|
-
method_source (1.
|
|
128
|
-
mini_mime (1.1.
|
|
129
|
-
mini_portile2 (2.8.
|
|
130
|
-
minitest (5.
|
|
148
|
+
marcel (1.0.4)
|
|
149
|
+
method_source (1.1.0)
|
|
150
|
+
mini_mime (1.1.5)
|
|
151
|
+
mini_portile2 (2.8.6)
|
|
152
|
+
minitest (5.23.1)
|
|
131
153
|
multipart-post (2.3.0)
|
|
132
|
-
|
|
154
|
+
mutex_m (0.2.0)
|
|
155
|
+
net-imap (0.4.11)
|
|
133
156
|
date
|
|
134
157
|
net-protocol
|
|
135
158
|
net-pop (0.1.2)
|
|
136
159
|
net-protocol
|
|
137
|
-
net-protocol (0.
|
|
160
|
+
net-protocol (0.2.2)
|
|
138
161
|
timeout
|
|
139
|
-
net-smtp (0.
|
|
140
|
-
digest
|
|
162
|
+
net-smtp (0.5.0)
|
|
141
163
|
net-protocol
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
mini_portile2 (~> 2.8.0)
|
|
164
|
+
nio4r (2.7.3)
|
|
165
|
+
nokogiri (1.16.5)
|
|
166
|
+
mini_portile2 (~> 2.8.2)
|
|
146
167
|
racc (~> 1.4)
|
|
147
168
|
overcommit (0.46.0)
|
|
148
169
|
childprocess (~> 0.6, >= 0.6.3)
|
|
@@ -155,39 +176,53 @@ GEM
|
|
|
155
176
|
method_source (~> 1.0)
|
|
156
177
|
pry-rails (0.3.9)
|
|
157
178
|
pry (>= 0.10.4)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
179
|
+
psych (5.1.2)
|
|
180
|
+
stringio
|
|
181
|
+
racc (1.8.0)
|
|
182
|
+
rack (3.0.11)
|
|
183
|
+
rack-session (2.0.0)
|
|
184
|
+
rack (>= 3.0.0)
|
|
185
|
+
rack-test (2.1.0)
|
|
161
186
|
rack (>= 1.3)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
rackup (2.1.0)
|
|
188
|
+
rack (>= 3)
|
|
189
|
+
webrick (~> 1.8)
|
|
190
|
+
rails (7.1.3.3)
|
|
191
|
+
actioncable (= 7.1.3.3)
|
|
192
|
+
actionmailbox (= 7.1.3.3)
|
|
193
|
+
actionmailer (= 7.1.3.3)
|
|
194
|
+
actionpack (= 7.1.3.3)
|
|
195
|
+
actiontext (= 7.1.3.3)
|
|
196
|
+
actionview (= 7.1.3.3)
|
|
197
|
+
activejob (= 7.1.3.3)
|
|
198
|
+
activemodel (= 7.1.3.3)
|
|
199
|
+
activerecord (= 7.1.3.3)
|
|
200
|
+
activestorage (= 7.1.3.3)
|
|
201
|
+
activesupport (= 7.1.3.3)
|
|
174
202
|
bundler (>= 1.15.0)
|
|
175
|
-
railties (=
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
203
|
+
railties (= 7.1.3.3)
|
|
204
|
+
rails-dom-testing (2.2.0)
|
|
205
|
+
activesupport (>= 5.0.0)
|
|
206
|
+
minitest
|
|
179
207
|
nokogiri (>= 1.6)
|
|
180
|
-
rails-html-sanitizer (1.
|
|
181
|
-
loofah (~> 2.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
208
|
+
rails-html-sanitizer (1.6.0)
|
|
209
|
+
loofah (~> 2.21)
|
|
210
|
+
nokogiri (~> 1.14)
|
|
211
|
+
railties (7.1.3.3)
|
|
212
|
+
actionpack (= 7.1.3.3)
|
|
213
|
+
activesupport (= 7.1.3.3)
|
|
214
|
+
irb
|
|
215
|
+
rackup (>= 1.0.0)
|
|
186
216
|
rake (>= 12.2)
|
|
187
|
-
thor (~> 1.0)
|
|
217
|
+
thor (~> 1.0, >= 1.2.2)
|
|
218
|
+
zeitwerk (~> 2.6)
|
|
188
219
|
rainbow (3.1.1)
|
|
189
|
-
rake (13.
|
|
220
|
+
rake (13.2.1)
|
|
221
|
+
rdoc (6.6.3.1)
|
|
222
|
+
psych (>= 4.0.0)
|
|
190
223
|
regexp_parser (2.4.0)
|
|
224
|
+
reline (0.5.7)
|
|
225
|
+
io-console (~> 0.5)
|
|
191
226
|
rexml (3.2.5)
|
|
192
227
|
rspec-core (3.10.1)
|
|
193
228
|
rspec-support (~> 3.10.0)
|
|
@@ -221,23 +256,18 @@ GEM
|
|
|
221
256
|
rubocop (>= 0.58.0)
|
|
222
257
|
ruby-progressbar (1.11.0)
|
|
223
258
|
ruby2_keywords (0.0.5)
|
|
224
|
-
sprockets (4.2.0)
|
|
225
|
-
concurrent-ruby (~> 1.0)
|
|
226
|
-
rack (>= 2.2.4, < 4)
|
|
227
|
-
sprockets-rails (3.4.2)
|
|
228
|
-
actionpack (>= 5.2)
|
|
229
|
-
activesupport (>= 5.2)
|
|
230
|
-
sprockets (>= 3.0.0)
|
|
231
259
|
sqlite3 (1.4.2)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
260
|
+
stringio (3.1.0)
|
|
261
|
+
thor (1.3.1)
|
|
262
|
+
timeout (0.4.1)
|
|
263
|
+
tzinfo (2.0.6)
|
|
235
264
|
concurrent-ruby (~> 1.0)
|
|
236
265
|
unicode-display_width (2.1.0)
|
|
266
|
+
webrick (1.8.1)
|
|
237
267
|
websocket-driver (0.7.6)
|
|
238
268
|
websocket-extensions (>= 0.1.0)
|
|
239
269
|
websocket-extensions (0.1.5)
|
|
240
|
-
zeitwerk (2.6.
|
|
270
|
+
zeitwerk (2.6.14)
|
|
241
271
|
|
|
242
272
|
PLATFORMS
|
|
243
273
|
ruby
|
|
@@ -256,4 +286,4 @@ DEPENDENCIES
|
|
|
256
286
|
sqlite3
|
|
257
287
|
|
|
258
288
|
BUNDLED WITH
|
|
259
|
-
2.
|
|
289
|
+
2.5.9
|
data/Rakefile
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ExternalServices
|
|
2
4
|
class ApiAction < ::ActiveRecord::Base
|
|
3
5
|
include ExternalServices::Action
|
|
4
6
|
|
|
5
|
-
MAX_ACTION_AGE = ENV.fetch('EXTERNAL_SERVICES_MAX_ACTION_AGE'
|
|
7
|
+
MAX_ACTION_AGE = ENV.fetch('EXTERNAL_SERVICES_MAX_ACTION_AGE', '90').to_i.days
|
|
6
8
|
|
|
7
9
|
attr_accessor :async
|
|
8
10
|
|
|
@@ -13,8 +15,8 @@ module ExternalServices
|
|
|
13
15
|
validates :initiator_id, :initiator_type, :method, :path, :queue, presence: true
|
|
14
16
|
validate :path_format_correctness
|
|
15
17
|
|
|
16
|
-
serialize :data,
|
|
17
|
-
serialize :options, JSON
|
|
18
|
+
serialize :data, coder: JSON
|
|
19
|
+
serialize :options, coder: JSON
|
|
18
20
|
|
|
19
21
|
scope :to_create, ->(obj) { where(initiator: obj, method: :post) }
|
|
20
22
|
|
|
@@ -90,6 +92,7 @@ module ExternalServices
|
|
|
90
92
|
|
|
91
93
|
def create_or_update(*args)
|
|
92
94
|
return true unless async
|
|
95
|
+
|
|
93
96
|
super
|
|
94
97
|
end
|
|
95
98
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ExternalServices
|
|
2
4
|
class Service < ::ActiveRecord::Base
|
|
3
5
|
self.table_name = :external_services
|
|
4
6
|
|
|
5
7
|
belongs_to :subject, polymorphic: true
|
|
6
|
-
serialize :extra_data, JSON
|
|
8
|
+
serialize :extra_data, coder: JSON
|
|
7
9
|
|
|
8
10
|
after_update :on_first_sync, if: proc { # Rails 5.1+ support
|
|
9
|
-
(respond_to?(:saved_change_to_external_id?) ? saved_change_to_external_id? : external_id_changed?
|
|
10
|
-
|
|
11
|
+
(respond_to?(:saved_change_to_external_id?) ? saved_change_to_external_id? : external_id_changed?) &&
|
|
12
|
+
(respond_to?(:external_id_before_last_save) ? external_id_before_last_save : external_id_was).nil?
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
def self.to_sym
|
|
@@ -22,6 +24,7 @@ module ExternalServices
|
|
|
22
24
|
def on_subject_update(subj)
|
|
23
25
|
method = subj.send("#{api_name}_id").present? ? :put : :post
|
|
24
26
|
return true if (subj.respond_to?(:became_archived?) && subj.became_archived?) && method == :post
|
|
27
|
+
|
|
25
28
|
subj.send("#{api_name}_api_action", method)
|
|
26
29
|
end
|
|
27
30
|
|
data/bin/rails
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
# This command will automatically be run when you run "rails" with Rails gems
|
|
3
5
|
# installed from the root of your application.
|
|
4
6
|
|
|
5
|
-
ENGINE_ROOT = File.expand_path('
|
|
6
|
-
ENGINE_PATH = File.expand_path('
|
|
7
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
|
8
|
+
ENGINE_PATH = File.expand_path('../lib/external_services/engine', __dir__)
|
|
7
9
|
|
|
8
10
|
# Set up gems listed in the Gemfile.
|
|
9
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
|
11
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
|
10
12
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
11
13
|
|
|
12
14
|
require 'rails/all'
|
data/external_services.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/external_services/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'external_services'
|
|
@@ -22,7 +22,9 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
And there is a sidekiq queue clean function, you should use it on Sidekiq start instead of cleaning all Redis db.
|
|
23
23
|
MSG
|
|
24
24
|
|
|
25
|
+
spec.required_ruby_version = '>= 2.7'
|
|
26
|
+
|
|
25
27
|
spec.add_dependency 'faraday', '>= 1.4', '< 2'
|
|
26
28
|
spec.add_dependency 'faraday_middleware', '>= 1.0', '< 2'
|
|
27
|
-
spec.add_dependency 'rails',
|
|
29
|
+
spec.add_dependency 'rails', '>= 4.2.5', '< 8'
|
|
28
30
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ExternalServices
|
|
2
4
|
module ActiveRecord
|
|
3
5
|
module HasExternalService
|
|
@@ -24,13 +26,11 @@ module ExternalServices
|
|
|
24
26
|
extend service_class::SubjectClassMethods if defined? service_class::SubjectClassMethods
|
|
25
27
|
include service_class::SubjectMethods if defined? service_class::SubjectMethods
|
|
26
28
|
|
|
27
|
-
# rubocop:disable Lint/HandleExceptions
|
|
28
29
|
begin
|
|
29
30
|
service_module = const_get(name.to_s.camelize, false)
|
|
30
31
|
include service_module
|
|
31
32
|
rescue NameError
|
|
32
33
|
end
|
|
33
|
-
# rubocop:enable Lint/HandleExceptions
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def includes_external_services
|
|
@@ -106,7 +106,7 @@ module ExternalServices
|
|
|
106
106
|
before_destroy :halt_on_external_services_syncing
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
after_save
|
|
109
|
+
after_save :"#{name}_on_create", if: proc { # Rails 5.1+ support
|
|
110
110
|
respond_to?(:saved_change_to_id?) ? saved_change_to_id? : id_changed?
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -120,7 +120,6 @@ module ExternalServices
|
|
|
120
120
|
define_method :"#{name}_on_create" do
|
|
121
121
|
public_send(service_assoc).on_subject_create(self) unless only_api_actions
|
|
122
122
|
end
|
|
123
|
-
protected :"#{name}_on_create"
|
|
124
123
|
|
|
125
124
|
define_method :"#{name}_on_update" do
|
|
126
125
|
public_send(service_assoc).on_subject_update(self) unless only_api_actions
|
|
@@ -129,17 +128,16 @@ module ExternalServices
|
|
|
129
128
|
define_method :"#{name}_on_destroy" do
|
|
130
129
|
public_send(service_assoc).on_subject_destroy(self) unless only_api_actions
|
|
131
130
|
end
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
end
|
|
131
|
+
|
|
132
|
+
protected
|
|
133
|
+
|
|
134
|
+
def halt_on_external_services_syncing
|
|
135
|
+
return unless external_services_syncing?
|
|
136
|
+
|
|
137
|
+
errors.add :base, :external_services_sync_in_process
|
|
138
|
+
return false if ::ActiveRecord::VERSION::MAJOR < 5
|
|
139
|
+
|
|
140
|
+
throw :abort
|
|
143
141
|
end
|
|
144
142
|
end
|
|
145
143
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
@@ -166,13 +164,13 @@ module ExternalServices
|
|
|
166
164
|
end
|
|
167
165
|
|
|
168
166
|
define_method :external_services_synced? do
|
|
169
|
-
result =
|
|
167
|
+
result = !defined?(super) || super()
|
|
170
168
|
result &&= public_send(synced_method) unless public_send(disabled_method)
|
|
171
169
|
result
|
|
172
170
|
end
|
|
173
171
|
|
|
174
172
|
define_method :external_services_syncing? do
|
|
175
|
-
result =
|
|
173
|
+
result = defined?(super) && super()
|
|
176
174
|
result ||= public_send(syncing_method) unless public_send(disabled_method)
|
|
177
175
|
result
|
|
178
176
|
end
|
|
@@ -217,14 +215,12 @@ module ExternalServices
|
|
|
217
215
|
end
|
|
218
216
|
|
|
219
217
|
define_method :"without_#{name}_api" do |&blk|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
send :"#{name}_api_disabled=", true
|
|
218
|
+
old = send :"#{name}_api_disabled"
|
|
219
|
+
send :"#{name}_api_disabled=", true
|
|
223
220
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
end
|
|
221
|
+
blk.call
|
|
222
|
+
ensure
|
|
223
|
+
send :"#{name}_api_disabled=", old
|
|
228
224
|
end
|
|
229
225
|
|
|
230
226
|
define_method :"find_all_by_#{name}_ids" do |ids|
|
|
@@ -272,13 +268,13 @@ module ExternalServices
|
|
|
272
268
|
|
|
273
269
|
action = "ExternalServices::ApiActions::#{name.to_s.camelize}".constantize.new(
|
|
274
270
|
initiator: self,
|
|
275
|
-
name:
|
|
276
|
-
method:
|
|
277
|
-
path:
|
|
278
|
-
data:
|
|
279
|
-
queue:
|
|
280
|
-
options:
|
|
281
|
-
async:
|
|
271
|
+
name: args[:name] || self.class.send(:"#{name}_api_name"),
|
|
272
|
+
method: method,
|
|
273
|
+
path: path,
|
|
274
|
+
data: data,
|
|
275
|
+
queue: args[:queue],
|
|
276
|
+
options: options,
|
|
277
|
+
async: async
|
|
282
278
|
)
|
|
283
279
|
|
|
284
280
|
if async
|
|
@@ -299,5 +295,5 @@ module ExternalServices
|
|
|
299
295
|
end
|
|
300
296
|
|
|
301
297
|
ActiveSupport.on_load :active_record do
|
|
302
|
-
ActiveRecord::Base.
|
|
298
|
+
ActiveRecord::Base.include ExternalServices::ActiveRecord::HasExternalService
|
|
303
299
|
end
|
data/lib/external_services.rb
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
require 'external_services/version'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
require_relative 'external_services/engine'
|
|
4
|
+
require_relative 'external_services/version'
|
|
5
|
+
|
|
6
|
+
require_relative 'external_services/active_record'
|
|
7
|
+
require_relative 'external_services/api'
|
|
8
|
+
require_relative 'generators/install_generator'
|
|
9
|
+
require_relative 'generators/service_generator'
|
|
8
10
|
|
|
9
11
|
if defined?(::RSpec::Core)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
require_relative 'rspec/configuration'
|
|
13
|
+
require_relative 'rspec/helpers'
|
|
12
14
|
end
|
|
13
15
|
|
|
14
|
-
Dir[File.join(File.expand_path('lib/external_services'), 'api', '*.rb')].each do |api|
|
|
15
|
-
|
|
16
|
+
Dir[File.join(File.expand_path('lib/external_services'), 'api', '*.rb')].sort.each do |api|
|
|
17
|
+
require_relative api
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
module ExternalServices
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rails/generators'
|
|
2
4
|
require 'rails/generators/active_record'
|
|
3
5
|
|
|
@@ -15,7 +17,7 @@ module ExternalServices
|
|
|
15
17
|
return unless Rails::VERSION::MAJOR >= 5
|
|
16
18
|
|
|
17
19
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
|
18
|
-
|
|
20
|
+
end
|
|
19
21
|
|
|
20
22
|
def create_migration_files
|
|
21
23
|
add_migration('create_external_services')
|
data/lib/rspec/configuration.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ExternalServices
|
|
2
4
|
module RSpec
|
|
3
5
|
module Configuration
|
|
@@ -18,4 +20,4 @@ module ExternalServices
|
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
|
-
RSpec::Core::Configuration.
|
|
23
|
+
RSpec::Core::Configuration.include ExternalServices::RSpec::Configuration
|
data/lib/rspec/disabler.rb
CHANGED
data/lib/rspec/helpers.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: external_services
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergey Gnuskov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -59,7 +59,7 @@ dependencies:
|
|
|
59
59
|
version: 4.2.5
|
|
60
60
|
- - "<"
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '
|
|
62
|
+
version: '8'
|
|
63
63
|
type: :runtime
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -69,7 +69,7 @@ dependencies:
|
|
|
69
69
|
version: 4.2.5
|
|
70
70
|
- - "<"
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: '
|
|
72
|
+
version: '8'
|
|
73
73
|
description:
|
|
74
74
|
email:
|
|
75
75
|
- sergey.gnuskov@flant.com
|
|
@@ -125,14 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
125
|
requirements:
|
|
126
126
|
- - ">="
|
|
127
127
|
- !ruby/object:Gem::Version
|
|
128
|
-
version: '
|
|
128
|
+
version: '2.7'
|
|
129
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements:
|
|
131
131
|
- - ">="
|
|
132
132
|
- !ruby/object:Gem::Version
|
|
133
133
|
version: '0'
|
|
134
134
|
requirements: []
|
|
135
|
-
rubygems_version: 3.
|
|
135
|
+
rubygems_version: 3.5.16
|
|
136
136
|
signing_key:
|
|
137
137
|
specification_version: 4
|
|
138
138
|
summary: Gem helps syncronizing objects to different external services like Gitlab,
|