mail-notify 1.0 → 1.0.1

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: 9f36508ecc59051156b2be68986f684048edc3fd7dc658cde126b9c473efe730
4
- data.tar.gz: 3c7f8e5e9eb5eaff953156826be0889b84bd2518a3034327e50eceb3c7f3efe5
3
+ metadata.gz: '0871ca5095f5674b08513169aa9361160fa5d55126f471d5ad313101ed854714'
4
+ data.tar.gz: 67bb0c0ff21658d7ecab145d047318f9822b8256ce9d296df6845a98375ecd2e
5
5
  SHA512:
6
- metadata.gz: 99c1f607b2fac7a132186ee9a9e81a5a497f61639ccdc3a0ebd87ae19f946d115b3e0b182df532d77b7e5db7ab48bcc4dd4d4b29b3cea727857ddc43fa47ab61
7
- data.tar.gz: 485548b456350634e2cafca421c0547c6854ac739b2d702e46f0bde938d3bf74eaac5a2a4f9d9322a74d54ade47b29907f0514b03ec1dbc95bc9586cb8013c89
6
+ metadata.gz: f989326003aeede1438e09100a01ffb05368a2be7099a2c2bdf86bd4991e6d31ac6c9e25b5e11f442393eb4640002859f2deafc750a7a6269716e02c554b3492
7
+ data.tar.gz: 1960f73ec4244ef53ba5a9f96eb0a4b0a32ffcb233d8c3acb787310fa01d7e94b2c2ba24abedee62441e6729af92316ab91226159816afa415f94bc26b3fcd3a
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog]
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.1] - 2020-03-06
10
+
11
+ - Support additional Notify services
12
+
9
13
  ## [1.0] - 2019-10-22
10
14
 
11
15
  - Bump Notify gem to 5.1
@@ -40,6 +44,7 @@ The format is based on [Keep a Changelog]
40
44
 
41
45
  [unreleased]:
42
46
  https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/1.0...HEAD
47
+ [1.0.1]: https://github.com/dxw/mail-notify/compare/1.0...1.0.1
43
48
  [1.0]: https://github.com/dxw/mail-notify/compare/0.2.1...1.0
44
49
  [0.2.1]: https://github.com/dxw/mail-notify/compare/0.2.0...0.2.1
45
50
  [0.2.0]: https://github.com/dxw/mail-notify/compare/0.1.0...0.2.0
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in mail-notify.gemspec
6
6
  gemspec
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:
data/Rakefile CHANGED
@@ -1,13 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
- require 'coveralls/rake/task'
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[rubocop spec coveralls:push]
12
+ task default: %i[standard spec coveralls:push]
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'notifications/client'
3
+ require "notifications/client"
4
4
 
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'
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, 'You must specify an API key' if settings[:api_key].blank?
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
@@ -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, 'You must specify a template ID' if template_id.blank?
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, 'You must specify a template ID' if template_id.blank?
13
+ raise ArgumentError, "You must specify a template ID" if template_id.blank?
14
14
 
15
- mail(headers.merge(body: '', subject: '', template_id: template_id))
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 = 'text/html'
27
- render html: @email.preview.html.html_safe, layout: 'govuk_notify_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: 'email', layout: false, formats: %i[html]
32
+ render action: "email", layout: false, formats: %i[html]
33
33
  end
34
34
 
35
35
  def notify?
@@ -3,11 +3,11 @@
3
3
  module Mail
4
4
  module Notify
5
5
  class Railtie < Rails::Railtie
6
- initializer 'mail-notify.add_delivery_method', before: 'action_mailer.set_configs' do
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 'mail-notify.action_controller' do
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mail
4
4
  module Notify
5
- VERSION = '1.0'
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
@@ -1,37 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'mail/notify/version'
5
+ require "mail/notify/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'mail-notify'
9
- spec.version = Mail::Notify::VERSION
10
- spec.authors = ['Stuart Harrison']
11
- spec.email = ['pezholio@gmail.com']
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 = 'ActionMailer support for the GOV.UK Notify API'
14
- spec.homepage = 'https://github.com/dxw/mail-notify'
15
- spec.license = 'MIT'
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 = Dir.chdir(File.expand_path(__dir__)) do
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 = 'exe'
23
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ['lib']
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 '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', '~> 10.0'
31
- spec.add_development_dependency 'rspec-rails', '~> 3.8'
32
- spec.add_development_dependency 'rubocop', '~> 0.63'
33
- spec.add_development_dependency 'sqlite3', '~> 1.4.1'
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.2"
33
+ spec.add_development_dependency "sqlite3", "~> 1.4.1"
34
+ spec.add_development_dependency "webmock", "~> 3.7.6"
34
35
 
35
- spec.add_dependency 'actionmailer', '>= 5.0', '< 6.1'
36
- spec.add_dependency 'notifications-ruby-client', '~> 5.1'
36
+ spec.add_dependency "actionmailer", ">= 5.0", "< 6.1"
37
+ spec.add_dependency "notifications-ruby-client", "~> 5.1"
37
38
  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: '1.0'
4
+ version: 1.0.1
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-01-17 00:00:00.000000000 Z
11
+ date: 2020-03-06 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: '10.0'
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: '10.0'
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: rubocop
98
+ name: standard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.63'
103
+ version: '0.2'
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.63'
110
+ version: '0.2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sqlite3
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ 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