mail-notify 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +0,0 @@
1
- name: Build
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
-
8
- runs-on: ubuntu-latest
9
-
10
- steps:
11
- - uses: actions/checkout@v3
12
- - name: Set up Ruby
13
- uses: ruby/setup-ruby@v1
14
- - name: Set up cache
15
- uses: actions/cache@preview
16
- with:
17
- path: vendor/bundle
18
- key: ${{ runner.os }}-gem-${{ hashFiles('**/mail-notify.gemspec') }}
19
- restore-keys: |
20
- ${{ runner.os }}-gem-
21
- - name: Build and test with Rake
22
- run: |
23
- sudo apt-get update
24
- sudo apt-get install sqlite3 libsqlite3-dev
25
- gem install bundler
26
- bundle install --jobs 4 --retry 3 --path ./vendor/bundle
27
- bundle exec rake
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mail
4
- module Notify
5
- module MailersController
6
- def preview
7
- @email_action = File.basename(params[:path])
8
- return super unless @preview.email_exists?(@email_action)
9
-
10
- @email = @preview.call(@email_action, params)
11
-
12
- return super unless notify?
13
-
14
- return render_part if params[:part]
15
-
16
- render_preview_wrapper
17
- end
18
-
19
- private
20
-
21
- def render_part
22
- # Add the current directory to the view path so that Rails can find
23
- # the `govuk_notify_layout` layout
24
- append_view_path(__dir__)
25
-
26
- response.content_type = "text/html"
27
- render html: @email.preview.html.html_safe, layout: "govuk_notify_layout"
28
- end
29
-
30
- def render_preview_wrapper
31
- @part = @email
32
- render action: "email", layout: false, formats: %i[html]
33
- end
34
-
35
- def notify?
36
- @email.delivery_method.instance_of?(Mail::Notify::DeliveryMethod)
37
- end
38
- end
39
- end
40
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mail
4
- module Notify
5
- class Personalisation
6
- BLANK = Object.new
7
-
8
- def initialize(mail)
9
- @body = mail.body.raw_source
10
- @subject = mail.subject
11
- @personalisation = mail[:personalisation]&.unparsed_value || {}
12
- end
13
-
14
- def to_h
15
- merged_options
16
- .reject { |_k, v| v.blank? }
17
- .transform_values { |value| value == BLANK ? "" : value }
18
- end
19
-
20
- private
21
-
22
- def merged_options
23
- {
24
- body: @body,
25
- subject: @subject
26
- }.merge(@personalisation)
27
- end
28
- end
29
- end
30
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/mailers_controller"
4
-
5
- module Mail
6
- module Notify
7
- class Railtie < Rails::Railtie
8
- initializer "mail-notify.add_delivery_method", before: "action_mailer.set_configs" do
9
- ActionMailer::Base.add_delivery_method(:notify, Mail::Notify::DeliveryMethod)
10
- end
11
-
12
- initializer "mail-notify.action_controller" do
13
- ActiveSupport.on_load(:action_controller, run_once: true) do
14
- Rails::MailersController.prepend(Mail::Notify::MailersController)
15
- end
16
- end
17
- end
18
- end
19
- end