notification-pusher 1.2.6 → 2.0.0
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/README.md +36 -72
- data/lib/generators/notification_pusher/install_generator.rb +1 -2
- data/lib/generators/templates/install/initializer.rb +4 -4
- data/lib/notification-pusher.rb +5 -3
- data/lib/notification_pusher/configuration.rb +13 -6
- data/lib/notification_pusher/delivery_method/base.rb +19 -0
- data/lib/notification_pusher/delivery_method_configuration.rb +28 -0
- data/lib/notification_pusher/notification_lib.rb +49 -0
- metadata +72 -16
- data/lib/notification_pusher/notification_library.rb +0 -46
- data/lib/notification_pusher/pusher.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e7cdafa752302560ca44f108e91f0793090dd77e0d6b5c16edef26a300c14cf
|
4
|
+
data.tar.gz: 216538d4db48bb379512e4946e018cc08285b8dc8520fda96cd757a1b34b7db6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da25af4e364fd5361b67ed6c8350e7927a2175d90ba2cebc95a54201aa6befe2a1eb67e5197eb1120ac5f971e18f9270171b63dd2c9573286c44ad6cbce3a578
|
7
|
+
data.tar.gz: 7bb4f6453c5bf13d080e5194bf2235e7b9c39827d78d000d0ee6134473720410c13d0b60cc1a06d415320d5e07a8c884abacaa40e70d01c9b50ef72f0adc2d64
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# NotificationPusher
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/notification-pusher)
|
3
|
+
[](https://badge.fury.io/rb/notification-pusher) 
|
4
4
|
|
5
|
-
|
5
|
+
Deliver your notifications through various services. Including Email delivery & OneSignal (cross-platform notification delivery).
|
6
6
|
|
7
7
|
---
|
8
8
|
|
@@ -10,15 +10,13 @@ Push your notifications to various services. Including Email, ActionCable, OneSi
|
|
10
10
|
|
11
11
|
* [Installation](#installation)
|
12
12
|
* [Usage](#usage)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
* [Delivery methods](#delivery-methods)
|
14
|
+
* [Defining a delivery method](#defining-a-delivery-method)
|
15
|
+
* [Using a delivery method](#using-a-delivery-method)
|
16
|
+
* [Writing a custom delivery method](#writing-a-custom-delivery-method)
|
17
17
|
* [To Do](#to-do)
|
18
18
|
* [Contributing](#contributing)
|
19
|
-
|
20
|
-
* [Semantic versioning](#semantic-versioning)
|
21
|
-
* [License](#license)
|
19
|
+
* [Semantic versioning](#semantic-versioning)
|
22
20
|
|
23
21
|
---
|
24
22
|
|
@@ -38,12 +36,6 @@ Or install it yourself as:
|
|
38
36
|
|
39
37
|
$ gem install notification-pusher
|
40
38
|
|
41
|
-
If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
|
42
|
-
|
43
|
-
```ruby
|
44
|
-
gem 'notification-pusher', github: 'jonhue/notifications-rails'
|
45
|
-
```
|
46
|
-
|
47
39
|
Now run the generator:
|
48
40
|
|
49
41
|
$ rails g notification_pusher:install
|
@@ -56,81 +48,83 @@ To wrap things up, migrate the changes to your database:
|
|
56
48
|
|
57
49
|
## Usage
|
58
50
|
|
59
|
-
###
|
51
|
+
### Delivery methods
|
60
52
|
|
61
|
-
A
|
53
|
+
A delivery method handles the process of sending your notifications to various services for you.
|
62
54
|
|
63
|
-
#### Defining a
|
55
|
+
#### Defining a delivery method
|
64
56
|
|
65
|
-
You
|
57
|
+
You register delivery methods in your `NotificationPusher` configuration (`config/initializers/notification-pusher.rb`). Using:
|
66
58
|
|
67
59
|
```ruby
|
68
60
|
NotificationPusher.configure do |config|
|
69
|
-
|
61
|
+
config.register_delivery_method name, class_name, options
|
70
62
|
end
|
71
63
|
```
|
72
64
|
|
73
|
-
More details about defining a specific
|
65
|
+
More details about defining a specific delivery method (name and available options) are available in the respective documentation of the gem.
|
74
66
|
|
75
|
-
#### Using a
|
67
|
+
#### Using a delivery method
|
76
68
|
|
77
|
-
It is super simple to initialize a
|
69
|
+
It is super simple to initialize a delivery:
|
78
70
|
|
79
71
|
```ruby
|
80
|
-
notification = Notification.create
|
81
|
-
notification.
|
72
|
+
notification = Notification.create(target: User.first, object: Recipe.first)
|
73
|
+
notification.deliver(name, custom_options)
|
82
74
|
```
|
83
75
|
|
84
|
-
Where `name` is the name of the defined
|
76
|
+
Where `name` is the name of the defined delivery method and `custom_options` are the options that will override the default options the delivery method has been defined with.
|
85
77
|
|
86
78
|
You are also able to do the exact same in just one line of code:
|
87
79
|
|
88
80
|
```ruby
|
89
|
-
notification = Notification.create
|
81
|
+
notification = Notification.create(target: User.first, object: Recipe.first, delivery_method: name, delivery_options: custom_options)
|
90
82
|
```
|
91
83
|
|
92
84
|
**Note:** In this case, pass `custom_options` as a `Hash`.
|
93
85
|
|
94
|
-
It is possible to use mutliple
|
86
|
+
It is possible to use mutliple delivery methods at a time:
|
95
87
|
|
96
88
|
```ruby
|
97
|
-
notification.
|
89
|
+
notification.deliver([name_one, name_two], name_one: custom_options, name_two: custom_options)
|
98
90
|
```
|
99
91
|
|
100
|
-
### Writing a custom
|
92
|
+
### Writing a custom delivery method
|
101
93
|
|
102
|
-
Writing custom
|
94
|
+
Writing custom delivery methods is fairly simple. Just add a new class to the `NotificationPusher::DeliveryMethod` namespace:
|
103
95
|
|
104
96
|
```ruby
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
97
|
+
module NotificationPusher
|
98
|
+
module DeliveryMethod
|
99
|
+
class CustomPusher < NotificationPusher::DeliveryMethod::Base
|
100
|
+
def call
|
101
|
+
# `notification` and `options` are accessible here
|
102
|
+
end
|
109
103
|
end
|
110
|
-
|
104
|
+
end
|
111
105
|
end
|
112
106
|
```
|
113
107
|
|
114
|
-
This is how to
|
108
|
+
This is how to register and use your delivery method:
|
115
109
|
|
116
110
|
```ruby
|
117
111
|
NotificationPusher.configure do |config|
|
118
|
-
|
112
|
+
config.register_delivery_method :custom, :CustomPusher, option_one: 'value_one'
|
119
113
|
end
|
120
114
|
```
|
121
115
|
|
122
116
|
```ruby
|
123
|
-
notification = Notification.create
|
124
|
-
notification.
|
117
|
+
notification = Notification.create(target: User.first, object: Recipe.first)
|
118
|
+
notification.deliver(:custom, option_one: 'value_two')
|
125
119
|
```
|
126
120
|
|
127
|
-
For further reference take a look at the default [ActionMailer](notification-pusher-actionmailer)
|
121
|
+
For further reference take a look at the default [ActionMailer](notification-pusher-actionmailer) and [OneSignal](notification-pusher-onesignal) delivery methods.
|
128
122
|
|
129
123
|
---
|
130
124
|
|
131
125
|
## To Do
|
132
126
|
|
133
|
-
[
|
127
|
+
We use [GitHub projects](https://github.com/jonhue/notifications-rails/projects/3) to coordinate the work on this project.
|
134
128
|
|
135
129
|
To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
|
136
130
|
|
@@ -142,36 +136,6 @@ We hope that you will consider contributing to NotificationPusher. Please read t
|
|
142
136
|
|
143
137
|
[Learn more about contributing to this repository](https://github.com/jonhue/notifications-rails/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/jonhue/notifications-rails/blob/master/CODE_OF_CONDUCT.md)
|
144
138
|
|
145
|
-
### Contributors
|
146
|
-
|
147
|
-
Give the people some :heart: who are working on this project. See them all at:
|
148
|
-
|
149
|
-
https://github.com/jonhue/notifications-rails/graphs/contributors
|
150
|
-
|
151
139
|
### Semantic Versioning
|
152
140
|
|
153
141
|
NotificationPusher follows Semantic Versioning 2.0 as defined at http://semver.org.
|
154
|
-
|
155
|
-
## License
|
156
|
-
|
157
|
-
MIT License
|
158
|
-
|
159
|
-
Copyright (c) 2017 Jonas Hübotter
|
160
|
-
|
161
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
162
|
-
of this software and associated documentation files (the "Software"), to deal
|
163
|
-
in the Software without restriction, including without limitation the rights
|
164
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
165
|
-
copies of the Software, and to permit persons to whom the Software is
|
166
|
-
furnished to do so, subject to the following conditions:
|
167
|
-
|
168
|
-
The above copyright notice and this permission notice shall be included in all
|
169
|
-
copies or substantial portions of the Software.
|
170
|
-
|
171
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
172
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
173
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
174
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
175
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
176
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
177
|
-
SOFTWARE.
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rails/generators'
|
4
|
-
require 'rails/generators/migration'
|
5
4
|
|
6
5
|
module NotificationPusher
|
7
6
|
class InstallGenerator < Rails::Generators::Base
|
@@ -9,7 +8,7 @@ module NotificationPusher
|
|
9
8
|
desc 'Install NotificationPusher'
|
10
9
|
|
11
10
|
def create_initializer
|
12
|
-
template 'initializer.rb', 'config/initializers/
|
11
|
+
template 'initializer.rb', 'config/initializers/notification_pusher.rb'
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
NotificationPusher.configure do |config|
|
4
|
-
# A
|
5
|
-
# services for you.
|
6
|
-
# Learn more: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher#
|
7
|
-
# config.
|
4
|
+
# A delivery method handles the process of sending your notifications to
|
5
|
+
# various services for you.
|
6
|
+
# Learn more: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher#delivery-methods
|
7
|
+
# config.register_delivery_method :email, :ActionMailer, email: 'my@email.com'
|
8
8
|
end
|
data/lib/notification-pusher.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module NotificationPusher
|
4
|
-
|
4
|
+
require_relative 'notification_pusher/configuration'
|
5
5
|
|
6
|
-
|
6
|
+
require_relative 'notification_pusher/delivery_method/base'
|
7
7
|
|
8
|
-
autoload :
|
8
|
+
autoload :DeliveryMethodConfiguration,
|
9
|
+
'notification_pusher/delivery_method_configuration'
|
10
|
+
autoload :NotificationLib, 'notification_pusher/notification_lib'
|
9
11
|
end
|
@@ -1,24 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'delivery_method_configuration'
|
4
|
+
|
3
5
|
module NotificationPusher
|
4
6
|
class << self
|
5
|
-
|
7
|
+
attr_writer :configuration
|
8
|
+
|
9
|
+
def configuration
|
10
|
+
@configuration ||= Configuration.new
|
11
|
+
end
|
6
12
|
end
|
7
13
|
|
8
14
|
def self.configure
|
9
|
-
self.configuration ||= Configuration.new
|
10
15
|
yield configuration
|
11
16
|
end
|
12
17
|
|
13
18
|
class Configuration
|
14
|
-
attr_accessor :
|
19
|
+
attr_accessor :delivery_methods
|
15
20
|
|
16
21
|
def initialize
|
17
|
-
@
|
22
|
+
@delivery_methods = {}
|
18
23
|
end
|
19
24
|
|
20
|
-
def
|
21
|
-
|
25
|
+
def register_delivery_method(name, class_name, options = {})
|
26
|
+
delivery_methods[name.to_sym] =
|
27
|
+
::NotificationPusher::DeliveryMethodConfiguration
|
28
|
+
.new(class_name, options)
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NotificationPusher
|
4
|
+
module DeliveryMethod
|
5
|
+
class Base
|
6
|
+
attr_reader :notification, :options
|
7
|
+
|
8
|
+
def initialize(notification, options = {})
|
9
|
+
@notification = notification
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
raise NotImplementedError,
|
15
|
+
'Implement a `call` method that delivers the notification.'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NotificationPusher
|
4
|
+
class DeliveryMethodConfiguration
|
5
|
+
def initialize(class_name, options = {})
|
6
|
+
@klass = NotificationPusher::DeliveryMethod.const_get(class_name)
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(notification, options = {})
|
11
|
+
options = @options.merge!(options)
|
12
|
+
|
13
|
+
@klass.new(notification, options).call
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.find_by_name(name)
|
17
|
+
NotificationPusher.configuration.delivery_methods[name]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find_by_name!(name)
|
21
|
+
find_by_name(name) ||
|
22
|
+
raise(ArgumentError,
|
23
|
+
"Could not find a registered delivery method for :#{name}. " \
|
24
|
+
'Make sure you register it with ' \
|
25
|
+
"config.register_delivery_method :#{name}, :CustomDeliveryMethod")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'notification-handler'
|
4
|
+
require 'active_support'
|
5
|
+
|
6
|
+
module NotificationPusher
|
7
|
+
module NotificationLib
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
attr_accessor :delivery_method
|
12
|
+
attr_accessor :delivery_options
|
13
|
+
|
14
|
+
after_create_commit :deliver_after_create_commit
|
15
|
+
|
16
|
+
include NotificationPusher::NotificationLib::InstanceMethods
|
17
|
+
end
|
18
|
+
|
19
|
+
module InstanceMethods
|
20
|
+
def deliver(delivery_methods, delivery_options = {})
|
21
|
+
return false unless delivery_methods
|
22
|
+
unless delivery_methods.is_a?(Array)
|
23
|
+
return deliver!(delivery_methods, delivery_options)
|
24
|
+
end
|
25
|
+
|
26
|
+
delivery_methods.each do |delivery_method|
|
27
|
+
deliver(delivery_method,
|
28
|
+
delivery_options[delivery_method.to_sym] || {})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def deliver!(name, options = {})
|
33
|
+
delivery_method = NotificationPusher::DeliveryMethodConfiguration
|
34
|
+
.find_by_name!(name)
|
35
|
+
delivery_method.call(self, options)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# If delivery_method attribute was specified
|
41
|
+
# when object was built/created, deliver using that delivery method
|
42
|
+
def deliver_after_create_commit
|
43
|
+
return if delivery_method.nil?
|
44
|
+
|
45
|
+
deliver(delivery_method, delivery_options || {})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,45 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notification-pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: notification-handler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: factory_bot
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
84
|
+
name: rspec-rails
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
44
86
|
requirements:
|
45
87
|
- - ">="
|
@@ -67,7 +109,21 @@ dependencies:
|
|
67
109
|
- !ruby/object:Gem::Version
|
68
110
|
version: '0'
|
69
111
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop-
|
112
|
+
name: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sqlite3
|
71
127
|
requirement: !ruby/object:Gem::Requirement
|
72
128
|
requirements:
|
73
129
|
- - ">="
|
@@ -80,8 +136,8 @@ dependencies:
|
|
80
136
|
- - ">="
|
81
137
|
- !ruby/object:Gem::Version
|
82
138
|
version: '0'
|
83
|
-
description: Push your notifications to various services. Including Email
|
84
|
-
|
139
|
+
description: Push your notifications to various services. Including Email & OneSignal
|
140
|
+
(cross-platform notifications).
|
85
141
|
email: me@jonhue.me
|
86
142
|
executables: []
|
87
143
|
extensions: []
|
@@ -93,8 +149,9 @@ files:
|
|
93
149
|
- lib/generators/templates/install/initializer.rb
|
94
150
|
- lib/notification-pusher.rb
|
95
151
|
- lib/notification_pusher/configuration.rb
|
96
|
-
- lib/notification_pusher/
|
97
|
-
- lib/notification_pusher/
|
152
|
+
- lib/notification_pusher/delivery_method/base.rb
|
153
|
+
- lib/notification_pusher/delivery_method_configuration.rb
|
154
|
+
- lib/notification_pusher/notification_lib.rb
|
98
155
|
homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher
|
99
156
|
licenses:
|
100
157
|
- MIT
|
@@ -114,8 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
171
|
- !ruby/object:Gem::Version
|
115
172
|
version: '0'
|
116
173
|
requirements: []
|
117
|
-
|
118
|
-
rubygems_version: 2.7.6
|
174
|
+
rubygems_version: 3.0.3
|
119
175
|
signing_key:
|
120
176
|
specification_version: 4
|
121
177
|
summary: Push your notifications to various services
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'notification-handler'
|
4
|
-
require 'active_support'
|
5
|
-
|
6
|
-
module NotificationPusher
|
7
|
-
module NotificationLibrary
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
included do
|
11
|
-
attr_accessor :pusher
|
12
|
-
attr_accessor :pusher_options
|
13
|
-
|
14
|
-
after_create_commit :initialize_pusher
|
15
|
-
|
16
|
-
include NotificationPusher::NotificationLibrary::InstanceMethods
|
17
|
-
end
|
18
|
-
|
19
|
-
module InstanceMethods
|
20
|
-
def push(name, options = {})
|
21
|
-
self.pusher = name
|
22
|
-
self.pusher_options = options
|
23
|
-
initialize_pusher
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def initialize_pusher
|
29
|
-
return if pusher.nil?
|
30
|
-
|
31
|
-
if pusher.is_a?(Array)
|
32
|
-
pusher.each do |class_name|
|
33
|
-
initiate_push(class_name, pusher_options[class_name.to_sym])
|
34
|
-
end
|
35
|
-
else
|
36
|
-
initiate_push(pusher, pusher_options)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def initiate_push(class_name, options = {})
|
41
|
-
pusher = NotificationPusher::Pusher.find_by_name(class_name).first
|
42
|
-
pusher.push(self, options)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module NotificationPusher
|
4
|
-
class Pusher
|
5
|
-
attr_reader :name
|
6
|
-
|
7
|
-
def initialize(name, options = {})
|
8
|
-
@instances = []
|
9
|
-
@name = name
|
10
|
-
@options = options
|
11
|
-
end
|
12
|
-
|
13
|
-
def push(notification, options = {})
|
14
|
-
options = @options.merge!(options)
|
15
|
-
|
16
|
-
return unless defined?(NotificationPusher.const_get(@name))
|
17
|
-
instance = NotificationPusher.const_get(@name).new(notification, options)
|
18
|
-
@instances << instance
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.find_by_name(name)
|
22
|
-
NotificationPusher.configuration.pushers.select do |pusher|
|
23
|
-
pusher.name == name
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|