hanami-mailer 1.2.0 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/LICENSE.md +1 -1
- data/README.md +8 -7
- data/hanami-mailer.gemspec +22 -19
- data/lib/hanami-mailer.rb +3 -1
- data/lib/hanami/mailer.rb +30 -22
- data/lib/hanami/mailer/configuration.rb +9 -7
- data/lib/hanami/mailer/dsl.rb +157 -7
- data/lib/hanami/mailer/rendering/template_name.rb +5 -3
- data/lib/hanami/mailer/rendering/templates_finder.rb +7 -5
- data/lib/hanami/mailer/template.rb +5 -3
- data/lib/hanami/mailer/version.rb +3 -1
- metadata +32 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa9852dec3800b06a8282dd1ee9d7c3c74a0acdac120657de03283ba1925d6a
|
4
|
+
data.tar.gz: ff87640e34325a09d94657ff0358cb456ff1f96826111df68b4f628619f95525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a4c8d1f3463a2378f587ddcb20c24cf281afd4c033f725df476e4a0b12d67ddaba90618bc73d5bd9bc614263d8bc257eba0e9922a8e30ae9367a0b86e4686e
|
7
|
+
data.tar.gz: 1ee77f48da2d39f1669e901b0f57981ffa89026283b8c37070900fcc5fe65d192850b6c2774b851c901fc8a7567c45c27056dc996783fa9e03a8470dbbe11923
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
# Hanami::Mailer
|
2
2
|
Mail for Ruby applications
|
3
3
|
|
4
|
+
## v1.3.3 - 2021-01-14
|
5
|
+
### Added
|
6
|
+
- [Luca Guidi] Official support for Ruby: MRI 3.0
|
7
|
+
|
8
|
+
## v1.3.2 - 2020-02-03
|
9
|
+
### Added
|
10
|
+
- [Luca Guidi] Official support for Ruby: MRI 2.7
|
11
|
+
- [glaszig] Added `Hanami::Mailer.return_path` and `#return_path` to specify `MAIL FROM` address
|
12
|
+
|
13
|
+
## v1.3.1 - 2019-01-18
|
14
|
+
### Added
|
15
|
+
- [Luca Guidi] Official support for Ruby: MRI 2.6
|
16
|
+
- [Luca Guidi] Support `bundler` 2.0+
|
17
|
+
|
18
|
+
## v1.3.0 - 2018-10-24
|
19
|
+
### Added
|
20
|
+
- [Ben Bachhuber] Added support for `reply_to`
|
21
|
+
|
22
|
+
## v1.3.0.beta1 - 2018-08-08
|
23
|
+
### Added
|
24
|
+
- [Luca Guidi] Official support for JRuby 9.2.0.0
|
25
|
+
|
4
26
|
## v1.2.0 - 2018-04-11
|
5
27
|
|
6
28
|
## v1.2.0.rc2 - 2018-04-06
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -4,11 +4,10 @@ Mail for Ruby applications.
|
|
4
4
|
|
5
5
|
## Status
|
6
6
|
|
7
|
-
[![Gem Version](
|
8
|
-
[![
|
9
|
-
[![Coverage](
|
10
|
-
[![
|
11
|
-
[![Dependencies](http://img.shields.io/gemnasium/hanami/mailer.svg)](https://gemnasium.com/hanami/mailer)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/hanami-mailer.svg)](https://badge.fury.io/rb/hanami-mailer)
|
8
|
+
[![CI](https://github.com/hanami/mailer/workflows/ci/badge.svg?branch=master)](https://github.com/hanami/mailer/actions?query=workflow%3Aci+branch%3Amaster)
|
9
|
+
[![Test Coverage](https://codecov.io/gh/hanami/mailer/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/mailer)
|
10
|
+
[![Depfu](https://badges.depfu.com/badges/739c6e10eaf20d3ba4240d00828284db/overview.svg)](https://depfu.com/github/hanami/mailer?project=Bundler)
|
12
11
|
[![Inline Docs](http://inch-ci.org/github/hanami/mailer.svg)](http://inch-ci.org/github/hanami/mailer)
|
13
12
|
|
14
13
|
## Contact
|
@@ -80,6 +79,7 @@ end.load!
|
|
80
79
|
class WelcomeMailer
|
81
80
|
include Hanami::Mailer
|
82
81
|
|
82
|
+
return_path 'bounce@sender.com'
|
83
83
|
from 'noreply@sender.com'
|
84
84
|
to 'noreply@recipient.com'
|
85
85
|
cc 'cc@sender.com'
|
@@ -311,7 +311,7 @@ It supports a few options:
|
|
311
311
|
```ruby
|
312
312
|
require 'hanami/mailer'
|
313
313
|
|
314
|
-
Hanami::
|
314
|
+
Hanami::Mailer.configure do
|
315
315
|
# Set the root path where to search for templates
|
316
316
|
# Argument: String, Pathname, #to_pathname, defaults to the current directory
|
317
317
|
#
|
@@ -326,6 +326,7 @@ Hanami::Maler.configure do
|
|
326
326
|
# Argument: Symbol
|
327
327
|
# Argument: Hash, optional configurations
|
328
328
|
delivery_method :stmp
|
329
|
+
end
|
329
330
|
```
|
330
331
|
|
331
332
|
### Attachments
|
@@ -414,6 +415,6 @@ __Hanami::Mailer__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
|
414
415
|
|
415
416
|
## Copyright
|
416
417
|
|
417
|
-
Copyright © 2015-
|
418
|
+
Copyright © 2015-2021 Luca Guidi – Released under MIT License
|
418
419
|
|
419
420
|
This project was formerly known as Lotus (`lotus-mailer`).
|
data/hanami-mailer.gemspec
CHANGED
@@ -1,29 +1,32 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
5
|
+
require "hanami/mailer/version"
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
8
|
+
spec.name = "hanami-mailer"
|
7
9
|
spec.version = Hanami::Mailer::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
+
spec.authors = ["Luca Guidi"]
|
11
|
+
spec.email = ["me@lucaguidi.com"]
|
10
12
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.summary = "Mail for Ruby applications."
|
14
|
+
spec.description = "Mail for Ruby applications and Hanami mailers"
|
15
|
+
spec.homepage = "http://hanamirb.org"
|
16
|
+
spec.license = "MIT"
|
15
17
|
|
16
|
-
spec.files = `git ls-files -- lib/* CHANGELOG.md LICENSE.md README.md hanami-mailer.gemspec`.split($/)
|
17
|
-
spec.bindir =
|
18
|
+
spec.files = `git ls-files -- lib/* CHANGELOG.md LICENSE.md README.md hanami-mailer.gemspec`.split($/)
|
19
|
+
spec.bindir = "exe"
|
18
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
20
|
-
spec.required_ruby_version =
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
spec.required_ruby_version = ">= 2.3.0"
|
21
23
|
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
24
|
+
spec.add_dependency "hanami-utils", "~> 1.3"
|
25
|
+
spec.add_dependency "tilt", "~> 2.0", ">= 2.0.1"
|
26
|
+
spec.add_dependency "mail", "~> 2.6"
|
25
27
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
28
|
+
spec.add_development_dependency "bundler", ">= 1.6", "< 3"
|
29
|
+
spec.add_development_dependency "rake", "~> 13"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.7"
|
31
|
+
spec.add_development_dependency "rubocop", "0.81" # rubocop 0.81+ removed support for Ruby 2.3
|
29
32
|
end
|
data/lib/hanami-mailer.rb
CHANGED
data/lib/hanami/mailer.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami/utils/class_attribute"
|
4
|
+
require "hanami/mailer/version"
|
5
|
+
require "hanami/mailer/configuration"
|
6
|
+
require "hanami/mailer/dsl"
|
7
|
+
require "mail"
|
6
8
|
|
7
9
|
# Hanami
|
8
10
|
#
|
@@ -34,8 +36,8 @@ module Hanami
|
|
34
36
|
# @since 0.1.0
|
35
37
|
# @api private
|
36
38
|
CONTENT_TYPES = {
|
37
|
-
html:
|
38
|
-
txt:
|
39
|
+
html: "text/html",
|
40
|
+
txt: "text/plain"
|
39
41
|
}.freeze
|
40
42
|
|
41
43
|
include Utils::ClassAttribute
|
@@ -181,10 +183,17 @@ module Hanami
|
|
181
183
|
# invoice = Invoice.new
|
182
184
|
# user = User.new(name: 'L', email: 'user@example.com')
|
183
185
|
#
|
184
|
-
#
|
185
|
-
# Billing::Invoice.deliver(invoice: invoice, user: user
|
186
|
-
#
|
187
|
-
#
|
186
|
+
# # Deliver both text, HTML parts and the attachment
|
187
|
+
# Billing::Invoice.deliver(invoice: invoice, user: user)
|
188
|
+
#
|
189
|
+
# # Deliver only the text part and the attachment
|
190
|
+
# Billing::Invoice.deliver(invoice: invoice, user: user, format: :txt)
|
191
|
+
#
|
192
|
+
# # Deliver only the text part and the attachment
|
193
|
+
# Billing::Invoice.deliver(invoice: invoice, user: user, format: :html)
|
194
|
+
#
|
195
|
+
# # Deliver both the parts with "iso-8859"
|
196
|
+
# Billing::Invoice.deliver(invoice: invoice, user: user, charset: "iso-8859")
|
188
197
|
def deliver(locals = {})
|
189
198
|
new(locals).deliver
|
190
199
|
end
|
@@ -223,8 +232,9 @@ module Hanami
|
|
223
232
|
# @api private
|
224
233
|
def deliver
|
225
234
|
mail.deliver
|
226
|
-
rescue ArgumentError =>
|
227
|
-
raise MissingDeliveryDataError if
|
235
|
+
rescue ArgumentError => exception
|
236
|
+
raise MissingDeliveryDataError if exception.message =~ /SMTP (From|To) address/
|
237
|
+
|
228
238
|
raise
|
229
239
|
end
|
230
240
|
|
@@ -279,15 +289,15 @@ module Hanami
|
|
279
289
|
|
280
290
|
private
|
281
291
|
|
282
|
-
# rubocop:disable Metrics/MethodLength
|
283
|
-
# rubocop:disable Metrics/AbcSize
|
284
292
|
def build
|
285
293
|
Mail.new.tap do |m|
|
286
|
-
m.
|
287
|
-
m.
|
288
|
-
m.
|
289
|
-
m.
|
290
|
-
m.
|
294
|
+
m.return_path = __dsl(:return_path)
|
295
|
+
m.from = __dsl(:from)
|
296
|
+
m.to = __dsl(:to)
|
297
|
+
m.cc = __dsl(:cc)
|
298
|
+
m.bcc = __dsl(:bcc)
|
299
|
+
m.reply_to = __dsl(:reply_to)
|
300
|
+
m.subject = __dsl(:subject)
|
291
301
|
|
292
302
|
m.charset = charset
|
293
303
|
m.html_part = __part(:html)
|
@@ -296,8 +306,6 @@ module Hanami
|
|
296
306
|
m.delivery_method(*Hanami::Mailer.configuration.delivery_method)
|
297
307
|
end
|
298
308
|
end
|
299
|
-
# rubocop:enable Metrics/MethodLength
|
300
|
-
# rubocop:enable Metrics/AbcSize
|
301
309
|
|
302
310
|
# @api private
|
303
311
|
# @since 0.1.0
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "set"
|
4
|
+
require "hanami/utils/kernel"
|
3
5
|
|
4
6
|
module Hanami
|
5
7
|
module Mailer
|
@@ -11,7 +13,7 @@ module Hanami
|
|
11
13
|
#
|
12
14
|
# @since 0.1.0
|
13
15
|
# @api private
|
14
|
-
DEFAULT_ROOT =
|
16
|
+
DEFAULT_ROOT = "."
|
15
17
|
|
16
18
|
# Default delivery method
|
17
19
|
#
|
@@ -23,7 +25,7 @@ module Hanami
|
|
23
25
|
#
|
24
26
|
# @since 0.1.0
|
25
27
|
# @api private
|
26
|
-
DEFAULT_CHARSET =
|
28
|
+
DEFAULT_CHARSET = "UTF-8"
|
27
29
|
|
28
30
|
# @since 0.1.0
|
29
31
|
# @api private
|
@@ -144,10 +146,10 @@ module Hanami
|
|
144
146
|
#
|
145
147
|
# @see Hanami::Mailer.configure
|
146
148
|
def prepare(&blk)
|
147
|
-
if block_given?
|
149
|
+
if block_given?
|
148
150
|
@modules.push(blk)
|
149
151
|
else
|
150
|
-
raise ArgumentError.new(
|
152
|
+
raise ArgumentError.new("Please provide a block")
|
151
153
|
end
|
152
154
|
end
|
153
155
|
|
@@ -191,7 +193,7 @@ module Hanami
|
|
191
193
|
@modules = []
|
192
194
|
end
|
193
195
|
|
194
|
-
|
196
|
+
alias_method :unload!, :reset!
|
195
197
|
|
196
198
|
# Copy the configuration for the given mailer
|
197
199
|
#
|
data/lib/hanami/mailer/dsl.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami/mailer/rendering/template_name"
|
4
|
+
require "hanami/mailer/rendering/templates_finder"
|
3
5
|
|
4
6
|
module Hanami
|
5
7
|
module Mailer
|
@@ -11,11 +13,13 @@ module Hanami
|
|
11
13
|
# @api private
|
12
14
|
def self.extended(base)
|
13
15
|
base.class_eval do
|
14
|
-
@from
|
15
|
-
@to
|
16
|
-
@cc
|
17
|
-
@bcc
|
18
|
-
@
|
16
|
+
@from = nil
|
17
|
+
@to = nil
|
18
|
+
@cc = nil
|
19
|
+
@bcc = nil
|
20
|
+
@reply_to = nil
|
21
|
+
@return_path = nil
|
22
|
+
@subject = nil
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -85,6 +89,63 @@ module Hanami
|
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
92
|
+
# Sets the MAIL FROM address for mail messages.
|
93
|
+
# This lets you specify a "bounce address" different from the sender
|
94
|
+
# address specified with `from`.
|
95
|
+
#
|
96
|
+
# It accepts a hardcoded value as a string, or a symbol that represents
|
97
|
+
# an instance method for more complex logic.
|
98
|
+
#
|
99
|
+
# This value is optional.
|
100
|
+
#
|
101
|
+
# When a value is given, specify the MAIL FROM address of the email
|
102
|
+
# Otherwise, it returns the MAIL FROM address of the email
|
103
|
+
#
|
104
|
+
# This is part of a DSL, for this reason when this method is called with
|
105
|
+
# an argument, it will set the corresponding class variable. When
|
106
|
+
# called without, it will return the already set value, or the default.
|
107
|
+
#
|
108
|
+
# @overload return_path(value)
|
109
|
+
# Sets the MAIL FROM address
|
110
|
+
# @param value [String, Symbol] the hardcoded value or method name
|
111
|
+
# @return [NilClass]
|
112
|
+
#
|
113
|
+
# @overload return_path
|
114
|
+
# Returns the MAIL FROM address
|
115
|
+
# @return [String, Symbol] the MAIL FROM address
|
116
|
+
#
|
117
|
+
# @since 1.3.2
|
118
|
+
#
|
119
|
+
# @example Hardcoded value (String)
|
120
|
+
# require 'hanami/mailer'
|
121
|
+
#
|
122
|
+
# class WelcomeMailer
|
123
|
+
# include Hanami::Mailer
|
124
|
+
#
|
125
|
+
# return_path "bounce@example.com"
|
126
|
+
# end
|
127
|
+
#
|
128
|
+
# @example Method (Symbol)
|
129
|
+
# require 'hanami/mailer'
|
130
|
+
#
|
131
|
+
# class WelcomeMailer
|
132
|
+
# include Hanami::Mailer
|
133
|
+
# return_path :bounce_address
|
134
|
+
#
|
135
|
+
# private
|
136
|
+
#
|
137
|
+
# def bounce_address
|
138
|
+
# "bounce@example.com"
|
139
|
+
# end
|
140
|
+
# end
|
141
|
+
def return_path(value = nil)
|
142
|
+
if value.nil?
|
143
|
+
@return_path
|
144
|
+
else
|
145
|
+
@return_path = value
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
88
149
|
# Sets the sender for mail messages
|
89
150
|
#
|
90
151
|
# It accepts a hardcoded value as a string, or a symbol that represents
|
@@ -319,6 +380,95 @@ module Hanami
|
|
319
380
|
end
|
320
381
|
end
|
321
382
|
|
383
|
+
# Sets the reply_to for mail messages
|
384
|
+
#
|
385
|
+
# It accepts a hardcoded value as a string or array of strings.
|
386
|
+
# For dynamic values, you can specify a symbol that represents an instance
|
387
|
+
# method.
|
388
|
+
#
|
389
|
+
# This value is optional.
|
390
|
+
#
|
391
|
+
# When a value is given, it specifies the reply_to for the email.
|
392
|
+
# When a value is not given, it returns the reply_to of the email.
|
393
|
+
#
|
394
|
+
# This is part of a DSL, for this reason when this method is called with
|
395
|
+
# an argument, it will set the corresponding class variable. When
|
396
|
+
# called without, it will return the already set value, or the default.
|
397
|
+
#
|
398
|
+
# @overload reply_to(value)
|
399
|
+
# Sets the reply_to
|
400
|
+
# @param value [String, Array, Symbol] the hardcoded value or method name
|
401
|
+
# @return [NilClass]
|
402
|
+
#
|
403
|
+
# @overload reply_to
|
404
|
+
# Returns the reply_to
|
405
|
+
# @return [String, Array, Symbol] the recipient
|
406
|
+
#
|
407
|
+
# @since 1.3.0
|
408
|
+
#
|
409
|
+
# @example Hardcoded value (String)
|
410
|
+
# require 'hanami/mailer'
|
411
|
+
#
|
412
|
+
# class WelcomeMailer
|
413
|
+
# include Hanami::Mailer
|
414
|
+
#
|
415
|
+
# to "user@example.com"
|
416
|
+
# reply_to "other.user@example.com"
|
417
|
+
# end
|
418
|
+
#
|
419
|
+
# @example Hardcoded value (Array)
|
420
|
+
# require 'hanami/mailer'
|
421
|
+
#
|
422
|
+
# class WelcomeMailer
|
423
|
+
# include Hanami::Mailer
|
424
|
+
#
|
425
|
+
# to ["user-1@example.com", "user-2@example.com"]
|
426
|
+
# reply_to ["other.user-1@example.com", "other.user-2@example.com"]
|
427
|
+
# end
|
428
|
+
#
|
429
|
+
# @example Method (Symbol)
|
430
|
+
# require 'hanami/mailer'
|
431
|
+
#
|
432
|
+
# class WelcomeMailer
|
433
|
+
# include Hanami::Mailer
|
434
|
+
# to "user@example.com"
|
435
|
+
# reply_to :email_address
|
436
|
+
#
|
437
|
+
# private
|
438
|
+
#
|
439
|
+
# def email_address
|
440
|
+
# user.email
|
441
|
+
# end
|
442
|
+
# end
|
443
|
+
#
|
444
|
+
# other_user = User.new(name: 'L')
|
445
|
+
# WelcomeMailer.deliver(user: other_user)
|
446
|
+
#
|
447
|
+
# @example Method that returns a collection of recipients
|
448
|
+
# require 'hanami/mailer'
|
449
|
+
#
|
450
|
+
# class WelcomeMailer
|
451
|
+
# include Hanami::Mailer
|
452
|
+
# to "user@example.com"
|
453
|
+
# reply_to :recipients
|
454
|
+
#
|
455
|
+
# private
|
456
|
+
#
|
457
|
+
# def recipients
|
458
|
+
# users.map(&:email)
|
459
|
+
# end
|
460
|
+
# end
|
461
|
+
#
|
462
|
+
# other_users = [User.new(name: 'L'), User.new(name: 'MG')]
|
463
|
+
# WelcomeMailer.deliver(users: other_users)
|
464
|
+
def reply_to(value = nil)
|
465
|
+
if value.nil?
|
466
|
+
@reply_to
|
467
|
+
else
|
468
|
+
@reply_to = value
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
322
472
|
# Sets the recipient for mail messages
|
323
473
|
#
|
324
474
|
# It accepts a hardcoded value as a string or array of strings.
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami/utils/string"
|
2
4
|
|
3
5
|
module Hanami
|
4
6
|
module Mailer
|
@@ -10,7 +12,7 @@ module Hanami
|
|
10
12
|
class TemplateName
|
11
13
|
# @since 0.1.0
|
12
14
|
# @api private
|
13
|
-
NAMESPACE_SEPARATOR =
|
15
|
+
NAMESPACE_SEPARATOR = "::"
|
14
16
|
|
15
17
|
# @since 0.1.0
|
16
18
|
# @api private
|
@@ -45,7 +47,7 @@ module Hanami
|
|
45
47
|
# @since 0.1.0
|
46
48
|
# @api private
|
47
49
|
def replace!(token)
|
48
|
-
@name.gsub
|
50
|
+
@name = @name.gsub(/\A#{token}#{NAMESPACE_SEPARATOR}/, "")
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami/mailer/template"
|
2
4
|
|
3
5
|
module Hanami
|
4
6
|
module Mailer
|
@@ -14,19 +16,19 @@ module Hanami
|
|
14
16
|
#
|
15
17
|
# @api private
|
16
18
|
# @since 0.1.0
|
17
|
-
FORMAT =
|
19
|
+
FORMAT = "*"
|
18
20
|
|
19
21
|
# Default template engines
|
20
22
|
#
|
21
23
|
# @api private
|
22
24
|
# @since 0.1.0
|
23
|
-
ENGINES =
|
25
|
+
ENGINES = "*"
|
24
26
|
|
25
27
|
# Recursive pattern
|
26
28
|
#
|
27
29
|
# @api private
|
28
30
|
# @since 0.1.0
|
29
|
-
RECURSIVE =
|
31
|
+
RECURSIVE = "**"
|
30
32
|
|
31
33
|
# Initialize a finder
|
32
34
|
#
|
@@ -72,7 +74,7 @@ module Hanami
|
|
72
74
|
templates = Hash[]
|
73
75
|
_find.map do |template|
|
74
76
|
name = File.basename(template)
|
75
|
-
format = (name.split(
|
77
|
+
format = (name.split(".")[-2]).to_sym
|
76
78
|
templates[format] = Mailer::Template.new(template)
|
77
79
|
end
|
78
80
|
templates
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tilt"
|
2
4
|
|
3
5
|
module Hanami
|
4
6
|
module Mailer
|
@@ -9,8 +11,8 @@ module Hanami
|
|
9
11
|
#
|
10
12
|
# TODO this is identical to Hanami::View, consider to move into Hanami::Utils
|
11
13
|
class Template
|
12
|
-
def initialize(template)
|
13
|
-
@_template = Tilt.new(template)
|
14
|
+
def initialize(template, encoding = Encoding::UTF_8)
|
15
|
+
@_template = Tilt.new(template, default_encoding: encoding)
|
14
16
|
end
|
15
17
|
|
16
18
|
# Render the template within the context of the given scope.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-utils
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: tilt
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,28 +64,34 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '1.6'
|
68
|
+
- - "<"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '3'
|
68
71
|
type: :development
|
69
72
|
prerelease: false
|
70
73
|
version_requirements: !ruby/object:Gem::Requirement
|
71
74
|
requirements:
|
72
75
|
- - ">="
|
73
76
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
77
|
+
version: '1.6'
|
78
|
+
- - "<"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '3'
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
82
|
name: rake
|
77
83
|
requirement: !ruby/object:Gem::Requirement
|
78
84
|
requirements:
|
79
85
|
- - "~>"
|
80
86
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
87
|
+
version: '13'
|
82
88
|
type: :development
|
83
89
|
prerelease: false
|
84
90
|
version_requirements: !ruby/object:Gem::Requirement
|
85
91
|
requirements:
|
86
92
|
- - "~>"
|
87
93
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
94
|
+
version: '13'
|
89
95
|
- !ruby/object:Gem::Dependency
|
90
96
|
name: rspec
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +106,20 @@ dependencies:
|
|
100
106
|
- - "~>"
|
101
107
|
- !ruby/object:Gem::Version
|
102
108
|
version: '3.7'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: rubocop
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0.81'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0.81'
|
103
123
|
description: Mail for Ruby applications and Hanami mailers
|
104
124
|
email:
|
105
125
|
- me@lucaguidi.com
|
@@ -123,7 +143,7 @@ homepage: http://hanamirb.org
|
|
123
143
|
licenses:
|
124
144
|
- MIT
|
125
145
|
metadata: {}
|
126
|
-
post_install_message:
|
146
|
+
post_install_message:
|
127
147
|
rdoc_options: []
|
128
148
|
require_paths:
|
129
149
|
- lib
|
@@ -138,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
158
|
- !ruby/object:Gem::Version
|
139
159
|
version: '0'
|
140
160
|
requirements: []
|
141
|
-
|
142
|
-
|
143
|
-
signing_key:
|
161
|
+
rubygems_version: 3.2.4
|
162
|
+
signing_key:
|
144
163
|
specification_version: 4
|
145
164
|
summary: Mail for Ruby applications.
|
146
165
|
test_files: []
|