mail-notify 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/README.md +10 -3
- data/lib/mail/notify.rb +4 -0
- data/lib/mail/notify/delivery_method.rb +6 -0
- data/lib/mail/notify/mailers_controller.rb +36 -0
- data/lib/mail/notify/message.rb +11 -0
- data/lib/mail/notify/railtie.rb +6 -0
- data/lib/mail/notify/version.rb +1 -1
- data/mail-notify.gemspec +4 -2
- metadata +37 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96ca2326f9ce5a6c1124e2a58d562a6969ebad1ea464940413e638fe5a7b4213
|
4
|
+
data.tar.gz: e5d02076848631d09ece955616b65a0c167eec463caad492037453a7ebf1cbff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '090eed8f5a382930f3b21b359397605710f7e9108d5d9a2f6711e2d48185c93f22267604ced049d68580aa6250efe138f3d442a37af7eca98c84314f5ccf5545'
|
7
|
+
data.tar.gz: 01152410ad1d43ff204f18e758625466bd773d331cb1bfb7d3ea68d61fd6861d06045db47e4525f8ff4fb733867c9817644889285943caa738d5924b0a41fde8
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
[![CircleCI](https://
|
1
|
+
[![CircleCI Status](https://img.shields.io/circleci/project/github/pezholio/mail-notify.svg?style=flat-square)](https://circleci.com/gh/pezholio/mail-notify)
|
2
|
+
[![Coverage Status](https://img.shields.io/coveralls/github/pezholio/mail-notify.svg?style=flat-square)](https://coveralls.io/github/pezholio/mail-notify)
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/mail-notify.svg?style=flat-square)](https://rubygems.org/gems/mail-notify)
|
4
|
+
[![License](http://img.shields.io/:license-mit-blue.svg)](https://mit-license.org/)
|
2
5
|
|
3
6
|
# Mail::Notify
|
4
7
|
|
@@ -78,6 +81,10 @@ class MyMailer < Mail::Notify::Mailer
|
|
78
81
|
end
|
79
82
|
```
|
80
83
|
|
84
|
+
## Previews
|
85
|
+
|
86
|
+
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.
|
87
|
+
|
81
88
|
## Development
|
82
89
|
|
83
90
|
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.
|
@@ -86,7 +93,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
86
93
|
|
87
94
|
## Contributing
|
88
95
|
|
89
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
96
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pezholio/mail-notify. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
90
97
|
|
91
98
|
## License
|
92
99
|
|
@@ -94,4 +101,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
94
101
|
|
95
102
|
## Code of Conduct
|
96
103
|
|
97
|
-
Everyone interacting in the Mail::Notify project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
104
|
+
Everyone interacting in the Mail::Notify project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pezholio/mail-notify/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/mail/notify.rb
CHANGED
@@ -7,6 +7,10 @@ require 'mail/notify/railtie' if defined? Rails
|
|
7
7
|
require 'mail/notify/delivery_method'
|
8
8
|
require 'mail/notify/personalisation'
|
9
9
|
require 'mail/notify/mailer'
|
10
|
+
require 'mail/notify/message'
|
11
|
+
require 'mail/notify/mailers_controller'
|
12
|
+
|
13
|
+
Mail::Message.include Mail::Notify::Message
|
10
14
|
|
11
15
|
module Mail
|
12
16
|
module Notify
|
@@ -15,6 +15,12 @@ module Mail
|
|
15
15
|
send_email
|
16
16
|
end
|
17
17
|
|
18
|
+
def preview(mail)
|
19
|
+
personalisation = Personalisation.new(mail).to_h
|
20
|
+
template_id = mail[:template_id].to_s
|
21
|
+
client.generate_template_preview(template_id, personalisation: personalisation)
|
22
|
+
end
|
23
|
+
|
18
24
|
private
|
19
25
|
|
20
26
|
def client
|
@@ -0,0 +1,36 @@
|
|
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
|
+
response.content_type = 'text/html'
|
23
|
+
render plain: @email.preview.html.html_safe
|
24
|
+
end
|
25
|
+
|
26
|
+
def render_preview_wrapper
|
27
|
+
@part = @email
|
28
|
+
render action: 'email', layout: false, formats: %w[html]
|
29
|
+
end
|
30
|
+
|
31
|
+
def notify?
|
32
|
+
@email.delivery_method.class == Mail::Notify::DeliveryMethod
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/mail/notify/railtie.rb
CHANGED
@@ -6,6 +6,12 @@ module Mail
|
|
6
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
|
+
|
10
|
+
initializer 'mail-notify.action_controller' do
|
11
|
+
ActiveSupport.on_load(:action_controller, run_once: true) do
|
12
|
+
Rails::MailersController.send(:prepend, Mail::Notify::MailersController)
|
13
|
+
end
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
data/lib/mail/notify/version.rb
CHANGED
data/mail-notify.gemspec
CHANGED
@@ -26,10 +26,12 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
27
|
spec.add_development_dependency 'coveralls', '~> 0.8.22'
|
28
28
|
spec.add_development_dependency 'pry', '~> 0.12.0'
|
29
|
+
spec.add_development_dependency 'rails', '~> 5.2'
|
29
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
31
|
+
spec.add_development_dependency 'rspec-rails', '~> 3.8'
|
31
32
|
spec.add_development_dependency 'rubocop', '~> 0.63'
|
33
|
+
spec.add_development_dependency 'sqlite3', '~> 1.4.1'
|
32
34
|
|
33
35
|
spec.add_dependency 'actionmailer', '~> 5.0'
|
34
|
-
spec.add_dependency 'notifications-ruby-client', '~>
|
36
|
+
spec.add_dependency 'notifications-ruby-client', '~> 3.1'
|
35
37
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Harrison
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.12.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.2'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +81,19 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '10.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
84
|
+
name: rspec-rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
89
|
+
version: '3.8'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
96
|
+
version: '3.8'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rubocop
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0.63'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.4.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.4.1
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: actionmailer
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +142,14 @@ dependencies:
|
|
114
142
|
requirements:
|
115
143
|
- - "~>"
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
145
|
+
version: '3.1'
|
118
146
|
type: :runtime
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
152
|
+
version: '3.1'
|
125
153
|
description:
|
126
154
|
email:
|
127
155
|
- pezholio@gmail.com
|
@@ -139,7 +167,6 @@ files:
|
|
139
167
|
- ".travis.yml"
|
140
168
|
- CODE_OF_CONDUCT.md
|
141
169
|
- Gemfile
|
142
|
-
- Gemfile.lock
|
143
170
|
- LICENSE.txt
|
144
171
|
- README.md
|
145
172
|
- Rakefile
|
@@ -149,6 +176,8 @@ files:
|
|
149
176
|
- lib/mail/notify.rb
|
150
177
|
- lib/mail/notify/delivery_method.rb
|
151
178
|
- lib/mail/notify/mailer.rb
|
179
|
+
- lib/mail/notify/mailers_controller.rb
|
180
|
+
- lib/mail/notify/message.rb
|
152
181
|
- lib/mail/notify/personalisation.rb
|
153
182
|
- lib/mail/notify/railtie.rb
|
154
183
|
- lib/mail/notify/version.rb
|