hanami-mailer 1.3.0.beta1 → 1.3.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/hanami-mailer.gemspec +1 -1
- data/lib/hanami/mailer.rb +7 -5
- data/lib/hanami/mailer/dsl.rb +95 -5
- data/lib/hanami/mailer/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52f0c61d4de8af3cfa11ee5ba09337c5e1091f04f23ccf3c149a8e13c71bf71b
|
|
4
|
+
data.tar.gz: aa1009dd9bc9036c72e657763fc7d1892dc0769f2b3bf89f9ac5ed5e8299d0d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6559982652477d33fc96333a51a188580ef564152ba66b694f28ce7f01d5895b5a3e0da1549d98de197cd83d951735b6ad0ec2ce8a6f16559cdb41986f7e4967
|
|
7
|
+
data.tar.gz: a512a7528eca16fc7ff933884b5eadeb69a337ceee9539e1a9990847b9540e245ab21c35347af9fc9900f13d2dbb870950d23bae2b0f29e61413c064a3e050a7
|
data/CHANGELOG.md
CHANGED
data/hanami-mailer.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
spec.required_ruby_version = '>= 2.3.0'
|
|
21
21
|
|
|
22
|
-
spec.add_dependency 'hanami-utils', '~> 1.3
|
|
22
|
+
spec.add_dependency 'hanami-utils', '~> 1.3'
|
|
23
23
|
spec.add_dependency 'tilt', '~> 2.0', '>= 2.0.1'
|
|
24
24
|
spec.add_dependency 'mail', '~> 2.6'
|
|
25
25
|
|
data/lib/hanami/mailer.rb
CHANGED
|
@@ -225,6 +225,7 @@ module Hanami
|
|
|
225
225
|
mail.deliver
|
|
226
226
|
rescue ArgumentError => e
|
|
227
227
|
raise MissingDeliveryDataError if e.message =~ /SMTP (From|To) address/
|
|
228
|
+
|
|
228
229
|
raise
|
|
229
230
|
end
|
|
230
231
|
|
|
@@ -283,11 +284,12 @@ module Hanami
|
|
|
283
284
|
# rubocop:disable Metrics/AbcSize
|
|
284
285
|
def build
|
|
285
286
|
Mail.new.tap do |m|
|
|
286
|
-
m.from
|
|
287
|
-
m.to
|
|
288
|
-
m.cc
|
|
289
|
-
m.bcc
|
|
290
|
-
m.
|
|
287
|
+
m.from = __dsl(:from)
|
|
288
|
+
m.to = __dsl(:to)
|
|
289
|
+
m.cc = __dsl(:cc)
|
|
290
|
+
m.bcc = __dsl(:bcc)
|
|
291
|
+
m.reply_to = __dsl(:reply_to)
|
|
292
|
+
m.subject = __dsl(:subject)
|
|
291
293
|
|
|
292
294
|
m.charset = charset
|
|
293
295
|
m.html_part = __part(:html)
|
data/lib/hanami/mailer/dsl.rb
CHANGED
|
@@ -11,11 +11,12 @@ module Hanami
|
|
|
11
11
|
# @api private
|
|
12
12
|
def self.extended(base)
|
|
13
13
|
base.class_eval do
|
|
14
|
-
@from
|
|
15
|
-
@to
|
|
16
|
-
@cc
|
|
17
|
-
@bcc
|
|
18
|
-
@
|
|
14
|
+
@from = nil
|
|
15
|
+
@to = nil
|
|
16
|
+
@cc = nil
|
|
17
|
+
@bcc = nil
|
|
18
|
+
@reply_to = nil
|
|
19
|
+
@subject = nil
|
|
19
20
|
end
|
|
20
21
|
end
|
|
21
22
|
|
|
@@ -319,6 +320,95 @@ module Hanami
|
|
|
319
320
|
end
|
|
320
321
|
end
|
|
321
322
|
|
|
323
|
+
# Sets the reply_to for mail messages
|
|
324
|
+
#
|
|
325
|
+
# It accepts a hardcoded value as a string or array of strings.
|
|
326
|
+
# For dynamic values, you can specify a symbol that represents an instance
|
|
327
|
+
# method.
|
|
328
|
+
#
|
|
329
|
+
# This value is optional.
|
|
330
|
+
#
|
|
331
|
+
# When a value is given, it specifies the reply_to for the email.
|
|
332
|
+
# When a value is not given, it returns the reply_to of the email.
|
|
333
|
+
#
|
|
334
|
+
# This is part of a DSL, for this reason when this method is called with
|
|
335
|
+
# an argument, it will set the corresponding class variable. When
|
|
336
|
+
# called without, it will return the already set value, or the default.
|
|
337
|
+
#
|
|
338
|
+
# @overload reply_to(value)
|
|
339
|
+
# Sets the reply_to
|
|
340
|
+
# @param value [String, Array, Symbol] the hardcoded value or method name
|
|
341
|
+
# @return [NilClass]
|
|
342
|
+
#
|
|
343
|
+
# @overload reply_to
|
|
344
|
+
# Returns the reply_to
|
|
345
|
+
# @return [String, Array, Symbol] the recipient
|
|
346
|
+
#
|
|
347
|
+
# @since 1.3.0
|
|
348
|
+
#
|
|
349
|
+
# @example Hardcoded value (String)
|
|
350
|
+
# require 'hanami/mailer'
|
|
351
|
+
#
|
|
352
|
+
# class WelcomeMailer
|
|
353
|
+
# include Hanami::Mailer
|
|
354
|
+
#
|
|
355
|
+
# to "user@example.com"
|
|
356
|
+
# reply_to "other.user@example.com"
|
|
357
|
+
# end
|
|
358
|
+
#
|
|
359
|
+
# @example Hardcoded value (Array)
|
|
360
|
+
# require 'hanami/mailer'
|
|
361
|
+
#
|
|
362
|
+
# class WelcomeMailer
|
|
363
|
+
# include Hanami::Mailer
|
|
364
|
+
#
|
|
365
|
+
# to ["user-1@example.com", "user-2@example.com"]
|
|
366
|
+
# reply_to ["other.user-1@example.com", "other.user-2@example.com"]
|
|
367
|
+
# end
|
|
368
|
+
#
|
|
369
|
+
# @example Method (Symbol)
|
|
370
|
+
# require 'hanami/mailer'
|
|
371
|
+
#
|
|
372
|
+
# class WelcomeMailer
|
|
373
|
+
# include Hanami::Mailer
|
|
374
|
+
# to "user@example.com"
|
|
375
|
+
# reply_to :email_address
|
|
376
|
+
#
|
|
377
|
+
# private
|
|
378
|
+
#
|
|
379
|
+
# def email_address
|
|
380
|
+
# user.email
|
|
381
|
+
# end
|
|
382
|
+
# end
|
|
383
|
+
#
|
|
384
|
+
# other_user = User.new(name: 'L')
|
|
385
|
+
# WelcomeMailer.deliver(user: other_user)
|
|
386
|
+
#
|
|
387
|
+
# @example Method that returns a collection of recipients
|
|
388
|
+
# require 'hanami/mailer'
|
|
389
|
+
#
|
|
390
|
+
# class WelcomeMailer
|
|
391
|
+
# include Hanami::Mailer
|
|
392
|
+
# to "user@example.com"
|
|
393
|
+
# reply_to :recipients
|
|
394
|
+
#
|
|
395
|
+
# private
|
|
396
|
+
#
|
|
397
|
+
# def recipients
|
|
398
|
+
# users.map(&:email)
|
|
399
|
+
# end
|
|
400
|
+
# end
|
|
401
|
+
#
|
|
402
|
+
# other_users = [User.new(name: 'L'), User.new(name: 'MG')]
|
|
403
|
+
# WelcomeMailer.deliver(users: other_users)
|
|
404
|
+
def reply_to(value = nil)
|
|
405
|
+
if value.nil?
|
|
406
|
+
@reply_to
|
|
407
|
+
else
|
|
408
|
+
@reply_to = value
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
|
|
322
412
|
# Sets the recipient for mail messages
|
|
323
413
|
#
|
|
324
414
|
# It accepts a hardcoded value as a string or array of strings.
|
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.3.0
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Luca Guidi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-10-24 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.3
|
|
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.3
|
|
26
|
+
version: '1.3'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: tilt
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -134,9 +134,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
134
134
|
version: 2.3.0
|
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
|
137
|
-
- - "
|
|
137
|
+
- - ">="
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
|
-
version:
|
|
139
|
+
version: '0'
|
|
140
140
|
requirements: []
|
|
141
141
|
rubyforge_project:
|
|
142
142
|
rubygems_version: 2.7.7
|