mail-notify 0.2.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +8 -1
- data/.gitignore +1 -0
- data/CHANGELOG.md +21 -3
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +1 -1
- data/README.md +11 -1
- data/Rakefile +5 -6
- data/lib/mail/notify.rb +8 -8
- data/lib/mail/notify/delivery_method.rb +2 -2
- data/lib/mail/notify/mailer.rb +3 -3
- data/lib/mail/notify/mailers_controller.rb +3 -3
- data/lib/mail/notify/railtie.rb +2 -2
- data/lib/mail/notify/version.rb +1 -1
- data/mail-notify.gemspec +28 -23
- metadata +86 -16
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c7e4e16f5be488db0fadd5e7bda04b7225eed92367f509ddf34a8c5bcc34ece
|
4
|
+
data.tar.gz: 804d693e50559e07ae4c9dd15ba60fe5219dffb7f323f35d5021726152752021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '019defa225ca4c55a8ab208708e4635ef55777f4e8a5d0a7ce1650d2b56271df1dd1595083bb8a1c245ec1578a4fc835c39de3139ad54b249cd183a8ffd55998'
|
7
|
+
data.tar.gz: ff993d41bcc0b050f3a0874e7d391023dcbfb0abfee33c112334e3d8906909c466300b5f5d12fe490c7ee5d1ee70ca808de744ce46a5fc52618b337d3ad91ec8
|
data/.github/workflows/build.yml
CHANGED
@@ -13,10 +13,17 @@ jobs:
|
|
13
13
|
uses: actions/setup-ruby@v1
|
14
14
|
with:
|
15
15
|
ruby-version: 2.6.x
|
16
|
+
- name: Set up cache
|
17
|
+
uses: actions/cache@preview
|
18
|
+
with:
|
19
|
+
path: vendor/bundle
|
20
|
+
key: ${{ runner.os }}-gem-${{ hashFiles('**/mail-notify.gemspec') }}
|
21
|
+
restore-keys: |
|
22
|
+
${{ runner.os }}-gem-
|
16
23
|
- name: Build and test with Rake
|
17
24
|
run: |
|
18
25
|
sudo apt-get update
|
19
26
|
sudo apt-get install sqlite3 libsqlite3-dev
|
20
27
|
gem install bundler
|
21
|
-
bundle install --jobs 4 --retry 3
|
28
|
+
bundle install --jobs 4 --retry 3 --path ./vendor/bundle
|
22
29
|
bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog]
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.3] - 2020-12-14
|
10
|
+
|
11
|
+
- Add support for ActionMailer 6.1
|
12
|
+
|
13
|
+
## [1.0.2] - 2020-03-24
|
14
|
+
|
15
|
+
- Add support for ActionMailer 6.0
|
16
|
+
|
17
|
+
## [1.0.1] - 2020-03-06
|
18
|
+
|
19
|
+
- Support additional Notify services
|
20
|
+
|
21
|
+
## [1.0] - 2019-10-22
|
22
|
+
|
23
|
+
- Bump Notify gem to 5.1
|
9
24
|
- Add error handling for blank variables
|
10
25
|
|
11
26
|
## [0.2.1] - 2019-10-22
|
@@ -33,10 +48,13 @@ The format is based on [Keep a Changelog]
|
|
33
48
|
|
34
49
|
## [0.0.1] - 2019-02-01
|
35
50
|
|
36
|
-
-
|
51
|
+
- Initial release
|
37
52
|
|
38
|
-
[unreleased]:
|
39
|
-
|
53
|
+
[unreleased]: https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/1.0.3...HEAD
|
54
|
+
[1.0.3]: https://github.com/dxw/mail-notify/compare/1.0.2...1.0.3
|
55
|
+
[1.0.2]: https://github.com/dxw/mail-notify/compare/1.0.1...1.0.2
|
56
|
+
[1.0.1]: https://github.com/dxw/mail-notify/compare/1.0...1.0.1
|
57
|
+
[1.0]: https://github.com/dxw/mail-notify/compare/0.2.1...1.0
|
40
58
|
[0.2.1]: https://github.com/dxw/mail-notify/compare/0.2.0...0.2.1
|
41
59
|
[0.2.0]: https://github.com/dxw/mail-notify/compare/0.1.0...0.2.0
|
42
60
|
[0.1.0]: https://github.com/dxw/mail-notify/compare/0.0.3...0.1.0
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
The [dxw standard contributing guide](https://github.com/dxw/.github/blob/main/CONTRIBUTING.md) applies for this repository.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -32,6 +32,16 @@ config.action_mailer.notify_settings = {
|
|
32
32
|
}
|
33
33
|
```
|
34
34
|
|
35
|
+
If you're using a different Notify service to GOV.UK Notify (for example [GOV.CA Notify](https://notification.alpha.canada.ca/)), you can also specify the Base URL in your setup:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
config.action_mailer.delivery_method = :notify
|
39
|
+
config.action_mailer.notify_settings = {
|
40
|
+
api_key: YOUR_NOTIFY_API_KEY,
|
41
|
+
base_url: 'https://api.notification.alpha.canada.ca'
|
42
|
+
}
|
43
|
+
```
|
44
|
+
|
35
45
|
### Mailers
|
36
46
|
|
37
47
|
There are two options for using `Mail::Notify`, either templating in Rails with a view, or templating in Notify. Whichever way you choose, you'll need your mailers to inherit from `Mail::Notify::Mailer` like so:
|
@@ -73,7 +83,7 @@ class MyMailer < Mail::Notify::Mailer
|
|
73
83
|
def send_email
|
74
84
|
template_mail('YOUR_TEMPLATE_ID_GOES_HERE',
|
75
85
|
to: 'mail@somewhere.com',
|
76
|
-
|
86
|
+
personalisation: {
|
77
87
|
foo: 'bar'
|
78
88
|
}
|
79
89
|
)
|
data/Rakefile
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "standard/rake"
|
6
|
+
require "coveralls/rake/task"
|
7
7
|
|
8
8
|
Coveralls::RakeTask.new
|
9
|
-
RuboCop::RakeTask.new
|
10
9
|
|
11
10
|
RSpec::Core::RakeTask.new(:spec)
|
12
11
|
|
13
|
-
task default: %i[
|
12
|
+
task default: %i[standard spec coveralls:push]
|
data/lib/mail/notify.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "notifications/client"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
5
|
+
require "mail/notify/version"
|
6
|
+
require "mail/notify/railtie" if defined? Rails
|
7
|
+
require "mail/notify/delivery_method"
|
8
|
+
require "mail/notify/personalisation"
|
9
|
+
require "mail/notify/mailer"
|
10
|
+
require "mail/notify/message"
|
11
|
+
require "mail/notify/mailers_controller"
|
12
12
|
|
13
13
|
Mail::Message.include Mail::Notify::Message
|
14
14
|
|
@@ -6,7 +6,7 @@ module Mail
|
|
6
6
|
attr_accessor :settings, :response
|
7
7
|
|
8
8
|
def initialize(settings)
|
9
|
-
raise ArgumentError,
|
9
|
+
raise ArgumentError, "You must specify an API key" if settings[:api_key].blank?
|
10
10
|
|
11
11
|
@settings = settings
|
12
12
|
end
|
@@ -26,7 +26,7 @@ module Mail
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def client
|
29
|
-
@client ||= Notifications::Client.new(@settings[:api_key])
|
29
|
+
@client ||= Notifications::Client.new(@settings[:api_key], @settings[:base_url])
|
30
30
|
end
|
31
31
|
|
32
32
|
def email_params
|
data/lib/mail/notify/mailer.rb
CHANGED
@@ -4,15 +4,15 @@ module Mail
|
|
4
4
|
module Notify
|
5
5
|
class Mailer < ActionMailer::Base
|
6
6
|
def view_mail(template_id, headers)
|
7
|
-
raise ArgumentError,
|
7
|
+
raise ArgumentError, "You must specify a template ID" if template_id.blank?
|
8
8
|
|
9
9
|
mail(headers.merge(template_id: template_id))
|
10
10
|
end
|
11
11
|
|
12
12
|
def template_mail(template_id, headers)
|
13
|
-
raise ArgumentError,
|
13
|
+
raise ArgumentError, "You must specify a template ID" if template_id.blank?
|
14
14
|
|
15
|
-
mail(headers.merge(body:
|
15
|
+
mail(headers.merge(body: "", subject: "", template_id: template_id))
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -23,13 +23,13 @@ module Mail
|
|
23
23
|
# the `govuk_notify_layout` layout
|
24
24
|
append_view_path(__dir__)
|
25
25
|
|
26
|
-
response.content_type =
|
27
|
-
render html: @email.preview.html.html_safe, layout:
|
26
|
+
response.content_type = "text/html"
|
27
|
+
render html: @email.preview.html.html_safe, layout: "govuk_notify_layout"
|
28
28
|
end
|
29
29
|
|
30
30
|
def render_preview_wrapper
|
31
31
|
@part = @email
|
32
|
-
render action:
|
32
|
+
render action: "email", layout: false, formats: %i[html]
|
33
33
|
end
|
34
34
|
|
35
35
|
def notify?
|
data/lib/mail/notify/railtie.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
module Mail
|
4
4
|
module Notify
|
5
5
|
class Railtie < Rails::Railtie
|
6
|
-
initializer
|
6
|
+
initializer "mail-notify.add_delivery_method", before: "action_mailer.set_configs" do
|
7
7
|
ActionMailer::Base.add_delivery_method(:notify, Mail::Notify::DeliveryMethod)
|
8
8
|
end
|
9
9
|
|
10
|
-
initializer
|
10
|
+
initializer "mail-notify.action_controller" do
|
11
11
|
ActiveSupport.on_load(:action_controller, run_once: true) do
|
12
12
|
Rails::MailersController.prepend(Mail::Notify::MailersController)
|
13
13
|
end
|
data/lib/mail/notify/version.rb
CHANGED
data/mail-notify.gemspec
CHANGED
@@ -1,37 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "mail/notify/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
8
|
+
spec.name = "mail-notify"
|
9
|
+
spec.version = Mail::Notify::VERSION
|
10
|
+
spec.authors = ["Stuart Harrison"]
|
11
|
+
spec.email = ["pezholio@gmail.com"]
|
12
12
|
|
13
|
-
spec.summary
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
13
|
+
spec.summary = "ActionMailer support for the GOV.UK Notify API"
|
14
|
+
spec.homepage = "https://github.com/dxw/mail-notify"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
21
|
end
|
22
|
-
spec.bindir
|
23
|
-
spec.executables
|
24
|
-
spec.require_paths = [
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
+
spec.add_development_dependency "coveralls", "~> 0.8.22"
|
28
|
+
spec.add_development_dependency "pry", "~> 0.12.0"
|
29
|
+
spec.add_development_dependency "rails", "~> 6.0"
|
30
|
+
spec.add_development_dependency "rake", "~> 12.3.3"
|
31
|
+
spec.add_development_dependency "rspec-rails", "~> 3.8"
|
32
|
+
spec.add_development_dependency "standard", "0.4.7"
|
33
|
+
spec.add_development_dependency "sqlite3", "~> 1.4.1"
|
34
|
+
spec.add_development_dependency "webmock", "~> 3.7.6"
|
34
35
|
|
35
|
-
spec.add_dependency
|
36
|
-
spec.add_dependency
|
36
|
+
spec.add_dependency "actionmailer", ">= 5.2.4.2", "< 6.2"
|
37
|
+
spec.add_dependency "activesupport", ">= 5.2.4.3"
|
38
|
+
spec.add_dependency "actionpack", ">= 5.2.4.3"
|
39
|
+
spec.add_dependency "actionview", ">= 5.2.4.3"
|
40
|
+
spec.add_dependency "notifications-ruby-client", "~> 5.1"
|
41
|
+
spec.add_dependency "rack", ">= 2.1.4"
|
37
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Harrison
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 12.3.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 12.3.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,19 +95,19 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.8'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: standard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.4.7
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.4.7
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: sqlite3
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,40 +122,110 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.4.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.7.6
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.7.6
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: actionmailer
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: 5.2.4.2
|
132
146
|
- - "<"
|
133
147
|
- !ruby/object:Gem::Version
|
134
|
-
version: '6.
|
148
|
+
version: '6.2'
|
135
149
|
type: :runtime
|
136
150
|
prerelease: false
|
137
151
|
version_requirements: !ruby/object:Gem::Requirement
|
138
152
|
requirements:
|
139
153
|
- - ">="
|
140
154
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
155
|
+
version: 5.2.4.2
|
142
156
|
- - "<"
|
143
157
|
- !ruby/object:Gem::Version
|
144
|
-
version: '6.
|
158
|
+
version: '6.2'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: activesupport
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 5.2.4.3
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 5.2.4.3
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: actionpack
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 5.2.4.3
|
180
|
+
type: :runtime
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 5.2.4.3
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: actionview
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 5.2.4.3
|
194
|
+
type: :runtime
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: 5.2.4.3
|
145
201
|
- !ruby/object:Gem::Dependency
|
146
202
|
name: notifications-ruby-client
|
147
203
|
requirement: !ruby/object:Gem::Requirement
|
148
204
|
requirements:
|
149
205
|
- - "~>"
|
150
206
|
- !ruby/object:Gem::Version
|
151
|
-
version: '
|
207
|
+
version: '5.1'
|
152
208
|
type: :runtime
|
153
209
|
prerelease: false
|
154
210
|
version_requirements: !ruby/object:Gem::Requirement
|
155
211
|
requirements:
|
156
212
|
- - "~>"
|
157
213
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
214
|
+
version: '5.1'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: rack
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: 2.1.4
|
222
|
+
type: :runtime
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: 2.1.4
|
159
229
|
description:
|
160
230
|
email:
|
161
231
|
- pezholio@gmail.com
|
@@ -171,9 +241,9 @@ files:
|
|
171
241
|
- ".rspec"
|
172
242
|
- ".rubocop.yml"
|
173
243
|
- ".ruby-version"
|
174
|
-
- ".travis.yml"
|
175
244
|
- CHANGELOG.md
|
176
245
|
- CODE_OF_CONDUCT.md
|
246
|
+
- CONTRIBUTING.md
|
177
247
|
- Gemfile
|
178
248
|
- LICENSE.txt
|
179
249
|
- README.md
|