notification-pusher 2.0.0 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e7cdafa752302560ca44f108e91f0793090dd77e0d6b5c16edef26a300c14cf
4
- data.tar.gz: 216538d4db48bb379512e4946e018cc08285b8dc8520fda96cd757a1b34b7db6
3
+ metadata.gz: dcfdb42230850ccffc65b62fafa5eb33a34521b02ba059bcd65228b05158c297
4
+ data.tar.gz: 693797fd5bc617873445f3b69d78277f116db1a74f492789b350476a9936d018
5
5
  SHA512:
6
- metadata.gz: da25af4e364fd5361b67ed6c8350e7927a2175d90ba2cebc95a54201aa6befe2a1eb67e5197eb1120ac5f971e18f9270171b63dd2c9573286c44ad6cbce3a578
7
- data.tar.gz: 7bb4f6453c5bf13d080e5194bf2235e7b9c39827d78d000d0ee6134473720410c13d0b60cc1a06d415320d5e07a8c884abacaa40e70d01c9b50ef72f0adc2d64
6
+ metadata.gz: d4056c9de6ec67d2843b471aa5d526b8d7d4cb88a1b0529a4b23a2cf7538aa2b892932e5b66bdeaa4caff0d0ca46844514f68ab3fc832c75e0ea75a7064c05e3
7
+ data.tar.gz: 32272f2035d41d80c47fcc114dde8e2ee0e18215e3bd62e669460216a464599b42709b08e5c81aafcdfabe53e1585fd69011256f72f0c4616ea757d1665cb2f8
data/README.md CHANGED
@@ -1,141 +1,84 @@
1
- # NotificationPusher
1
+ # notifications-rails
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/notification-pusher.svg)](https://badge.fury.io/rb/notification-pusher) ![Travis](https://travis-ci.com/jonhue/notifications-rails.svg?branch=master)
3
+ A flexible notification library supporting the delivery to external services, rendering in various environments, and user configuration by category.
4
4
 
5
- Deliver your notifications through various services. Including Email delivery & OneSignal (cross-platform notification delivery).
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
- ## Table of Contents
9
+ **[notification-handler](notification-handler):** Create and modify your notifications through a simple API.
10
10
 
11
- * [Installation](#installation)
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
- ## Installation
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
- ### Delivery methods
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
- A delivery method handles the process of sending your notifications to various services for you.
54
-
55
- #### Defining a delivery method
19
+ ## Installation
56
20
 
57
- You register delivery methods in your `NotificationPusher` configuration (`config/initializers/notification-pusher.rb`). Using:
21
+ You can add notifications-rails to your `Gemfile` with:
58
22
 
59
23
  ```ruby
60
- NotificationPusher.configure do |config|
61
- config.register_delivery_method name, class_name, options
62
- end
24
+ gem 'notifications-rails'
63
25
  ```
64
26
 
65
- More details about defining a specific delivery method (name and available options) are available in the respective documentation of the gem.
66
-
67
- #### Using a delivery method
27
+ And then run:
68
28
 
69
- It is super simple to initialize a delivery:
29
+ $ bundle install
70
30
 
71
- ```ruby
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
- 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.
33
+ $ gem install notifications-rails
77
34
 
78
- You are also able to do the exact same in just one line of code:
35
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
79
36
 
80
37
  ```ruby
81
- notification = Notification.create(target: User.first, object: Recipe.first, delivery_method: name, delivery_options: custom_options)
38
+ gem 'notifications-rails', github: 'jonhue/notifications-rails'
82
39
  ```
83
40
 
84
- **Note:** In this case, pass `custom_options` as a `Hash`.
41
+ ## Usage
85
42
 
86
- It is possible to use mutliple delivery methods at a time:
43
+ Details on usage are provided in the [documentation](#philosophy) of the specific modules.
87
44
 
88
- ```ruby
89
- notification.deliver([name_one, name_two], name_one: custom_options, name_two: custom_options)
90
- ```
45
+ ## Development
91
46
 
92
- ### Writing a custom delivery method
47
+ To start development you first have to fork this repository and locally clone your fork.
93
48
 
94
- Writing custom delivery methods is fairly simple. Just add a new class to the `NotificationPusher::DeliveryMethod` namespace:
49
+ Install the projects dependencies by running:
95
50
 
96
- ```ruby
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
- This is how to register and use your delivery method:
53
+ ### Testing
109
54
 
110
- ```ruby
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
- ```ruby
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
- For further reference take a look at the default [ActionMailer](notification-pusher-actionmailer) and [OneSignal](notification-pusher-onesignal) delivery methods.
59
+ $ ./rspec
122
60
 
123
- ---
61
+ To run RuboCop:
124
62
 
125
- ## To Do
63
+ $ bundle exec rubocop
126
64
 
127
- We use [GitHub projects](https://github.com/jonhue/notifications-rails/projects/3) to coordinate the work on this project.
65
+ You can find all commands run by the CI workflow in `.github/workflows/ci.yml`.
128
66
 
129
- To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
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
- ## Contributing
71
+ ## Releases
134
72
 
135
- We hope that you will consider contributing to NotificationPusher. Please read this short overview for some information about how to get started:
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
- [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)
75
+ notifications-rails follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our [security policy](SECURITY.md).
138
76
 
139
- ### Semantic Versioning
77
+ ### Publishing
140
78
 
141
- NotificationPusher follows Semantic Versioning 2.0 as defined at http://semver.org.
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.
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'notification-handler'
4
+ require 'notification-renderer'
5
+ require 'notification-pusher'
6
+ require 'notification-settings'
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: 2.0.0
4
+ version: 4.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: 2019-06-04 00:00:00.000000000 Z
11
+ date: 2022-04-24 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: 2.0.0
33
+ version: 4.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: 2.0.0
40
+ version: 4.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: factory_bot
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -136,26 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description: Push your notifications to various services. Including Email & OneSignal
140
- (cross-platform notifications).
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/generators/notification_pusher/install_generator.rb
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
158
- metadata: {}
151
+ metadata:
152
+ github_repo: ssh://github.com/jonhue/notifications-rails
159
153
  post_install_message:
160
154
  rdoc_options: []
161
155
  require_paths:
@@ -164,15 +158,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
158
  requirements:
165
159
  - - ">="
166
160
  - !ruby/object:Gem::Version
167
- version: 2.2.2
161
+ version: '2.7'
168
162
  required_rubygems_version: !ruby/object:Gem::Requirement
169
163
  requirements:
170
164
  - - ">="
171
165
  - !ruby/object:Gem::Version
172
166
  version: '0'
173
167
  requirements: []
174
- rubygems_version: 3.0.3
168
+ rubygems_version: 3.3.7
175
169
  signing_key:
176
170
  specification_version: 4
177
- summary: Push your notifications to various services
171
+ summary: Deliver your notifications to various services
178
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
@@ -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