notification-pusher 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -100
- data/lib/notifications-rails.rb +6 -0
- metadata +9 -16
- data/lib/generators/notification_pusher/install_generator.rb +0 -14
- data/lib/generators/templates/install/initializer.rb +0 -8
- data/lib/notification-pusher.rb +0 -11
- data/lib/notification_pusher/configuration.rb +0 -31
- data/lib/notification_pusher/delivery_method/base.rb +0 -19
- data/lib/notification_pusher/delivery_method_configuration.rb +0 -28
- data/lib/notification_pusher/notification_lib.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3842033c487c47b11953e242d24ab55acd82c280898073090a5d468a9a2118e
|
4
|
+
data.tar.gz: 779daa39294bee3fb49a7601bcba73177f6c9d6374c49b0ae8a4e1c9f72eab63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b875353d7805d0e4ae050f169ce5c65903e14828037c0779616722cfe7e362f68fa234f59e39c4f6490c12dc50bad058fa3815e5c78a5980240a6016ea2d874
|
7
|
+
data.tar.gz: 22641a2181d63da3a2b2747025d290b65ba74adfcef002a57102e0df9ecea320efbb9dd8fdfb769a2060a9e122f5315a0987803d889d25cee4ef589778d31ca0
|
data/README.md
CHANGED
@@ -1,141 +1,84 @@
|
|
1
|
-
#
|
1
|
+
# notifications-rails
|
2
2
|
|
3
|
-
|
3
|
+
notifications-rails is the most powerful notification library for Rails. It offers not only simple APIs to create and render notifications but also supports user-integration and cross-platform delivery of notifications.
|
4
4
|
|
5
|
-
|
5
|
+
## Philosophy
|
6
6
|
|
7
|
-
|
7
|
+
notifications-rails has been built with modularity in mind. It currently consists of four components each of which bringing one essential functionality to the integration of notifications in your Rails app.
|
8
8
|
|
9
|
-
|
9
|
+
**[notification-handler](notification-handler):** Create and modify your notifications through a simple API.
|
10
10
|
|
11
|
-
|
12
|
-
* [Usage](#usage)
|
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
|
-
* [To Do](#to-do)
|
18
|
-
* [Contributing](#contributing)
|
19
|
-
* [Semantic versioning](#semantic-versioning)
|
11
|
+
**[notification-renderer](notification-renderer):** Render your notifications in various contexts.
|
20
12
|
|
21
|
-
|
13
|
+
**[notification-pusher](notification-pusher):** Deliver your notifications to various services, including [Email](notification-pusher/notification-pusher-actionmailer) and [OneSignal](notification-pusher/notification-pusher-onesignal).
|
22
14
|
|
23
|
-
|
24
|
-
|
25
|
-
NotificationPusher works with Rails 5 onwards. You can add it to your `Gemfile` with:
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
gem 'notification-pusher'
|
29
|
-
```
|
30
|
-
|
31
|
-
And then execute:
|
32
|
-
|
33
|
-
$ bundle
|
34
|
-
|
35
|
-
Or install it yourself as:
|
36
|
-
|
37
|
-
$ gem install notification-pusher
|
38
|
-
|
39
|
-
Now run the generator:
|
40
|
-
|
41
|
-
$ rails g notification_pusher:install
|
42
|
-
|
43
|
-
To wrap things up, migrate the changes to your database:
|
44
|
-
|
45
|
-
$ rails db:migrate
|
46
|
-
|
47
|
-
---
|
48
|
-
|
49
|
-
## Usage
|
15
|
+
**[notification-settings](notification-settings):** Integrates with your authentication solution to craft a personalized user notification platform.
|
50
16
|
|
51
|
-
|
17
|
+
You may just use the components you actually need, or instead use this gem to bundle everything for a complete notification solution.
|
52
18
|
|
53
|
-
|
54
|
-
|
55
|
-
#### Defining a delivery method
|
19
|
+
## Installation
|
56
20
|
|
57
|
-
You
|
21
|
+
You can add notifications-rails to your `Gemfile` with:
|
58
22
|
|
59
23
|
```ruby
|
60
|
-
|
61
|
-
config.register_delivery_method name, class_name, options
|
62
|
-
end
|
24
|
+
gem 'notifications-rails'
|
63
25
|
```
|
64
26
|
|
65
|
-
|
66
|
-
|
67
|
-
#### Using a delivery method
|
27
|
+
And then run:
|
68
28
|
|
69
|
-
|
29
|
+
$ bundle install
|
70
30
|
|
71
|
-
|
72
|
-
notification = Notification.create(target: User.first, object: Recipe.first)
|
73
|
-
notification.deliver(name, custom_options)
|
74
|
-
```
|
31
|
+
Or install it yourself as:
|
75
32
|
|
76
|
-
|
33
|
+
$ gem install notifications-rails
|
77
34
|
|
78
|
-
|
35
|
+
If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
|
79
36
|
|
80
37
|
```ruby
|
81
|
-
|
38
|
+
gem 'notifications-rails', github: 'jonhue/notifications-rails'
|
82
39
|
```
|
83
40
|
|
84
|
-
|
41
|
+
## Usage
|
85
42
|
|
86
|
-
|
43
|
+
Details on usage are provided in the [documentation](#philosophy) of the specific modules.
|
87
44
|
|
88
|
-
|
89
|
-
notification.deliver([name_one, name_two], name_one: custom_options, name_two: custom_options)
|
90
|
-
```
|
45
|
+
## Development
|
91
46
|
|
92
|
-
|
47
|
+
To start development you first have to fork this repository and locally clone your fork.
|
93
48
|
|
94
|
-
|
49
|
+
Install the projects dependencies by running:
|
95
50
|
|
96
|
-
|
97
|
-
module NotificationPusher
|
98
|
-
module DeliveryMethod
|
99
|
-
class CustomPusher < NotificationPusher::DeliveryMethod::Base
|
100
|
-
def call
|
101
|
-
# `notification` and `options` are accessible here
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
```
|
51
|
+
$ bundle install
|
107
52
|
|
108
|
-
|
53
|
+
### Testing
|
109
54
|
|
110
|
-
|
111
|
-
NotificationPusher.configure do |config|
|
112
|
-
config.register_delivery_method :custom, :CustomPusher, option_one: 'value_one'
|
113
|
-
end
|
114
|
-
```
|
55
|
+
Tests are written with RSpec. Integration tests are located in `/spec`, unit tests can be found in `<module>/spec`.
|
115
56
|
|
116
|
-
|
117
|
-
notification = Notification.create(target: User.first, object: Recipe.first)
|
118
|
-
notification.deliver(:custom, option_one: 'value_two')
|
119
|
-
```
|
57
|
+
To run all tests:
|
120
58
|
|
121
|
-
|
59
|
+
$ ./rspec
|
122
60
|
|
123
|
-
|
61
|
+
To run RuboCop:
|
124
62
|
|
125
|
-
|
63
|
+
$ bundle exec rubocop
|
126
64
|
|
127
|
-
|
65
|
+
You can find all commands run by the CI workflow in `.github/workflows/ci.yml`.
|
128
66
|
|
129
|
-
|
67
|
+
## Contributing
|
130
68
|
|
131
|
-
|
69
|
+
We warmly welcome everyone who is intersted in contributing. Please reference our [contributing guidelines](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md).
|
132
70
|
|
133
|
-
##
|
71
|
+
## Releases
|
134
72
|
|
135
|
-
|
73
|
+
[Here](https://github.com/jonhue/notifications-rails/releases) you can find details on all past releases. Unreleased breaking changes that are on the current master can be found [here](CHANGELOG.md).
|
136
74
|
|
137
|
-
|
75
|
+
notifications-rails follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our [security policy](SECURITY.md).
|
138
76
|
|
139
|
-
###
|
77
|
+
### Publishing
|
140
78
|
|
141
|
-
|
79
|
+
1. Review breaking changes and deprecations in `CHANGELOG.md`.
|
80
|
+
1. Change the gem version in `VERSION`.
|
81
|
+
1. Reset `CHANGELOG.md`.
|
82
|
+
1. Create a pull request to merge the changes into `master`.
|
83
|
+
1. After the pull request was merged, create a new release listing the breaking changes and commits on `master` since the last release.
|
84
|
+
1. The release workflow will publish the gems to RubyGems.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notification-pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
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: 2020-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.0.
|
33
|
+
version: 3.0.3
|
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: 3.0.
|
40
|
+
version: 3.0.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: factory_bot
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,22 +136,15 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description:
|
140
|
-
|
141
|
-
email: me@jonhue.me
|
139
|
+
description: Deliver your notifications to various services.
|
140
|
+
email: jonas.huebotter@gmail.com
|
142
141
|
executables: []
|
143
142
|
extensions: []
|
144
143
|
extra_rdoc_files: []
|
145
144
|
files:
|
146
145
|
- LICENSE
|
147
146
|
- README.md
|
148
|
-
- lib/
|
149
|
-
- lib/generators/templates/install/initializer.rb
|
150
|
-
- lib/notification-pusher.rb
|
151
|
-
- lib/notification_pusher/configuration.rb
|
152
|
-
- lib/notification_pusher/delivery_method/base.rb
|
153
|
-
- lib/notification_pusher/delivery_method_configuration.rb
|
154
|
-
- lib/notification_pusher/notification_lib.rb
|
147
|
+
- lib/notifications-rails.rb
|
155
148
|
homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher
|
156
149
|
licenses:
|
157
150
|
- MIT
|
@@ -172,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
165
|
- !ruby/object:Gem::Version
|
173
166
|
version: '0'
|
174
167
|
requirements: []
|
175
|
-
rubygems_version: 3.
|
168
|
+
rubygems_version: 3.1.4
|
176
169
|
signing_key:
|
177
170
|
specification_version: 4
|
178
|
-
summary:
|
171
|
+
summary: Deliver your notifications to various services
|
179
172
|
test_files: []
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators'
|
4
|
-
|
5
|
-
module NotificationPusher
|
6
|
-
class InstallGenerator < Rails::Generators::Base
|
7
|
-
source_root(File.join(File.dirname(__FILE__), '../templates/install'))
|
8
|
-
desc 'Install NotificationPusher'
|
9
|
-
|
10
|
-
def create_initializer
|
11
|
-
template 'initializer.rb', 'config/initializers/notification_pusher.rb'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
NotificationPusher.configure do |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
|
-
end
|
data/lib/notification-pusher.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module NotificationPusher
|
4
|
-
require_relative 'notification_pusher/configuration'
|
5
|
-
|
6
|
-
require_relative 'notification_pusher/delivery_method/base'
|
7
|
-
|
8
|
-
autoload :DeliveryMethodConfiguration,
|
9
|
-
'notification_pusher/delivery_method_configuration'
|
10
|
-
autoload :NotificationLib, 'notification_pusher/notification_lib'
|
11
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'delivery_method_configuration'
|
4
|
-
|
5
|
-
module NotificationPusher
|
6
|
-
class << self
|
7
|
-
attr_writer :configuration
|
8
|
-
|
9
|
-
def configuration
|
10
|
-
@configuration ||= Configuration.new
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.configure
|
15
|
-
yield configuration
|
16
|
-
end
|
17
|
-
|
18
|
-
class Configuration
|
19
|
-
attr_accessor :delivery_methods
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
@delivery_methods = {}
|
23
|
-
end
|
24
|
-
|
25
|
-
def register_delivery_method(name, class_name, options = {})
|
26
|
-
delivery_methods[name.to_sym] =
|
27
|
-
::NotificationPusher::DeliveryMethodConfiguration
|
28
|
-
.new(class_name, options)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,28 +0,0 @@
|
|
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
|
@@ -1,49 +0,0 @@
|
|
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
|