nuntius 1.1.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -4
- data/app/providers/nuntius/teams_teams_provider.rb +1 -0
- data/lib/nuntius/active_record_helpers.rb +3 -2
- data/lib/nuntius/devise.rb +5 -4
- data/lib/nuntius/engine.rb +0 -1
- data/lib/nuntius/life_cycle.rb +28 -0
- data/lib/nuntius/state_machine.rb +27 -5
- data/lib/nuntius/version.rb +1 -1
- metadata +15 -29
- data/lib/nuntius/transactio.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa439d75f1be61c5122338f9d0c2c74b68d016e91208756d9ad2be119845ad51
|
4
|
+
data.tar.gz: 164ff8b68eb4912eaabade99a3ee39e593d5c2274345211601dccf14d6bb11c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f40c494fc93610eee81a49f8b648b7cb3dafa8be578b051d24cfa8a052536ce69f6eb252df05eb98c5367bd28fe10c5109ad668b10efde3b015355282293e92
|
7
|
+
data.tar.gz: 65088baae2f8f957ac6dab1c14d9945d43e594149c9074d257d4a1db5f6f582a02801642c4348c3cd8b2a5c02c93ade63599d61d474869e30920a06e2d75cbd6
|
data/Rakefile
CHANGED
@@ -6,6 +6,7 @@ module Nuntius
|
|
6
6
|
|
7
7
|
def deliver
|
8
8
|
# NOTE: Attachments are not supported
|
9
|
+
# https://adaptivecards.io/designer/
|
9
10
|
# https://learn.microsoft.com/en-us/power-automate/overview-adaptive-cards
|
10
11
|
# https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=newteams%2Cdotnet
|
11
12
|
|
@@ -3,7 +3,8 @@
|
|
3
3
|
require_relative "nuntiable"
|
4
4
|
require_relative "devise"
|
5
5
|
require_relative "state_machine"
|
6
|
-
require_relative "
|
6
|
+
require_relative "life_cycle"
|
7
|
+
# require_relative "transactio"
|
7
8
|
|
8
9
|
module Nuntius::ActiveRecordHelpers
|
9
10
|
extend ActiveSupport::Concern
|
@@ -18,7 +19,7 @@ module Nuntius::ActiveRecordHelpers
|
|
18
19
|
include Nuntius::Nuntiable
|
19
20
|
include Nuntius::StateMachine if options[:use_state_machine]
|
20
21
|
include Nuntius::Devise if options[:override_devise]
|
21
|
-
include Nuntius::
|
22
|
+
include Nuntius::LifeCycle if options[:life_cycle]
|
22
23
|
end
|
23
24
|
|
24
25
|
def nuntiable?
|
data/lib/nuntius/devise.rb
CHANGED
@@ -7,12 +7,13 @@ module Nuntius
|
|
7
7
|
included do
|
8
8
|
raise "#{name} must be nuntiable" unless nuntiable?
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
I18n.t('devise.mailer').keys.map(&:to_s).each do |event_name|
|
11
|
+
messenger.send(:define_method, event_name) { |object, options = {}| }
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
+
define_method(:send_devise_notification) do |notification, *devise_params|
|
14
15
|
# All notifications have either a token as the first param, or nothing
|
15
|
-
Nuntius.event(notification, self, {token: devise_params.first})
|
16
|
+
Nuntius.event(notification, self, { token: devise_params.first })
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/lib/nuntius/engine.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nuntius
|
4
|
+
module LifeCycle
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
raise "#{name} must be nuntiable" unless nuntiable?
|
9
|
+
|
10
|
+
after_commit do
|
11
|
+
if previously_persisted?
|
12
|
+
Nuntius.event(:destroy, self)
|
13
|
+
elsif previously_new_record?
|
14
|
+
Nuntius.event(:create, self)
|
15
|
+
Nuntius.event(:save, self)
|
16
|
+
else
|
17
|
+
Nuntius.event(:update, self)
|
18
|
+
Nuntius.event(:save, self)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
%i[create destroy update save].each do |event_name|
|
23
|
+
next if messenger.method_defined?(event_name)
|
24
|
+
messenger.send(:define_method, event_name) { |object, options = {}| }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,18 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nuntius
|
4
|
+
|
4
5
|
module StateMachine
|
5
6
|
extend ActiveSupport::Concern
|
6
7
|
|
7
8
|
included do
|
8
9
|
raise "#{name} must be nuntiable" unless nuntiable?
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
state_machine.events.map(&:name)
|
12
|
+
.reject { |event_name| messenger.method_defined?(event_name) }
|
13
|
+
.each do |event_name|
|
14
|
+
messenger.send(:define_method, event_name) { |object, options = {}| }
|
15
|
+
end
|
16
|
+
|
17
|
+
after_commit do
|
18
|
+
Thread.current['___nuntius_state_machine_events']&.each do |event|
|
19
|
+
Nuntius.event(event[:event], event[:object])
|
20
|
+
end
|
21
|
+
# After events are fired we can clear the events
|
22
|
+
Thread.current['___nuntius_state_machine_events'] = []
|
23
|
+
end
|
24
|
+
|
25
|
+
state_machine do
|
26
|
+
# This records events within the same thread, and clears them in the same thread.
|
27
|
+
# A different thread is a different transaction.
|
28
|
+
after_transition any => any do |record, transition|
|
29
|
+
___record__nuntius_state_machine_event(transition.event, record)
|
30
|
+
___record__nuntius_state_machine_event(:update, record)
|
31
|
+
___record__nuntius_state_machine_event(:save, record)
|
32
|
+
end
|
12
33
|
|
13
|
-
|
14
|
-
|
15
|
-
|
34
|
+
def ___record__nuntius_state_machine_event(event, object)
|
35
|
+
Thread.current['___nuntius_state_machine_events'] ||= []
|
36
|
+
Thread.current['___nuntius_state_machine_events'] << { event: event, object: object }
|
37
|
+
end
|
16
38
|
end
|
17
39
|
end
|
18
40
|
end
|
data/lib/nuntius/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nuntius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom de Grunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apnotic
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.56'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: evento
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: fcm
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +140,16 @@ dependencies:
|
|
154
140
|
name: labelary
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
|
-
- - "
|
143
|
+
- - "~>"
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
145
|
+
version: '0.5'
|
160
146
|
type: :runtime
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
|
-
- - "
|
150
|
+
- - "~>"
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
152
|
+
version: '0.5'
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: liquidum
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,16 +224,16 @@ dependencies:
|
|
238
224
|
name: parse-cron
|
239
225
|
requirement: !ruby/object:Gem::Requirement
|
240
226
|
requirements:
|
241
|
-
- - "
|
227
|
+
- - "~>"
|
242
228
|
- !ruby/object:Gem::Version
|
243
|
-
version: '0'
|
229
|
+
version: '0.1'
|
244
230
|
type: :runtime
|
245
231
|
prerelease: false
|
246
232
|
version_requirements: !ruby/object:Gem::Requirement
|
247
233
|
requirements:
|
248
|
-
- - "
|
234
|
+
- - "~>"
|
249
235
|
- !ruby/object:Gem::Version
|
250
|
-
version: '0'
|
236
|
+
version: '0.1'
|
251
237
|
- !ruby/object:Gem::Dependency
|
252
238
|
name: pg
|
253
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -266,16 +252,16 @@ dependencies:
|
|
266
252
|
name: premailer
|
267
253
|
requirement: !ruby/object:Gem::Requirement
|
268
254
|
requirements:
|
269
|
-
- - "
|
255
|
+
- - "~>"
|
270
256
|
- !ruby/object:Gem::Version
|
271
|
-
version: '
|
257
|
+
version: '1.23'
|
272
258
|
type: :runtime
|
273
259
|
prerelease: false
|
274
260
|
version_requirements: !ruby/object:Gem::Requirement
|
275
261
|
requirements:
|
276
|
-
- - "
|
262
|
+
- - "~>"
|
277
263
|
- !ruby/object:Gem::Version
|
278
|
-
version: '
|
264
|
+
version: '1.23'
|
279
265
|
- !ruby/object:Gem::Dependency
|
280
266
|
name: rails
|
281
267
|
requirement: !ruby/object:Gem::Requirement
|
@@ -551,11 +537,11 @@ files:
|
|
551
537
|
- lib/nuntius/devise.rb
|
552
538
|
- lib/nuntius/engine.rb
|
553
539
|
- lib/nuntius/i18n_store.rb
|
540
|
+
- lib/nuntius/life_cycle.rb
|
554
541
|
- lib/nuntius/liquid/tags/attach_tag.rb
|
555
542
|
- lib/nuntius/mail_allow_list.rb
|
556
543
|
- lib/nuntius/nuntiable.rb
|
557
544
|
- lib/nuntius/state_machine.rb
|
558
|
-
- lib/nuntius/transactio.rb
|
559
545
|
- lib/nuntius/version.rb
|
560
546
|
- lib/preamble.rb
|
561
547
|
- lib/tasks/nuntius_tasks.rake
|
data/lib/nuntius/transactio.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nuntius
|
4
|
-
module Transactio
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
raise "#{name} must be nuntiable" unless nuntiable?
|
9
|
-
|
10
|
-
orchestrator = Evento::Orchestrator.new(self)
|
11
|
-
if nuntiable_options[:life_cycle]
|
12
|
-
orchestrator.define_event_methods_on(messenger, life_cycle: true) do |object, options = {}|
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
orchestrator = Evento::Orchestrator.new(self)
|
17
|
-
orchestrator.after_transaction_log_commit(:nuntius) do |transaction_log_entry|
|
18
|
-
resource = transaction_log_entry.transaction_loggable
|
19
|
-
event = transaction_log_entry.event
|
20
|
-
|
21
|
-
if resource.present? && event.present? && resource.nuntiable?
|
22
|
-
params = Nuntius.config.default_params(transaction_log_entry)
|
23
|
-
|
24
|
-
Nuntius.event(event, resource, params)
|
25
|
-
Nuntius.event("save", resource, params) if %w[create update].include?(event)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|