mandrill_mailer 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Yzg2ZGQ3OWZmNWQ2ODA3M2Q0N2UyMGU3MTFlNzc0ODYzYTAxYWMzYQ==
4
+ NDA1OTI0MDFjNWE3MDU3ZGM3ODEyZWI4ODZlMzFhMjllYmFkMjUwNA==
5
5
  data.tar.gz: !binary |-
6
- MzQ3MjQzNzM4ZjRmMWU4MWY5NGQ0MWMxMTNlZTlkYTBlYTdiNzU4Yw==
6
+ NGJjZGVhNTUyMThkZDlmOGJmNGVlZTM4ZGI4NGEzOTA1MDU1ZDA5MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDZmZDI2NDllNGNkNzU3ZDk2MTExMmI5ZmM5ZWVlZWU5NzBhNzc2N2U3NWE4
10
- NjU0NjJmYTkyZGYxZGI2NzIxOGYzOTM2ZjJhMjQwNDNjNzlkMWIxMDE3ZWUz
11
- ZWM3YjlmNjU3ZjIzNzE1ZTI4ZWM5M2NkMzZkZGI2M2QzN2ZmNWM=
9
+ MDM5MTk5MDM3ODQwMDhjZWZiY2NmMDI3ZTM1NDc0MWE1YTc4ZGY5OWY3MDU3
10
+ NTFmNjliZDU5MmZiZWU0Yzk3ZGNmZGU4MDNmNDI0MDgzYTk5YzZmNmYzNTQ2
11
+ MzAxNzFjYzQ1NGFkMjEyOTZlNDAzODIyZTczNmQzYjMzMjIyNTQ=
12
12
  data.tar.gz: !binary |-
13
- YzY4YmVmZDZkMDVmODRjNDIzMjMwYThlOTZkZjA4OTc1YTJjYzY4Y2ZhNDA5
14
- Y2U5NjJmZTZmM2E4MTcyNWFhZjNjMmFlZWFlOTNjYTQwMTc0NGFhNzc3ZDJh
15
- OTM4NGE0YWQ1ZmNiY2Q4NDQzODM4M2YyMjc2YjdiMjU0MmIxZDc=
13
+ MGJkOWE4YmJhNDIzNzIzNzRkZDA0Njk5N2U4NjFiOTRjYzcyM2NiYTUzZjgz
14
+ MjUyMzc2ZjIzM2U0ZmQ1ZmQ3OTdmZjdhNDJjMWVhZDIyYjVmOTQ4MDFlNjkz
15
+ MmVhYTY5ZWQxMDA4NzJmYTU3YjMwNzIxMDY2Zjk3MWIxZjY2ZTI=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.4.6
2
+ - [FEATURE] Added support for images array of embedded images
3
+
1
4
  # 0.4.5
2
5
  - [BUGFIX] Declare `mandrill-api` gem as a runtime dependency to prevent load errors.
3
6
 
data/README.md CHANGED
@@ -114,6 +114,11 @@ end
114
114
  * `filename:` The name of the file
115
115
  * `mimetype:` This is the mimetype of the file. Ex. png = image/png, pdf = application/pdf, txt = text/plain etc
116
116
 
117
+ * `:images` - An array of embedded images to add to the message:
118
+ * `file:` This is the actual file, it will be converted to byte data in the mailer
119
+ * `filename:` The Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
120
+ * `mimetype:` The MIME type of the image - must start with "image/"
121
+
117
122
  * `:async` - Whether or not this message should be sent asynchronously
118
123
 
119
124
  * `:ip_pool` - The name of the dedicated ip pool that should be used to send the message
@@ -59,6 +59,11 @@
59
59
  # filename: The name of the file
60
60
  # mimetype: This is the mimetype of the file. Ex. png = image/png, pdf = application/pdf, txt = text/plain etc
61
61
 
62
+ # :images - An array of embedded images to add to the message:
63
+ # file: This is the actual file, it will be converted to byte data in the mailer
64
+ # filename: The Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
65
+ # mimetype: The MIME type of the image - must start with "image/"
66
+
62
67
  # :headers - Extra headers to add to the message (currently only Reply-To and X-* headers are allowed) {"...": "..."}
63
68
 
64
69
  # :bcc - Add an email to bcc to
@@ -96,7 +101,7 @@ module MandrillMailer
96
101
  # Public: Defaults for the mailer. Currently the only option is from:
97
102
  #
98
103
  # options - The Hash options used to refine the selection (default: {}):
99
- # :from - Default from email address
104
+ # :from - Default from email address
100
105
  #
101
106
  # Examples
102
107
  #
@@ -115,20 +120,21 @@ module MandrillMailer
115
120
  # Public: setup a way to test mailer methods
116
121
  #
117
122
  # mailer_method - Name of the mailer method the test setup is for
123
+ #
118
124
  # block - Block of code to execute to perform the test. The mailer
119
- # and options are passed to the block. The options have to
120
- # contain at least the :email to send the test to.
125
+ # and options are passed to the block. The options have to
126
+ # contain at least the :email to send the test to.
121
127
  #
122
128
  # Examples
123
129
  #
124
- # test_setup_for :invite do |mailer, options|
125
- # invitation = OpenStruct.new({
126
- # email: options[:email],
127
- # owner_name: 'foobar',
128
- # secret: rand(9000000..1000000).to_s
129
- # })
130
- # mailer.invite(invitation).deliver
131
- # end
130
+ # test_setup_for :invite do |mailer, options|
131
+ # invitation = OpenStruct.new({
132
+ # email: options[:email],
133
+ # owner_name: 'foobar',
134
+ # secret: rand(9000000..1000000).to_s
135
+ # })
136
+ # mailer.invite(invitation).deliver
137
+ # end
132
138
  #
133
139
  # Returns the duplicated String.
134
140
  def self.test_setup_for(mailer_method, &block)
@@ -139,12 +145,13 @@ module MandrillMailer
139
145
  # Public: Executes a test email
140
146
  #
141
147
  # mailer_method - Method to execute
148
+ #
142
149
  # options - The Hash options used to refine the selection (default: {}):
143
- # :email - The email to send the test to.
150
+ # :email - The email to send the test to.
144
151
  #
145
152
  # Examples
146
153
  #
147
- # InvitationMailer.test(:invite, email: 'benny@envylabs.com')
154
+ # InvitationMailer.test(:invite, email: 'benny@envylabs.com')
148
155
  #
149
156
  # Returns the duplicated String.
150
157
  def self.test(mailer_method, options={})
@@ -214,7 +221,7 @@ module MandrillMailer
214
221
  #
215
222
  # Examples
216
223
  #
217
- # mandrill_mail template: 'Group Invite',
224
+ # mandrill_mail template: 'Group Invite',
218
225
  # subject: I18n.t('invitation_mailer.invite.subject'),
219
226
  # to: invitation.email,
220
227
  # vars: {
@@ -265,7 +272,8 @@ module MandrillMailer
265
272
  "google_analytics_domains" => args[:google_analytics_domains],
266
273
  "google_analytics_campaign" => args[:google_analytics_campaign],
267
274
  "metadata" => args[:metadata],
268
- "attachments" => mandrill_attachment_args(args[:attachments])
275
+ "attachments" => mandrill_attachment_args(args[:attachments]),
276
+ "images" => mandrill_images_args(args[:images])
269
277
  }
270
278
 
271
279
  unless MandrillMailer.config.interceptor_params.nil?
@@ -317,6 +325,17 @@ module MandrillMailer
317
325
  end
318
326
  end
319
327
 
328
+ def mandrill_images_args(args)
329
+ return unless args
330
+ args.map do |attachment|
331
+ attachment.symbolize_keys!
332
+ type = attachment[:mimetype]
333
+ name = attachment[:filename]
334
+ file = attachment[:file]
335
+ {"type" => type, "name" => name, "content" => Base64.encode64(file)}
336
+ end
337
+ end
338
+
320
339
  # Makes this class act as a singleton without it actually being a singleton
321
340
  # This keeps the syntax the same as the orginal mailers so we can swap quickly if something
322
341
  # goes wrong.
@@ -1,3 +1,3 @@
1
1
  module MandrillMailer
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
@@ -20,6 +20,11 @@ describe MandrillMailer::TemplateMailer do
20
20
  let(:attachment_file) { File.read(File.expand_path('spec/support/test_image.png')) }
21
21
  let(:attachment_filename) { 'test_image.png' }
22
22
  let(:attachment_mimetype) { 'image/png' }
23
+
24
+ let(:image_file) { File.read(File.expand_path('spec/support/test_image.png')) }
25
+ let(:image_filename) { 'test_image.png' }
26
+ let(:image_mimetype) { 'image/png' }
27
+
23
28
  let(:send_at) { Time.utc(2020, 1, 1, 8, 0) }
24
29
  let(:bcc) { "bcc@email.com" }
25
30
 
@@ -44,6 +49,7 @@ describe MandrillMailer::TemplateMailer do
44
49
  google_analytics_domains: ["http://site.com"],
45
50
  google_analytics_campaign: '1237423474',
46
51
  attachments: [{file: attachment_file, filename: attachment_filename, mimetype: attachment_mimetype}],
52
+ images: [{file: image_file, filename: image_filename, mimetype: image_mimetype}],
47
53
  inline_css: true,
48
54
  important: true,
49
55
  send_at: send_at,
@@ -216,7 +222,8 @@ describe MandrillMailer::TemplateMailer do
216
222
  "subaccount" => args[:subaccount],
217
223
  "google_analytics_domains" => args[:google_analytics_domains],
218
224
  "google_analytics_campaign" => args[:google_analytics_campaign],
219
- "attachments" => [{'type' => attachment_mimetype, 'name' => attachment_filename, 'content' => Base64.encode64(attachment_file)}]
225
+ "attachments" => [{'type' => attachment_mimetype, 'name' => attachment_filename, 'content' => Base64.encode64(attachment_file)}],
226
+ "images" => [{'type' => image_mimetype, 'name' => image_filename, 'content' => Base64.encode64(image_file)}]
220
227
  })
221
228
  end
222
229
  end
@@ -262,7 +269,8 @@ describe MandrillMailer::TemplateMailer do
262
269
  "subaccount" => args[:subaccount],
263
270
  "google_analytics_domains" => args[:google_analytics_domains],
264
271
  "google_analytics_campaign" => args[:google_analytics_campaign],
265
- "attachments" => [{'type' => attachment_mimetype, 'name' => attachment_filename, 'content' => Base64.encode64(attachment_file)}]
272
+ "attachments" => [{'type' => attachment_mimetype, 'name' => attachment_filename, 'content' => Base64.encode64(attachment_file)}],
273
+ "images" => [{'type' => image_mimetype, 'name' => image_filename, 'content' => Base64.encode64(image_file)}]
266
274
  })
267
275
  end
268
276
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandrill_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Rensel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-28 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport