notification-pusher-actionmailer 1.2.6 → 2.0.0

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: 8712a4c61c9fbc50771a3a8b4b8df266df08a9bc157b8ff8f4417e679a925504
4
- data.tar.gz: eb81367f4f3f529ef51dc90db4037bd83f57b395c0192281ad788923a41e6e29
3
+ metadata.gz: 1ace410bc0d4d02cffc46b368f7ac26ea7c05f23993e0db166cba968825c3788
4
+ data.tar.gz: b9ab6323df47db214da68071743b788c092614c053daefa8093995e46b96a0ed
5
5
  SHA512:
6
- metadata.gz: 9e7fab7423b084d66edb15968f662ba7bfce4f278632a5a9cbdc2a7f492a7114c39cff9a78e655a4d21b8f170c6d5a0ab3337aed8f02a420104b6610060bc130
7
- data.tar.gz: cd01d224c4813cb8732ab18648d9960232b19a378ddd1c6d2dc8f6d9f60c40ec8a86c378e960bffa962901590cc582b43db309a4c952384c4b02f0ef925c737a
6
+ metadata.gz: '068fc97838b7ef080a2aab91cdaa369639ebb135c4963e66c6e49bd28f19b69cab489147b05c24f70d4c581dd100f254a4fe0dfb8eb6a8297b2fa01492bc9d09'
7
+ data.tar.gz: d0b3ed2a689975105498d757834b594d8bc32228ec451fcc53c4a45732e830c47edb4b327d6dadad4fa2eb8fed063eba0495f5d7662013a83cde5f5d1d414b79
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NotificationPusher for ActionMailer
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/notification-pusher-actionmailer.svg)](https://badge.fury.io/rb/notification-pusher-actionmailer) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
3
+ [![Gem Version](https://badge.fury.io/rb/notification-pusher-actionmailer.svg)](https://badge.fury.io/rb/notification-pusher-actionmailer) ![Travis](https://travis-ci.com/jonhue/notifications-rails.svg?branch=master)
4
4
 
5
5
  A pusher to send your notifications via email utilizing ActionMailer.
6
6
 
@@ -10,12 +10,10 @@ A pusher to send your notifications via email utilizing ActionMailer.
10
10
 
11
11
  * [Installation](#installation)
12
12
  * [Usage](#usage)
13
- * [Options](#options)
13
+ * [Options](#options)
14
14
  * [To Do](#to-do)
15
15
  * [Contributing](#contributing)
16
- * [Contributors](#contributors)
17
- * [Semantic versioning](#semantic-versioning)
18
- * [License](#license)
16
+ * [Semantic versioning](#semantic-versioning)
19
17
 
20
18
  ---
21
19
 
@@ -35,60 +33,73 @@ Or install it yourself as:
35
33
 
36
34
  $ gem install notification-pusher-actionmailer
37
35
 
38
- If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
39
-
40
- ```ruby
41
- gem 'notification-pusher-actionmailer', github: 'jonhue/notifications-rails'
42
- ```
43
-
44
36
  ---
45
37
 
46
38
  ## Usage
47
39
 
48
- Define this pusher in your `NotificationPusher` configuration:
40
+ Register this pusher in your `NotificationPusher` configuration:
49
41
 
50
42
  ```ruby
51
43
  NotificationPusher.configure do |config|
52
- config.define_pusher :ActionMailer
44
+ config.register_delivery_method :email, :ActionMailer
53
45
  end
54
46
  ```
55
47
 
56
- You can pass a `from` parameter, which will override the default email address specified in `ApplicationMailer`:
48
+ You can pass a `from` parameter, which will be used if you don't provide a `from` address when delivering:
57
49
 
58
50
  ```ruby
59
51
  NotificationPusher.configure do |config|
60
- config.define_pusher :ActionMailer, from: 'my@email.com'
52
+ config.register_delivery_method :email, :ActionMailer, from: 'my@email.com'
61
53
  end
62
54
  ```
63
55
 
64
56
  Then add a renderer called `_actionmailer.html.erb` to every notification type you aim to support. Learn more [here](https://github.com/jonhue/notifications-rails/tree/master/notification-renderer).
65
57
 
66
- Now you can push your notifications:
58
+ Now you can deliver your notifications:
67
59
 
68
60
  ```ruby
69
- notification = Notification.create target: User.first, object: Recipe.first
70
- notification.push :ActionMailer, to: 'another@email.com'
61
+ require 'notification-renderer'
62
+
63
+ notification = Notification.create(target: User.first, object: Recipe.first)
64
+ notification.deliver(:email, to: 'another@email.com')
71
65
  ```
72
66
 
73
- **Note:** If the email address, you want to push to, is the same as `notification.target.email` you can omit the `to` parameter.
67
+ **Note:** If the email address, you want to deliver to, is the same as `notification.target.email` you can omit the `to` parameter.
74
68
 
75
69
  It is also possible to override the email address sending this notification, by passing a `from` parameter.
76
70
 
71
+ If you don't want to use [NotificationRenderer](https://github.com/jonhue/notifications-rails/tree/master/notification-renderer):
72
+
73
+ ```ruby
74
+ notification = Notification.create(target: User.first, object: Recipe.first)
75
+ notification.deliver(:email, to: 'another@email.com', mailer: MyCustomMailer, action: :deliver_notification)
76
+ ```
77
+
78
+ `MyCustomMailer.deliver_notification` is then called with a `notification` as first argument and an options hash as second argument.
79
+
77
80
  ### Options
78
81
 
79
82
  **`to`** Receiver email address. Takes a string.
80
83
 
81
- **`from`** Sender email address. Takes a string. Defaults to email specified in `ApplicationMailer`.
84
+ **`from`** Sender email address. Takes a string.
82
85
 
83
86
  **`renderer`** Specify a renderer. Takes a string. Defaults to `'actionmailer'`.
84
87
 
85
88
  **`layout`** Layout used for template rendering. Takes a string. Defaults to layout specified in `ApplicationMailer`.
86
89
 
90
+ **`mail_options`** A hash that is passed to `mail` (e.g. including `:subject`). Takes a hash. Defaults to `{}`.
91
+
92
+ **`mailer`** ActionMailer class. Takes a constant. Defaults to `NotificationPusher::ActionMailer::NotificationMailer`.
93
+
94
+ **`action`** ActionMailer action. Takes a symbol. Defaults to `:push`.
95
+
96
+ **`deliver_method`** ActionMailer deliver_method (e.g. `:deliver_later`). Takes a symbol. Defaults to `:deliver`.
97
+
87
98
  ---
88
99
 
89
100
  ## To Do
90
101
 
91
- [Here](https://github.com/jonhue/notifications-rails/projects/6) is the full list of current projects.
102
+ We use [GitHub projects](https://github.com/jonhue/notifications-rails/projects/6) to coordinate the work on this project.
92
103
 
93
104
  To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
94
105
 
@@ -100,36 +111,6 @@ We hope that you will consider contributing to NotificationPusher for ActionMail
100
111
 
101
112
  [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)
102
113
 
103
- ### Contributors
104
-
105
- Give the people some :heart: who are working on this project. See them all at:
106
-
107
- https://github.com/jonhue/notifications-rails/graphs/contributors
108
-
109
114
  ### Semantic Versioning
110
115
 
111
116
  NotificationPusher for ActionMailer follows Semantic Versioning 2.0 as defined at http://semver.org.
112
-
113
- ## License
114
-
115
- MIT License
116
-
117
- Copyright (c) 2017 Jonas Hübotter
118
-
119
- Permission is hereby granted, free of charge, to any person obtaining a copy
120
- of this software and associated documentation files (the "Software"), to deal
121
- in the Software without restriction, including without limitation the rights
122
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
123
- copies of the Software, and to permit persons to whom the Software is
124
- furnished to do so, subject to the following conditions:
125
-
126
- The above copyright notice and this permission notice shall be included in all
127
- copies or substantial portions of the Software.
128
-
129
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
130
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
131
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
132
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
133
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
134
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
135
- SOFTWARE.
@@ -3,13 +3,21 @@
3
3
  module NotificationPusher
4
4
  class ActionMailer
5
5
  class NotificationMailer < ApplicationMailer
6
+ # rubocop:disable Metrics/ParameterLists
6
7
  def push(notification,
7
- from:, to: nil, renderer: 'actionmailer', layout: nil)
8
+ from:, to: nil, renderer: 'actionmailer', layout: nil,
9
+ mail_options: {})
8
10
  render(layout: layout) unless layout.nil?
11
+
9
12
  @notification = notification
10
13
  @renderer = renderer
11
- mail(to: to || notification.target.email, from: from)
14
+
15
+ mail({
16
+ to: to || notification.target.email,
17
+ from: from
18
+ }.merge(mail_options))
12
19
  end
20
+ # rubocop:enable Metrics/ParameterLists
13
21
  end
14
22
  end
15
23
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'notification-pusher'
4
- require 'notification_pusher/action_mailer'
4
+ require_relative 'notification_pusher/delivery_method/action_mailer'
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NotificationPusher
4
+ module DeliveryMethod
5
+ class ActionMailer < NotificationPusher::DeliveryMethod::Base
6
+ require_relative 'action_mailer/engine'
7
+
8
+ DEFAULT_MAILER_ACTION = :push
9
+ DEFAULT_DELIVER_METHOD = :deliver
10
+
11
+ def call
12
+ mailer_class.send(mailer_action, notification, options)
13
+ .send(deliver_method)
14
+ end
15
+
16
+ private
17
+
18
+ def mailer_class
19
+ return options[:mailer] if options.key?(:mailer)
20
+ if defined?(NotificationRenderer)
21
+ return ::NotificationPusher::ActionMailer::NotificationMailer
22
+ end
23
+
24
+ raise(ArgumentError,
25
+ 'You have to pass the :mailer option explicitly or require ' \
26
+ "'notification-renderer'")
27
+ end
28
+
29
+ def mailer_action
30
+ options[:action] || DEFAULT_MAILER_ACTION
31
+ end
32
+
33
+ def deliver_method
34
+ options[:deliver_method] || DEFAULT_DELIVER_METHOD
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/railtie'
3
+ require 'rails/engine'
4
4
  require 'action_mailer'
5
5
 
6
6
  module NotificationPusher
metadata CHANGED
@@ -1,73 +1,101 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notification-pusher-actionmailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
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: 2018-12-22 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
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.2'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: notification-pusher
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.6
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: 1.2.6
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: notification-renderer
42
+ name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.6
47
+ version: '5.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.6
54
+ version: '5.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: railties
56
+ name: factory_bot
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '5.2'
62
- type: :runtime
61
+ version: '0'
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '5.2'
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
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'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: 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'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -108,6 +136,20 @@ dependencies:
108
136
  - - ">="
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sqlite3
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
111
153
  description: A pusher to send your notifications via email utilizing ActionMailer.
112
154
  email: me@jonhue.me
113
155
  executables: []
@@ -119,8 +161,8 @@ files:
119
161
  - app/mailers/notification_pusher/action_mailer/notification_mailer.rb
120
162
  - app/views/notification_pusher/action_mailer/notification_mailer/push.html.erb
121
163
  - lib/notification-pusher-actionmailer.rb
122
- - lib/notification_pusher/action_mailer.rb
123
- - lib/notification_pusher/action_mailer/engine.rb
164
+ - lib/notification_pusher/delivery_method/action_mailer.rb
165
+ - lib/notification_pusher/delivery_method/action_mailer/engine.rb
124
166
  homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher/notification-pusher-actionmailer
125
167
  licenses:
126
168
  - MIT
@@ -140,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
182
  - !ruby/object:Gem::Version
141
183
  version: '0'
142
184
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.7.6
185
+ rubygems_version: 3.0.3
145
186
  signing_key:
146
187
  specification_version: 4
147
188
  summary: A pusher to send your notifications via email utilizing ActionMailer
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'notification-renderer'
4
-
5
- module NotificationPusher
6
- class ActionMailer
7
- require 'notification_pusher/action_mailer/engine'
8
-
9
- def initialize(notification, options = {})
10
- ::NotificationPusher::ActionMailer::NotificationMailer.push(
11
- notification, options
12
- )
13
- end
14
- end
15
- end