mail-notify 1.0.2 → 1.0.5

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: 5e655bdd3f3a316396b7df35d23a86f0f4a860aa5fc25612d52b1f765cb762f9
4
- data.tar.gz: 29521a3f973c0f7dff6ffa51024653b0896e9bdb672693cde040e57cbe95cf64
3
+ metadata.gz: 51dc46116d659f7d269b55bed4d05a6389cffb71c0da50e87610e7c491a35927
4
+ data.tar.gz: 853e9293faa4f7e9a913ad53922db154260b616a5fe1485c9e5ee0f65ca8f9f3
5
5
  SHA512:
6
- metadata.gz: 640be6724ce67e82499573090eff2d66121d4a8f4814a160d4ce8bd62d0a9390595f02b10b7cdecfb10cc7d47e4f62a5f1c8d3ebbfb9be3b951026a20bff3d72
7
- data.tar.gz: 95aee1774859003130cf27841d6bf3d31ed883e56864378ee4f6fe5a6a52adf19d347375c58b5ba8c0f2c646a3e57c8486eb52e7774e287666fb0f36d4b0c58d
6
+ metadata.gz: ddd4d70cd5779b20791014b66987179081070a5b8e5d709da816f4d883e111cf45f5da0235eab06a1ebdd5e8f5092c3269d64fee720e9847d675d49def12dbfa
7
+ data.tar.gz: 851594ef11849f363c241106508f1cb939911ac9cc8fd57fcd88588f0ca72ace91c859fa02b6ddb5297143002956880070164226b305325b1710281ab9561b47
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
  set -e
3
3
 
4
- mkdir ~/.gem
4
+ mkdir -p ~/.gem
5
5
  echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
6
6
  chmod 0600 ~/.gem/credentials
@@ -8,11 +8,9 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v1
12
- - name: Set up Ruby 2.6
13
- uses: actions/setup-ruby@v1
14
- with:
15
- ruby-version: 2.6.x
11
+ - uses: actions/checkout@v3
12
+ - name: Set up Ruby
13
+ uses: ruby/setup-ruby@v1
16
14
  - name: Set up cache
17
15
  uses: actions/cache@preview
18
16
  with:
@@ -9,11 +9,9 @@ jobs:
9
9
  build:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v1
13
- - name: Set up Ruby 2.6
14
- uses: actions/setup-ruby@v1
15
- with:
16
- ruby-version: 2.6.x
12
+ - uses: actions/checkout@v3
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
17
15
  - name: Setup Rubygems
18
16
  env:
19
17
  RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.7.6
data/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ The format is based on [Keep a Changelog]
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.5] - 2022-08-31
10
+
11
+ - Allow explicitly blank personalisations (https://github.com/dxw/mail-notify/pull/30)
12
+ - Fix Zeitwerk compatibility issue (https://github.com/dxw/mail-notify/pull/58)
13
+ - Dependency updates
14
+
15
+ ## [1.0.4] - 2021-01-28
16
+
17
+ - Remove pessimistic constraint on Rails version
18
+
19
+ ## [1.0.3] - 2020-12-14
20
+
21
+ - Add support for ActionMailer 6.1
22
+
23
+ ## [1.0.2] - 2020-03-24
24
+
25
+ - Add support for ActionMailer 6.0
26
+
9
27
  ## [1.0.1] - 2020-03-06
10
28
 
11
29
  - Support additional Notify services
@@ -42,8 +60,11 @@ The format is based on [Keep a Changelog]
42
60
 
43
61
  - Initial release
44
62
 
45
- [unreleased]:
46
- https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/1.0...HEAD
63
+ [unreleased]: https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/1.0.3...HEAD
64
+ [1.0.5]: https://github.com/dxw/mail-notify/compare/1.0.4...1.0.5
65
+ [1.0.4]: https://github.com/dxw/mail-notify/compare/1.0.3...1.0.4
66
+ [1.0.3]: https://github.com/dxw/mail-notify/compare/1.0.2...1.0.3
67
+ [1.0.2]: https://github.com/dxw/mail-notify/compare/1.0.1...1.0.2
47
68
  [1.0.1]: https://github.com/dxw/mail-notify/compare/1.0...1.0.1
48
69
  [1.0]: https://github.com/dxw/mail-notify/compare/0.2.1...1.0
49
70
  [0.2.1]: https://github.com/dxw/mail-notify/compare/0.2.0...0.2.1
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/README.md CHANGED
@@ -91,6 +91,23 @@ class MyMailer < Mail::Notify::Mailer
91
91
  end
92
92
  ```
93
93
 
94
+ By default, any blank personalisation are removed from the request, which will trigger mail template validation. This is to avoid accidental blanks in the email. If you want to send a blank value, you need to explicitly state that the personalization can be blank:
95
+
96
+ ```ruby
97
+ class MyMailer < Mail::Notify::Mailer
98
+ def send_email
99
+ template_mail('YOUR_TEMPLATE_ID_GOES_HERE',
100
+ to: 'mail@somewhere.com',
101
+ personalisation: {
102
+ foo: foo.name, # This will trigger template validation error when blank
103
+ bar: blank_allowed(bar.name) # This will inject empty string in the template when blank
104
+ }
105
+ )
106
+ end
107
+ end
108
+ ```
109
+
110
+
94
111
  #### With optional Notify arguments
95
112
 
96
113
  It's possible to pass two optional arguments to Notify:
@@ -113,13 +130,34 @@ class MyMailer < Mail::Notify::Mailer
113
130
  end
114
131
  ```
115
132
 
133
+ #### With Devise
134
+
135
+ If you're using [Devise](https://github.com/heartcombo/devise), you can overwrite your Devise mailer to use mail-notify for password reset emails etc.
136
+
137
+ In `config/initializers/devise.rb`:
138
+
139
+ ```ruby
140
+ config.mailer = 'DeviseMailer'
141
+ ```
142
+
143
+ in `app/mailers/devise_mailer.rb`:
144
+
145
+ ```ruby
146
+ class DeviseMailer < Devise::Mailer
147
+ def devise_mail(record, action, opts = {}, &block)
148
+ initialize_from_record(record)
149
+ view_mail(ENV['NOTIFY_TEMPLATE_ID'], headers_for(action, opts))
150
+ end
151
+ end
152
+ ```
153
+
116
154
  ## Previews
117
155
 
118
156
  If you're using ActionMailer with Rails, [previews](https://guides.rubyonrails.org/action_mailer_basics.html#previewing-emails) are supported too, and work in the same way as standard previews. Currently they're shown without any branding, but this may change in future.
119
157
 
120
158
  ## Development
121
159
 
122
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
160
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
123
161
 
124
162
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
125
163
 
@@ -14,6 +14,10 @@ module Mail
14
14
 
15
15
  mail(headers.merge(body: "", subject: "", template_id: template_id))
16
16
  end
17
+
18
+ def blank_allowed(value)
19
+ value.presence || Personalisation::BLANK
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -3,6 +3,8 @@
3
3
  module Mail
4
4
  module Notify
5
5
  class Personalisation
6
+ BLANK = Object.new
7
+
6
8
  def initialize(mail)
7
9
  @body = mail.body.raw_source
8
10
  @subject = mail.subject
@@ -10,7 +12,9 @@ module Mail
10
12
  end
11
13
 
12
14
  def to_h
13
- merged_options.reject { |_k, v| v.blank? }
15
+ merged_options
16
+ .reject { |_k, v| v.blank? }
17
+ .transform_values { |value| value == BLANK ? "" : value }
14
18
  end
15
19
 
16
20
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mail
4
4
  module Notify
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.5"
6
6
  end
7
7
  end
File without changes
data/mail-notify.gemspec CHANGED
@@ -25,14 +25,18 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 2.0"
27
27
  spec.add_development_dependency "coveralls", "~> 0.8.22"
28
- spec.add_development_dependency "pry", "~> 0.12.0"
28
+ spec.add_development_dependency "pry", "~> 0.14.1"
29
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.2"
30
+ spec.add_development_dependency "rake", "~> 13.0.6"
31
+ spec.add_development_dependency "rspec-rails", "~> 5.1"
32
+ spec.add_development_dependency "standard", "0.4.7"
33
33
  spec.add_development_dependency "sqlite3", "~> 1.4.1"
34
- spec.add_development_dependency "webmock", "~> 3.7.6"
34
+ spec.add_development_dependency "webmock", "~> 3.16.0"
35
35
 
36
- spec.add_dependency "actionmailer", ">= 5.2.4.2", "< 6.1"
36
+ spec.add_dependency "actionmailer", ">= 5.2.4.6"
37
+ spec.add_dependency "activesupport", ">= 5.2.4.6"
38
+ spec.add_dependency "actionpack", ">= 5.2.7.1"
39
+ spec.add_dependency "actionview", ">= 5.2.7.1"
37
40
  spec.add_dependency "notifications-ruby-client", "~> 5.1"
41
+ spec.add_dependency "rack", ">= 2.1.4.1"
38
42
  end
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
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: 1.0.2
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Harrison
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-24 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.12.0
47
+ version: 0.14.1
48
48
  type: :development
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: 0.12.0
54
+ version: 0.14.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,42 +72,42 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 12.3.3
75
+ version: 13.0.6
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: 12.3.3
82
+ version: 13.0.6
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.8'
89
+ version: '5.1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.8'
96
+ version: '5.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: standard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: '0.2'
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: '0.2'
110
+ version: 0.4.7
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sqlite3
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,34 +128,70 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 3.7.6
131
+ version: 3.16.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 3.7.6
138
+ version: 3.16.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: actionmailer
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 5.2.4.2
146
- - - "<"
145
+ version: 5.2.4.6
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 5.2.4.6
153
+ - !ruby/object:Gem::Dependency
154
+ name: activesupport
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 5.2.4.6
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 5.2.4.6
167
+ - !ruby/object:Gem::Dependency
168
+ name: actionpack
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
147
172
  - !ruby/object:Gem::Version
148
- version: '6.1'
173
+ version: 5.2.7.1
149
174
  type: :runtime
150
175
  prerelease: false
151
176
  version_requirements: !ruby/object:Gem::Requirement
152
177
  requirements:
153
178
  - - ">="
154
179
  - !ruby/object:Gem::Version
155
- version: 5.2.4.2
156
- - - "<"
180
+ version: 5.2.7.1
181
+ - !ruby/object:Gem::Dependency
182
+ name: actionview
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 5.2.7.1
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
157
193
  - !ruby/object:Gem::Version
158
- version: '6.1'
194
+ version: 5.2.7.1
159
195
  - !ruby/object:Gem::Dependency
160
196
  name: notifications-ruby-client
161
197
  requirement: !ruby/object:Gem::Requirement
@@ -170,6 +206,20 @@ dependencies:
170
206
  - - "~>"
171
207
  - !ruby/object:Gem::Version
172
208
  version: '5.1'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rack
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: 2.1.4.1
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: 2.1.4.1
173
223
  description:
174
224
  email:
175
225
  - pezholio@gmail.com
@@ -178,6 +228,7 @@ extensions: []
178
228
  extra_rdoc_files: []
179
229
  files:
180
230
  - ".coveralls.yml"
231
+ - ".github/dependabot.yml"
181
232
  - ".github/setup-rubygems.sh"
182
233
  - ".github/workflows/build.yml"
183
234
  - ".github/workflows/publish.yml"
@@ -187,6 +238,7 @@ files:
187
238
  - ".ruby-version"
188
239
  - CHANGELOG.md
189
240
  - CODE_OF_CONDUCT.md
241
+ - CONTRIBUTING.md
190
242
  - Gemfile
191
243
  - LICENSE.txt
192
244
  - README.md
@@ -194,7 +246,6 @@ files:
194
246
  - bin/console
195
247
  - bin/setup
196
248
  - docs/screenshot.png
197
- - lib/mail/notify.rb
198
249
  - lib/mail/notify/delivery_method.rb
199
250
  - lib/mail/notify/layouts/govuk_notify_layout.html.erb
200
251
  - lib/mail/notify/mailer.rb
@@ -203,7 +254,9 @@ files:
203
254
  - lib/mail/notify/personalisation.rb
204
255
  - lib/mail/notify/railtie.rb
205
256
  - lib/mail/notify/version.rb
257
+ - lib/notify.rb
206
258
  - mail-notify.gemspec
259
+ - renovate.json
207
260
  homepage: https://github.com/dxw/mail-notify
208
261
  licenses:
209
262
  - MIT
@@ -223,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
276
  - !ruby/object:Gem::Version
224
277
  version: '0'
225
278
  requirements: []
226
- rubygems_version: 3.0.3
279
+ rubygems_version: 3.1.6
227
280
  signing_key:
228
281
  specification_version: 4
229
282
  summary: ActionMailer support for the GOV.UK Notify API