notification-pusher 1.0.0.beta6 → 1.0.0.beta7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9279ebe6e68eda1bbaac017e8b2ef6ecacf12fb39498d618efa1d9901129406
4
- data.tar.gz: 2f0699404108acf6c9697cae22f13d665a2640f5f7c79668b8fb39760db6cb00
3
+ metadata.gz: b23540414b0c20125716ee66cd6d940f2eed78f8751911ec94c09959ff67b0f2
4
+ data.tar.gz: 117a4c33a58ab637464d1706155f67131ac5b611d54bcffe87706e8c533d2ca3
5
5
  SHA512:
6
- metadata.gz: 555cc8686080758e1dc13f6a2102e5e10235de24b25fc8b2c455a9f4c085e4a754a7c01d5729391c346344808835332f82626874f5ab5eb5822b539bc40c2f94
7
- data.tar.gz: dff48181613cdf05f32131750740c45576477102ecf0e5b325015e27ca3b989be61885d0ca2db64cee929c298c776fadde5d468b2d5b30396ed5f850a3c13587
6
+ metadata.gz: c03fd0209cc73ae4e32df40095eaaac29a6f10d14db3e7e0f8ceaf14497a60a9ca83ba0f4fb1500d78811bce9dcfb74f34ea474dc97dd82a28a53da92977dc75
7
+ data.tar.gz: 4175563440b2ce9a910236a1b01c5bd2a097ae554676dac1a96c5bdee1afc0a11a0a2decf05f1dff7761ae57600613082ff5ce2710a543874376a971fa23f27c
data/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ ### master
4
+
5
+ * nothing yet
6
+
7
+ ### 1.0.0.beta6 - 2017-12-28
8
+
9
+ * bugfixes
10
+ * fix lib loading problems
11
+
12
+ ### 1.0.0.beta5 - 2017-12-28
13
+
14
+ * bugfixes
15
+ * fix generators
16
+ * fix lib loading problems
17
+ * fix syntax errors
18
+
19
+ ### 1.0.0.beta4 - 2017-12-27
20
+
21
+ * no changes
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
data/README.md CHANGED
@@ -1,17 +1,19 @@
1
- # NotificationsRails
1
+ # NotificationPusher
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/notifications-rails.svg)](https://badge.fury.io/rb/notifications-rails) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
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
4
 
5
- The most powerful notification solution for Rails. NotificationsRails simplifies the handling, rendering, user-integration and cross-platform pushing of notifications through its simple API.
6
-
7
- It integrates with the [Native](https://github.com/NativeGap/native-rails) gem to allow you to create a cross platform Rails app.
5
+ Push your notifications to various services. Including Email, ActionCable, OneSignal (cross-platform notifications).
8
6
 
9
7
  ---
10
8
 
11
9
  ## Table of Contents
12
10
 
13
- * [Philosophy](#philosophy)
14
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)
15
17
  * [To Do](#to-do)
16
18
  * [Contributing](#contributing)
17
19
  * [Contributors](#contributors)
@@ -20,49 +22,117 @@ It integrates with the [Native](https://github.com/NativeGap/native-rails) gem t
20
22
 
21
23
  ---
22
24
 
23
- ## Philosophy
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
24
40
 
25
- NotificationsRails has been built with modularity in mind. It currently consists of four components each of which bringing one essential functionality to the notification-integration in your Rails app.
41
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
26
42
 
27
- **[NotificationHandler](notification-handler):** Create and modify your notifications through a simple API.
43
+ ```ruby
44
+ gem 'notification-pusher', github: 'jonhue/notifications-rails'
45
+ ```
28
46
 
29
- **[NotificationRenderer](notification-renderer):** Render your notifications on multiple platforms by specifying notification types.
47
+ Now run the generator:
30
48
 
31
- **[NotificationPusher](notification-pusher):** Push your notifications to various services. Including [Email](notification-pusher-actionmailer), [ActionCable](notification-pusher-actioncable), [OneSignal](notification-pusher-onesignal).
49
+ $ rails g notification_pusher:install
32
50
 
33
- **[NotificationSettings](notification-settings):** Integrates with your authentication solution to craft a personalized user notification platform.
51
+ To wrap things up, migrate the changes to your database:
34
52
 
35
- You may just add the components you actually need, or instead use this gem to bundle everything for a complete notification solution.
53
+ $ rails db:migrate
36
54
 
37
55
  ---
38
56
 
39
- ## Installation
57
+ ## Usage
58
+
59
+ ### Pushers
40
60
 
41
- NotificationsRails works with Rails 5 onwards. You can add it to your `Gemfile` with:
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:
42
66
 
43
67
  ```ruby
44
- gem 'notifications-rails'
68
+ NotificationPusher.configure do |config|
69
+ config.define_pusher name, options
70
+ end
45
71
  ```
46
72
 
47
- And then execute:
73
+ More details about defining a specific pusher (name and available options) are available in the respective documentation of the gem.
48
74
 
49
- $ bundle
75
+ #### Using a pusher
50
76
 
51
- Or install it yourself as:
77
+ It is super simple to initialize a push:
52
78
 
53
- $ gem install notifications-rails
79
+ ```ruby
80
+ notification = Notification.create target: User.first, object: Recipe.first
81
+ notification.push name, custom_options
82
+ ```
54
83
 
55
- If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
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, push: name, push_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:
56
95
 
57
96
  ```ruby
58
- gem 'notifications-rails', github: 'jonhue/notifications-rails'
97
+ notification.push [name_one, name_two], name_one: custom_options, name_two: custom_options
59
98
  ```
60
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
+ module NotificationPusher
106
+ class CustomPusher
107
+
108
+ def initialize notification, options = {}
109
+ # ...
110
+ end
111
+
112
+ end
113
+ end
114
+ ```
115
+
116
+ This is how to define and use your pusher:
117
+
118
+ ```ruby
119
+ NotificationPusher.configure do |config|
120
+ config.define_pusher :CustomPusher, option_one: 'value_one'
121
+ end
122
+ ```
123
+
124
+ ```ruby
125
+ notification = Notification.create target: User.first, object: Recipe.first
126
+ notification.push :CustomPusher, option_one: 'value_two'
127
+ ```
128
+
129
+ For further reference take a look at the default [ActionMailer](notification-pusher-actionmailer), [ActionCable](notification-pusher-actioncable) and [OneSignal](notification-pusher-onesignal) pusher.
130
+
61
131
  ---
62
132
 
63
133
  ## To Do
64
134
 
65
- [Here](https://github.com/jonhue/notifications-rails/projects) is the full list of current projects.
135
+ [Here](https://github.com/jonhue/notifications-rails/projects/3) is the full list of current projects.
66
136
 
67
137
  To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
68
138
 
@@ -70,9 +140,9 @@ To propose your ideas, initiate the discussion by adding a [new issue](https://g
70
140
 
71
141
  ## Contributing
72
142
 
73
- We hope that you will consider contributing to NotificationsRails. Please read this short overview for some information about how to get started:
143
+ We hope that you will consider contributing to NotificationPusher. Please read this short overview for some information about how to get started:
74
144
 
75
- [Learn more about contributing to this repository](CONTRIBUTING.md), [Code of Conduct](CODE_OF_CONDUCT.md)
145
+ [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)
76
146
 
77
147
  ### Contributors
78
148
 
@@ -82,7 +152,7 @@ https://github.com/jonhue/notifications-rails/graphs/contributors
82
152
 
83
153
  ### Semantic Versioning
84
154
 
85
- NotificationsRails follows Semantic Versioning 2.0 as defined at http://semver.org.
155
+ NotificationPusher follows Semantic Versioning 2.0 as defined at http://semver.org.
86
156
 
87
157
  ## License
88
158
 
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,21 @@
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
+ def define_pusher name, options = {}
15
+ options[:name] = name
16
+ ::NotificationPusher::Pusher.new options
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,38 @@
1
+ module NotificationPusher
2
+ module NotificationLibrary
3
+
4
+ attr_accessor :push
5
+ attr_accessor :push_options
6
+
7
+ after_create_commit :initialize_pusher
8
+
9
+ def push name, options = {}
10
+ self.push = class_name
11
+ self.push_options = options
12
+ self.initialize_pusher
13
+ end
14
+
15
+ private
16
+
17
+ def initialize_pusher
18
+ unless self.push.nil?
19
+ if self.push.kind_of(Array)
20
+ self.push.each do |class_name|
21
+ pusher = NotificationPusher::Pusher.find_by_name(class_name).last
22
+ if defined?(NotificationPusher.const_get(pusher.name))
23
+ options = pusher.options.merge! self.push_options[class_name.to_sym]
24
+ pusher.instances << NotificationPusher.const_get(pusher.name).new options
25
+ end
26
+ end
27
+ else
28
+ pusher = NotificationPusher::Pusher.find_by_name(self.push).last
29
+ if defined?(NotificationPusher.const_get(pusher.name))
30
+ options = pusher.options.merge! self.push_options
31
+ pusher.instances << NotificationPusher.const_get(pusher.name).new self, options
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,19 @@
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 find_by_name name
15
+ ObjectSpace.each_object(NotificationPusher::Pusher).select { |pusher| pusher.name == name }
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,9 @@
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notification-pusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta6
4
+ version: 1.0.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0.beta6
19
+ version: 1.0.0.beta7
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: 1.0.0.beta6
26
+ version: 1.0.0.beta7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,8 +59,15 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - CHANGELOG.md
62
63
  - LICENSE
63
64
  - README.md
65
+ - lib/generators/notification_pusher/install_generator.rb
66
+ - lib/generators/templates/install/initializer.rb
67
+ - lib/notification_pusher.rb
68
+ - lib/notification_pusher/configuration.rb
69
+ - lib/notification_pusher/notification_library.rb
70
+ - lib/notification_pusher/pusher.rb
64
71
  homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher
65
72
  licenses:
66
73
  - MIT
@@ -68,7 +75,7 @@ metadata: {}
68
75
  post_install_message:
69
76
  rdoc_options: []
70
77
  require_paths:
71
- - lib/notification_pusher.rb
78
+ - lib
72
79
  required_ruby_version: !ruby/object:Gem::Requirement
73
80
  requirements:
74
81
  - - ">="