notification-pusher 1.2.4 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e1d6d66c37f3e0f0c2513aad94db692b1e3f7b694dc4c70bda2a78abb1529fc
4
- data.tar.gz: 6870383f90c6bdf53e2faac3566df84999de248210989806e32936578d884f4a
3
+ metadata.gz: f3842033c487c47b11953e242d24ab55acd82c280898073090a5d468a9a2118e
4
+ data.tar.gz: 779daa39294bee3fb49a7601bcba73177f6c9d6374c49b0ae8a4e1c9f72eab63
5
5
  SHA512:
6
- metadata.gz: 79092a9671e99300723f0031703c9123d3138c693d19dad6fb85370d10f0714016713bf5b0f995579ca1572e36f7a72896d761abdd599f2a1281874747973deb
7
- data.tar.gz: f5a5e2d440eba20d0a4a7e765fa1ed051750bebb6da7ee18f09276b5ed5f68257cc4a6e5a11bbb22b3754eea00e476d5fddcf3ffb9532a3e44347b4d07211851
6
+ metadata.gz: 1b875353d7805d0e4ae050f169ce5c65903e14828037c0779616722cfe7e362f68fa234f59e39c4f6490c12dc50bad058fa3815e5c78a5980240a6016ea2d874
7
+ data.tar.gz: 22641a2181d63da3a2b2747025d290b65ba74adfcef002a57102e0df9ecea320efbb9dd8fdfb769a2060a9e122f5315a0987803d889d25cee4ef589778d31ca0
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Jonas Hübotter
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Jonas Hübotter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,177 +1,84 @@
1
- # NotificationPusher
2
-
3
- [![Gem Version](https://badge.fury.io/rb/notification-pusher.svg)](https://badge.fury.io/rb/notification-pusher) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
4
-
5
- Push your notifications to various services. Including Email, ActionCable, OneSignal (cross-platform notifications).
6
-
7
- ---
8
-
9
- ## Table of Contents
10
-
11
- * [Installation](#installation)
12
- * [Usage](#usage)
13
- * [Pushers](#pushers)
14
- * [Defining a pusher](#defining-a-pusher)
15
- * [Using a pusher](#using-a-pusher)
16
- * [Writing a custom pusher](#writing-a-custom-pusher)
17
- * [To Do](#to-do)
18
- * [Contributing](#contributing)
19
- * [Contributors](#contributors)
20
- * [Semantic versioning](#semantic-versioning)
21
- * [License](#license)
22
-
23
- ---
24
-
25
- ## Installation
26
-
27
- NotificationPusher works with Rails 5 onwards. You can add it to your `Gemfile` with:
28
-
29
- ```ruby
30
- gem 'notification-pusher'
31
- ```
32
-
33
- And then execute:
34
-
35
- $ bundle
36
-
37
- Or install it yourself as:
38
-
39
- $ gem install notification-pusher
40
-
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
- Now run the generator:
48
-
49
- $ rails g notification_pusher:install
50
-
51
- To wrap things up, migrate the changes to your database:
52
-
53
- $ rails db:migrate
54
-
55
- ---
56
-
57
- ## Usage
58
-
59
- ### Pushers
60
-
61
- A pusher handles the process of sending your notifications to various services for you.
62
-
63
- #### Defining a pusher
64
-
65
- You define pushers in your `NotificationPusher` configuration (`config/initializers/notification-pusher.rb`). Using:
66
-
67
- ```ruby
68
- NotificationPusher.configure do |config|
69
- config.define_pusher name, options
70
- end
71
- ```
72
-
73
- More details about defining a specific pusher (name and available options) are available in the respective documentation of the gem.
74
-
75
- #### Using a pusher
76
-
77
- It is super simple to initialize a push:
78
-
79
- ```ruby
80
- notification = Notification.create target: User.first, object: Recipe.first
81
- notification.push name, custom_options
82
- ```
83
-
84
- Where `name` is the name of the defined pusher and `custom_options` are the options that will override the default options the pusher has been defined with.
85
-
86
- You are also able to do the exact same in just one line of code:
87
-
88
- ```ruby
89
- notification = Notification.create target: User.first, object: Recipe.first, pusher: name, pusher_options: custom_options
90
- ```
91
-
92
- **Note:** In this case, pass `custom_options` as a `Hash`.
93
-
94
- It is possible to use mutliple pushers at a time:
95
-
96
- ```ruby
97
- notification.push [name_one, name_two], name_one: custom_options, name_two: custom_options
98
- ```
99
-
100
- ### Writing a custom pusher
101
-
102
- Writing custom pushers is fairly simple. Just add a new subclass to `NotificationPusher`:
103
-
104
- ```ruby
105
- class NotificationPusher::CustomPusher
106
-
107
- def initialize notification, options = {}
108
- # ...
109
- end
110
-
111
- end
112
- ```
113
-
114
- This is how to define and use your pusher:
115
-
116
- ```ruby
117
- NotificationPusher.configure do |config|
118
- config.define_pusher :CustomPusher, option_one: 'value_one'
119
- end
120
- ```
121
-
122
- ```ruby
123
- notification = Notification.create target: User.first, object: Recipe.first
124
- notification.push :CustomPusher, option_one: 'value_two'
125
- ```
126
-
127
- For further reference take a look at the default [ActionMailer](notification-pusher-actionmailer), [ActionCable](notification-pusher-actioncable) and [OneSignal](notification-pusher-onesignal) pusher.
128
-
129
- ---
130
-
131
- ## To Do
132
-
133
- [Here](https://github.com/jonhue/notifications-rails/projects/3) is the full list of current projects.
134
-
135
- To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
136
-
137
- ---
138
-
139
- ## Contributing
140
-
141
- We hope that you will consider contributing to NotificationPusher. Please read this short overview for some information about how to get started:
142
-
143
- [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
-
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
- ### Semantic Versioning
152
-
153
- 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
+ # notifications-rails
2
+
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
+
5
+ ## Philosophy
6
+
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
+
9
+ **[notification-handler](notification-handler):** Create and modify your notifications through a simple API.
10
+
11
+ **[notification-renderer](notification-renderer):** Render your notifications in various contexts.
12
+
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).
14
+
15
+ **[notification-settings](notification-settings):** Integrates with your authentication solution to craft a personalized user notification platform.
16
+
17
+ You may just use the components you actually need, or instead use this gem to bundle everything for a complete notification solution.
18
+
19
+ ## Installation
20
+
21
+ You can add notifications-rails to your `Gemfile` with:
22
+
23
+ ```ruby
24
+ gem 'notifications-rails'
25
+ ```
26
+
27
+ And then run:
28
+
29
+ $ bundle install
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install notifications-rails
34
+
35
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
36
+
37
+ ```ruby
38
+ gem 'notifications-rails', github: 'jonhue/notifications-rails'
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ Details on usage are provided in the [documentation](#philosophy) of the specific modules.
44
+
45
+ ## Development
46
+
47
+ To start development you first have to fork this repository and locally clone your fork.
48
+
49
+ Install the projects dependencies by running:
50
+
51
+ $ bundle install
52
+
53
+ ### Testing
54
+
55
+ Tests are written with RSpec. Integration tests are located in `/spec`, unit tests can be found in `<module>/spec`.
56
+
57
+ To run all tests:
58
+
59
+ $ ./rspec
60
+
61
+ To run RuboCop:
62
+
63
+ $ bundle exec rubocop
64
+
65
+ You can find all commands run by the CI workflow in `.github/workflows/ci.yml`.
66
+
67
+ ## Contributing
68
+
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).
70
+
71
+ ## Releases
72
+
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).
74
+
75
+ notifications-rails follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our [security policy](SECURITY.md).
76
+
77
+ ### Publishing
78
+
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: 1.2.4
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: 2018-03-17 00:00:00.000000000 Z
11
+ date: 2020-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,62 +30,126 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.4
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: 1.2.4
40
+ version: 3.0.3
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: factory_bot
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
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
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: '3.7'
75
+ version: '0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: '3.7'
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: rubocop
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
- - - "~>"
101
+ - - ">="
60
102
  - !ruby/object:Gem::Version
61
- version: '0.52'
103
+ version: '0'
62
104
  type: :development
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
- - - "~>"
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
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
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
67
137
  - !ruby/object:Gem::Version
68
- version: '0.52'
69
- description: Push your notifications to various services. Including Email, ActionCable,
70
- OneSignal (cross-platform notifications).
71
- email: me@jonhue.me
138
+ version: '0'
139
+ description: Deliver your notifications to various services.
140
+ email: jonas.huebotter@gmail.com
72
141
  executables: []
73
142
  extensions: []
74
143
  extra_rdoc_files: []
75
144
  files:
76
- - CHANGELOG.md
77
145
  - LICENSE
78
146
  - README.md
79
- - lib/generators/notification_pusher/install_generator.rb
80
- - lib/generators/templates/install/initializer.rb
81
- - lib/notification-pusher.rb
82
- - lib/notification_pusher/configuration.rb
83
- - lib/notification_pusher/notification_library.rb
84
- - lib/notification_pusher/pusher.rb
147
+ - lib/notifications-rails.rb
85
148
  homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher
86
149
  licenses:
87
150
  - MIT
88
- metadata: {}
151
+ metadata:
152
+ github_repo: ssh://github.com/jonhue/notifications-rails
89
153
  post_install_message:
90
154
  rdoc_options: []
91
155
  require_paths:
@@ -94,17 +158,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
158
  requirements:
95
159
  - - ">="
96
160
  - !ruby/object:Gem::Version
97
- version: '2.3'
161
+ version: 2.2.2
98
162
  required_rubygems_version: !ruby/object:Gem::Requirement
99
163
  requirements:
100
164
  - - ">="
101
165
  - !ruby/object:Gem::Version
102
166
  version: '0'
103
167
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.7.4
168
+ rubygems_version: 3.1.4
106
169
  signing_key:
107
170
  specification_version: 4
108
- summary: Push your notifications to various services. Including Email, ActionCable,
109
- OneSignal (cross-platform notifications)
171
+ summary: Deliver your notifications to various services
110
172
  test_files: []
@@ -1,36 +0,0 @@
1
- # Changelog
2
-
3
- ### master
4
-
5
- * nothing yet
6
-
7
- ### 1.0.0 - 2017/12/28
8
-
9
- * bugfixes
10
-
11
- ### 1.0.0.beta6 - 2017/12/28
12
-
13
- * bugfixes
14
- * fix lib loading problems
15
-
16
- ### 1.0.0.beta5 - 2017/12/28
17
-
18
- * bugfixes
19
- * fix generators
20
- * fix lib loading problems
21
- * fix syntax errors
22
-
23
- ### 1.0.0.beta3 - 2017/12/25
24
-
25
- * features
26
- * add `Pusher` class and allow definition in configuration
27
-
28
- ### 1.0.0.beta2 - 2017/12/23
29
-
30
- * enhancements
31
- * add `NotificationPusher::NotificationLibrary` module to extend `NotificationHandler::Notification` model
32
- * drop Rails dependency
33
-
34
- ### 1.0.0.beta1 - 2017/12/22
35
-
36
- * initial release
@@ -1,17 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- module NotificationPusher
5
-
6
- class InstallGenerator < Rails::Generators::Base
7
-
8
- source_root File.join File.dirname(__FILE__), '../templates/install'
9
- desc 'Install NotificationPusher'
10
-
11
- def create_initializer
12
- template 'initializer.rb', 'config/initializers/notification-pusher.rb'
13
- end
14
-
15
- end
16
-
17
- end
@@ -1,7 +0,0 @@
1
- NotificationPusher.configure do |config|
2
-
3
- # A pusher handles the process of sending your notifications to various services for you.
4
- # Learn more: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher#pushers
5
- # config.define_pusher :ActionMailer, email: 'my@email.com'
6
-
7
- end
@@ -1,9 +0,0 @@
1
- module NotificationPusher
2
-
3
- require 'notification_pusher/configuration'
4
-
5
- autoload :Pusher, 'notification_pusher/pusher'
6
-
7
- autoload :NotificationLibrary, 'notification_pusher/notification_library'
8
-
9
- end
@@ -1,26 +0,0 @@
1
- module NotificationPusher
2
-
3
- class << self
4
- attr_accessor :configuration
5
- end
6
-
7
- def self.configure
8
- self.configuration ||= Configuration.new
9
- yield configuration
10
- end
11
-
12
- class Configuration
13
-
14
- attr_accessor :pushers
15
-
16
- def initialize
17
- @pushers = []
18
- end
19
-
20
- def define_pusher name, options = {}
21
- self.pushers << ::NotificationPusher::Pusher.new(name, options)
22
- end
23
-
24
- end
25
-
26
- end
@@ -1,45 +0,0 @@
1
- require 'notification-handler'
2
- require 'active_support'
3
-
4
- module NotificationPusher
5
- module NotificationLibrary
6
-
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- attr_accessor :pusher
11
- attr_accessor :pusher_options
12
-
13
- after_create_commit :initialize_pusher
14
-
15
- include NotificationPusher::NotificationLibrary::InstanceMethods
16
- end
17
-
18
- module InstanceMethods
19
-
20
- def push name, options = {}
21
- self.pusher = name
22
- self.pusher_options = options
23
- self.initialize_pusher
24
- end
25
-
26
- protected
27
-
28
- def initialize_pusher
29
- unless self.pusher.nil?
30
- if self.pusher.kind_of?(Array)
31
- self.pusher.each do |class_name|
32
- pusher = NotificationPusher::Pusher.find_by_name(class_name).first
33
- pusher.push(self, self.pusher_options[class_name.to_sym])
34
- end
35
- else
36
- pusher = NotificationPusher::Pusher.find_by_name(self.pusher).first
37
- pusher.push(self, self.pusher_options)
38
- end
39
- end
40
- end
41
-
42
- end
43
-
44
- end
45
- end
@@ -1,28 +0,0 @@
1
- module NotificationPusher
2
- class Pusher
3
-
4
- attr_accessor :name
5
- attr_accessor :options
6
- attr_accessor :instances
7
-
8
- def initialize name, options = {}
9
- @instances = []
10
- @name = name
11
- @options = options
12
- end
13
-
14
- def push notification, options = {}
15
- default_options = self.options
16
- options = options.nil? ? default_options : default_options.merge!(options)
17
- if defined?(NotificationPusher.const_get(self.name))
18
- instance = NotificationPusher.const_get(self.name).new notification, options
19
- self.instances << instance
20
- end
21
- end
22
-
23
- def self.find_by_name name
24
- NotificationPusher.configuration.pushers.select { |pusher| pusher.name == name }
25
- end
26
-
27
- end
28
- end