unotifier 0.2.2 → 0.2.3
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/Gemfile.lock +1 -1
- data/lib/provider/action_cable.rb +4 -2
- data/lib/provider/action_mailer.rb +4 -2
- data/lib/provider/provider_base.rb +14 -0
- data/lib/provider.rb +1 -0
- data/lib/unotifier/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8d0d6e9fbcd78989dedfe9692b6995501e6dda0dccfc46c01e8a0d013a568d4
|
4
|
+
data.tar.gz: bda785e4df5defce86a8741753825b5cfe2d0c8e0bfcdd1025fcb245892f74d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82eaf6528bd654344a4927624d694a824f1e2832a0a251b5e760d8a3f38bcafdab6978c18405499a8994c78a7defbfda64986105d45e8843a33f3594edd31a4a
|
7
|
+
data.tar.gz: 4f0d4e2f18c0d501334cc046fd501d4588e7dcf1578f44c5b8a11ae4232aeb89d14faf1381cf291e3eecd11798f293b6a17e1a2472498638a7391c1c9b7f0ed6
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module UNotifier
|
2
2
|
module Provider
|
3
|
-
class ActionCable
|
3
|
+
class ActionCable < ProviderBase
|
4
4
|
attr_reader :server
|
5
5
|
attr_accessor :autohide_delay, :channel_name
|
6
6
|
|
7
|
-
def initialize(server, channel_name: nil, autohide_delay: 30)
|
7
|
+
def initialize(server, channel_name: nil, autohide_delay: 30, notification_conditions: [])
|
8
|
+
super(notification_conditions: notification_conditions)
|
8
9
|
@server = server
|
9
10
|
@autohide_delay = autohide_delay
|
10
11
|
@channel_name =
|
@@ -13,6 +14,7 @@ module UNotifier
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def notify(notification)
|
17
|
+
return unless can_notify?(notification)
|
16
18
|
if notification.target.online?
|
17
19
|
@server.broadcast @channel_name.call(notification), serialize_notification(notification)
|
18
20
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module UNotifier
|
2
2
|
module Provider
|
3
|
-
class ActionMailer
|
4
|
-
def initialize(mailer, sending_method: :new_notification)
|
3
|
+
class ActionMailer < ProviderBase
|
4
|
+
def initialize(mailer, sending_method: :new_notification, notification_conditions: [])
|
5
|
+
super(notification_conditions: notification_conditions)
|
5
6
|
@mailer = mailer
|
6
7
|
@sending_method = sending_method
|
7
8
|
end
|
8
9
|
|
9
10
|
def notify(notification)
|
11
|
+
return unless can_notify?(notification)
|
10
12
|
@mailer.public_send(@sending_method, notification).deliver
|
11
13
|
end
|
12
14
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module UNotifier
|
2
|
+
module Provider
|
3
|
+
class ProviderBase
|
4
|
+
def initialize(notification_conditions: [])
|
5
|
+
@notification_conditions = notification_conditions
|
6
|
+
end
|
7
|
+
|
8
|
+
def can_notify?(target)
|
9
|
+
return true if @notification_conditions.empty?
|
10
|
+
@notification_conditions.all? { |c| c.call(target) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/provider.rb
CHANGED
data/lib/unotifier/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unotifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Rashev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/provider.rb
|
121
121
|
- lib/provider/action_cable.rb
|
122
122
|
- lib/provider/action_mailer.rb
|
123
|
+
- lib/provider/provider_base.rb
|
123
124
|
- lib/settings.rb
|
124
125
|
- lib/unotifier.rb
|
125
126
|
- lib/unotifier/version.rb
|