hanami-mailer 1.3.1 → 1.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b08471dba84f2f9e6f8b13c5085ed9a2f094430109ce674a8758cc244cee1c2d
4
- data.tar.gz: 93194e1b4eefe4cb6e2c7d4eb5048ba7878d5fa1dbd4e16dcd3f11d512c0dcb3
3
+ metadata.gz: 7c6d1550998953f3d5e03031b550d543559c5be86ffd4f1c523062d497a2ccc5
4
+ data.tar.gz: b8405f76831e172ad647ec01ac9a139a7b9e0542db64443715ea5e8bdda2b3eb
5
5
  SHA512:
6
- metadata.gz: 947a24021f123919dee44bf2d388ed82c6edbec1984e8e2fdd2dab5ada8a9e245c375338ea2db90fb9e0ccef0f3964999792c45deaa50fd9121674805d2447a3
7
- data.tar.gz: d215ed8af0cac8ebac90c49d260831a1f0205627e72a3fe97f59b7c9db50dcb77c6b15425eeb5b2c878f714ad1f79025e435857b5019736b98d061e6c9511d19
6
+ metadata.gz: 4fcb959ad5f4e8f2c6e8a1605a48dce7d07ec781dca766d7127989b6e2ec9485ae2f82321ec0ff38f07f7313bdc29474437771045d84d7e1b85a432ad53d763c
7
+ data.tar.gz: 3daf620d72aff005141b9954ef526406c4f522894b0f5bad7a39f2193c40ddfffbecc553c171a70c87615528a4b8eafbdf3dea312ec49553874ec2b00d624b1c
@@ -1,6 +1,11 @@
1
1
  # Hanami::Mailer
2
2
  Mail for Ruby applications
3
3
 
4
+ ## v1.3.2 - 2020-02-03
5
+ ### Added
6
+ - [Luca Guidi] Official support for Ruby: MRI 2.7
7
+ - [glaszig] Added `Hanami::Mailer.return_path` and `#return_path` to specify `MAIL FROM` address
8
+
4
9
  ## v1.3.1 - 2019-01-18
5
10
  ### Added
6
11
  - [Luca Guidi] Official support for Ruby: MRI 2.6
data/README.md CHANGED
@@ -5,7 +5,7 @@ Mail for Ruby applications.
5
5
  ## Status
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/hanami-mailer.svg)](https://badge.fury.io/rb/hanami-mailer)
8
- [![TravisCI](https://travis-ci.org/hanami/mailer.svg?branch=master)](https://travis-ci.org/hanami/mailer)
8
+ [![Build Status](https://ci.hanamirb.org/api/badges/hanami/mailer/status.svg)](https://ci.hanamirb.org/hanami/mailer)
9
9
  [![CircleCI](https://circleci.com/gh/hanami/mailer/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/mailer/tree/master)
10
10
  [![Test Coverage](https://codecov.io/gh/hanami/mailer/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/mailer)
11
11
  [![Depfu](https://badges.depfu.com/badges/739c6e10eaf20d3ba4240d00828284db/overview.svg)](https://depfu.com/github/hanami/mailer?project=Bundler)
@@ -80,6 +80,7 @@ end.load!
80
80
  class WelcomeMailer
81
81
  include Hanami::Mailer
82
82
 
83
+ return_path 'bounce@sender.com'
83
84
  from 'noreply@sender.com'
84
85
  to 'noreply@recipient.com'
85
86
  cc 'cc@sender.com'
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'mail', '~> 2.6'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
27
- spec.add_development_dependency 'rake', '~> 12'
27
+ spec.add_development_dependency 'rake', '~> 13'
28
28
  spec.add_development_dependency 'rspec', '~> 3.7'
29
29
  end
@@ -223,8 +223,8 @@ module Hanami
223
223
  # @api private
224
224
  def deliver
225
225
  mail.deliver
226
- rescue ArgumentError => e
227
- raise MissingDeliveryDataError if e.message =~ /SMTP (From|To) address/
226
+ rescue ArgumentError => exception
227
+ raise MissingDeliveryDataError if exception.message =~ /SMTP (From|To) address/
228
228
 
229
229
  raise
230
230
  end
@@ -284,6 +284,7 @@ module Hanami
284
284
  # rubocop:disable Metrics/AbcSize
285
285
  def build
286
286
  Mail.new.tap do |m|
287
+ m.return_path = __dsl(:return_path)
287
288
  m.from = __dsl(:from)
288
289
  m.to = __dsl(:to)
289
290
  m.cc = __dsl(:cc)
@@ -11,12 +11,13 @@ module Hanami
11
11
  # @api private
12
12
  def self.extended(base)
13
13
  base.class_eval do
14
- @from = nil
15
- @to = nil
16
- @cc = nil
17
- @bcc = nil
18
- @reply_to = nil
19
- @subject = nil
14
+ @from = nil
15
+ @to = nil
16
+ @cc = nil
17
+ @bcc = nil
18
+ @reply_to = nil
19
+ @return_path = nil
20
+ @subject = nil
20
21
  end
21
22
  end
22
23
 
@@ -86,6 +87,63 @@ module Hanami
86
87
  end
87
88
  end
88
89
 
90
+ # Sets the MAIL FROM address for mail messages.
91
+ # This lets you specify a "bounce address" different from the sender
92
+ # address specified with `from`.
93
+ #
94
+ # It accepts a hardcoded value as a string, or a symbol that represents
95
+ # an instance method for more complex logic.
96
+ #
97
+ # This value is optional.
98
+ #
99
+ # When a value is given, specify the MAIL FROM address of the email
100
+ # Otherwise, it returns the MAIL FROM address of the email
101
+ #
102
+ # This is part of a DSL, for this reason when this method is called with
103
+ # an argument, it will set the corresponding class variable. When
104
+ # called without, it will return the already set value, or the default.
105
+ #
106
+ # @overload return_path(value)
107
+ # Sets the MAIL FROM address
108
+ # @param value [String, Symbol] the hardcoded value or method name
109
+ # @return [NilClass]
110
+ #
111
+ # @overload return_path
112
+ # Returns the MAIL FROM address
113
+ # @return [String, Symbol] the MAIL FROM address
114
+ #
115
+ # @since 1.3.2
116
+ #
117
+ # @example Hardcoded value (String)
118
+ # require 'hanami/mailer'
119
+ #
120
+ # class WelcomeMailer
121
+ # include Hanami::Mailer
122
+ #
123
+ # return_path "bounce@example.com"
124
+ # end
125
+ #
126
+ # @example Method (Symbol)
127
+ # require 'hanami/mailer'
128
+ #
129
+ # class WelcomeMailer
130
+ # include Hanami::Mailer
131
+ # return_path :bounce_address
132
+ #
133
+ # private
134
+ #
135
+ # def bounce_address
136
+ # "bounce@example.com"
137
+ # end
138
+ # end
139
+ def return_path(value = nil)
140
+ if value.nil?
141
+ @return_path
142
+ else
143
+ @return_path = value
144
+ end
145
+ end
146
+
89
147
  # Sets the sender for mail messages
90
148
  #
91
149
  # It accepts a hardcoded value as a string, or a symbol that represents
@@ -45,7 +45,7 @@ module Hanami
45
45
  # @since 0.1.0
46
46
  # @api private
47
47
  def replace!(token)
48
- @name.gsub!(/\A#{token}#{NAMESPACE_SEPARATOR}/, '')
48
+ @name = @name.gsub(/\A#{token}#{NAMESPACE_SEPARATOR}/, '')
49
49
  end
50
50
  end
51
51
  end
@@ -9,8 +9,8 @@ module Hanami
9
9
  #
10
10
  # TODO this is identical to Hanami::View, consider to move into Hanami::Utils
11
11
  class Template
12
- def initialize(template)
13
- @_template = Tilt.new(template)
12
+ def initialize(template, encoding = Encoding::UTF_8)
13
+ @_template = Tilt.new(template, default_encoding: encoding)
14
14
  end
15
15
 
16
16
  # Render the template within the context of the given scope.
@@ -1,6 +1,6 @@
1
1
  module Hanami
2
2
  module Mailer
3
3
  # @since 0.1.0
4
- VERSION = '1.3.1'.freeze
4
+ VERSION = '1.3.2'.freeze
5
5
  end
6
6
  end
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.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -84,14 +84,14 @@ dependencies:
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: '12'
87
+ version: '13'
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '12'
94
+ version: '13'
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rspec
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.0.2
147
+ rubygems_version: 3.1.2
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Mail for Ruby applications.