send_grid_mailer 2.2.0 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63020124b1515b99d0c9caf1d5df50ea94321a32c721a7200be76ac46514afca
4
- data.tar.gz: b29dbcffafae53610da1043f09b9cb855af6f54f556faa818c7395c205199efb
3
+ metadata.gz: d3ba49658ee4d361ee0447235860596bfbda468304436ef9853ef240fb578aae
4
+ data.tar.gz: 578c91e30a4aadc8c6399eab270a661f6d319e60a3197033a1018bd6fcfb5fe4
5
5
  SHA512:
6
- metadata.gz: 7ab1703c02724aaf91be20a94ef241eecee55c0767efabbe87b7a8ad52d5d1f93f541e1208551a566f7bdf9b909537c6f320a83e610ce26842dc6280fafd7b7a
7
- data.tar.gz: fc46b2077fe4e08ecdbce69cf47c2dc3c088c6c9e8d8db36d510480e7cbe008160e5ae1f1cae7b5ddacdb4457976f000dda07819fee62272ad22dcb9ae30f93c
6
+ metadata.gz: 077a40754df2f0004cf2dc8feff8583b927a644d69acbd67fbf200bbce7d1c3a1edd32f49594f79f0a8808b1d1a672ff67952cfae0a30cca2497d86d5e2a15b4
7
+ data.tar.gz: 56849b81c28093d0fadcc07e24abe1912a5e3291330d29f3c929f54e117776add2af462e6c8d5533f3fb3e459b8ea34f3def59eaeb038c827d2b065cade5355f
data/.circleci/config.yml CHANGED
@@ -13,10 +13,10 @@ executors:
13
13
  parameters:
14
14
  ruby-version:
15
15
  description: "Ruby version"
16
- default: "2.7"
16
+ default: "3.2"
17
17
  type: string
18
18
  docker:
19
- - image: circleci/ruby:<<parameters.ruby-version>>-node
19
+ - image: cimg/ruby:<<parameters.ruby-version>>-node
20
20
  environment: *env-vars
21
21
 
22
22
  commands:
@@ -54,7 +54,7 @@ jobs:
54
54
  parameters:
55
55
  ruby-version:
56
56
  description: "Ruby version"
57
- default: "2.7"
57
+ default: "3.2"
58
58
  type: string
59
59
  executor:
60
60
  name: main-executor
@@ -92,7 +92,7 @@ workflows:
92
92
  - test:
93
93
  matrix:
94
94
  parameters:
95
- ruby-version: ["2.6", "2.7"]
95
+ ruby-version: ["2.6", "2.7", "3.1", "3.2"]
96
96
  - deploy:
97
97
  context: org-global
98
98
  filters:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7
1
+ 3.2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ### v2.4.0
6
+
7
+ #### Added
8
+
9
+ * Add the set_reply_to method to enable setting the Reply-To header. [#28] thanks @m-quezada-loyola
10
+
11
+ ### v2.3.0
12
+
13
+ ##### Added
14
+
15
+ * Add Ruby 3.2 support
16
+
5
17
  ### v2.2.0
6
18
 
7
19
  * :sendgrid_dev replace handlerbars library with a pure ruby implementation. [#25]
@@ -6,6 +6,7 @@ module SendGridMailer
6
6
  :set_template_id,
7
7
  :set_sender,
8
8
  :set_recipients,
9
+ :set_reply_to,
9
10
  :set_subject,
10
11
  :set_content,
11
12
  :add_attachment,
@@ -30,16 +31,10 @@ module SendGridMailer
30
31
  end
31
32
 
32
33
  def set_sender(email)
33
- return unless email
34
-
35
- matched_format = email.match(/<(.+)>/)
36
- if matched_format
37
- address = matched_format[1]
38
- name = email.match(/\"?([^<^\"]*)\"?\s?/)[1].strip
39
- mail.from = SendGrid::Email.new(email: address, name: name)
40
- else
41
- mail.from = SendGrid::Email.new(email: email)
42
- end
34
+ email_info = extract_email_and_name(email)
35
+ return unless email_info
36
+
37
+ mail.from = SendGrid::Email.new(email: email_info[:email], name: email_info[:name])
43
38
  end
44
39
 
45
40
  def set_recipients(mode, *emails)
@@ -50,6 +45,13 @@ module SendGridMailer
50
45
  end
51
46
  end
52
47
 
48
+ def set_reply_to(email)
49
+ email_info = extract_email_and_name(email)
50
+ return unless email_info
51
+
52
+ mail.reply_to = SendGrid::Email.new(email: email_info[:email], name: email_info[:name])
53
+ end
54
+
53
55
  def set_subject(value)
54
56
  return unless value
55
57
 
@@ -94,6 +96,19 @@ module SendGridMailer
94
96
  @mail ||= SendGrid::Mail.new
95
97
  end
96
98
 
99
+ def extract_email_and_name(email)
100
+ return unless email
101
+
102
+ matched_format = email.match(/<(.+)>/)
103
+ if matched_format
104
+ address = matched_format[1]
105
+ name = email.match(/\"?([^<^\"]*)\"?\s?/)[1].strip
106
+ { email: address, name: name }
107
+ else
108
+ { email: email }
109
+ end
110
+ end
111
+
97
112
  def clean_recipients(mode)
98
113
  personalization.instance_variable_set("@#{mode}s", [])
99
114
  end
@@ -108,6 +123,8 @@ module SendGridMailer
108
123
 
109
124
  def sender?; mail.from.present? end
110
125
 
126
+ def reply_to?; mail.reply_to.present? end
127
+
111
128
  def subject?; personalization.subject.present? end
112
129
 
113
130
  def template_id?; mail.template_id.present? end
@@ -65,6 +65,7 @@ module SendGridMailer
65
65
  m.to = emails(:tos) if emails(:tos).present?
66
66
  m.cc = emails(:ccs) if emails(:ccs).present?
67
67
  m.bcc = emails(:bccs) if emails(:bccs).present?
68
+ m.reply_to = @sg_definition.mail.reply_to["email"] if @sg_definition.mail.reply_to.present?
68
69
 
69
70
  m
70
71
  end
@@ -33,6 +33,7 @@ module ActionMailer
33
33
  set_recipients(:to, params[:to])
34
34
  set_recipients(:cc, params[:cc])
35
35
  set_recipients(:bcc, params[:bcc])
36
+ set_reply_to(params[:reply_to]) unless sg_definition.reply_to?
36
37
  set_subject(params[:subject]) unless sg_definition.subject?
37
38
  set_body(params)
38
39
  add_attachments
@@ -1,3 +1,3 @@
1
1
  module SendGridMailer
2
- VERSION = "2.2.0"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -48,6 +48,15 @@ class TestMailer < ApplicationMailer
48
48
  mail(template_id: "XXX")
49
49
  end
50
50
 
51
+ def reply_to_email
52
+ set_reply_to("reply-to@platan.us")
53
+ mail(body: "X")
54
+ end
55
+
56
+ def reply_to_params_email
57
+ mail(reply_to: "reply-to@platan.us", body: "X")
58
+ end
59
+
51
60
  def subject_email
52
61
  set_subject("My Subject")
53
62
  mail(body: "X")
File without changes