mail-mad_mimi 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -3
- data/lib/mail/mad_mimi.rb +25 -8
- data/lib/mail/mad_mimi/version.rb +1 -1
- data/spec/mail/mad_mimi_spec.rb +32 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -47,11 +47,10 @@ If you are sending to an individual email address, the body must
|
|
47
47
|
include `[[tracking_beacon]]` or `[[peek_image]]`.
|
48
48
|
|
49
49
|
If you are sending to a list or everyone, the body must include
|
50
|
-
`[[opt_out]]` or `unsubscribe`.
|
50
|
+
`[[opt_out]]` or `[[unsubscribe]]`.
|
51
51
|
|
52
52
|
An exception will be raised if you don't include a macro. When debugging,
|
53
|
-
you may want to
|
54
|
-
on your `Mail` object.
|
53
|
+
you may want to set `raise_delivery_errors = true` on your `Mail` object.
|
55
54
|
|
56
55
|
## Rails 3 support
|
57
56
|
|
data/lib/mail/mad_mimi.rb
CHANGED
@@ -22,19 +22,36 @@ module Mail #:nodoc:
|
|
22
22
|
|
23
23
|
def options_from_mail(mail)
|
24
24
|
settings.merge(
|
25
|
-
:recipients
|
26
|
-
:from
|
27
|
-
:bcc
|
28
|
-
:subject
|
25
|
+
:recipients => mail[:to].to_s,
|
26
|
+
:from => mail[:from].to_s,
|
27
|
+
:bcc => mail[:bcc].to_s,
|
28
|
+
:subject => mail.subject,
|
29
|
+
:raw_html => html(mail),
|
30
|
+
:raw_plain_text => text(mail)
|
29
31
|
).tap do |options|
|
30
|
-
options[:raw_html] = mail.html_part.body.to_s if mail.html_part
|
31
|
-
options[:raw_plain_text] = mail.text_part.body.to_s if mail.text_part
|
32
|
-
|
33
32
|
if mail.respond_to? :mailer_action
|
34
|
-
options[:promotion_name] = mail.mailer_action
|
33
|
+
options[:promotion_name] = mail.mailer_action
|
35
34
|
end
|
36
35
|
|
37
36
|
options.merge!(mail[:mad_mimi].value) if mail[:mad_mimi]
|
37
|
+
|
38
|
+
options.reject! {|k,v| v.nil? }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def html(mail)
|
43
|
+
body(mail, "text/html")
|
44
|
+
end
|
45
|
+
|
46
|
+
def text(mail)
|
47
|
+
body(mail, "text/plain") || mail.body.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
def body(mail, mime_type)
|
51
|
+
if part = mail.find_first_mime_type(mime_type)
|
52
|
+
part.body.to_s
|
53
|
+
elsif mail.mime_type == mime_type
|
54
|
+
mail.body.to_s
|
38
55
|
end
|
39
56
|
end
|
40
57
|
|
data/spec/mail/mad_mimi_spec.rb
CHANGED
@@ -70,6 +70,27 @@ describe Mail::MadMimi do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
context "with a non-multipart text body" do
|
74
|
+
before(:each) do
|
75
|
+
mail.body = "text body"
|
76
|
+
mail.content_type = "text/plain"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should set :raw_plain_text" do
|
80
|
+
options[:raw_plain_text].should == "text body"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "with a text body no content type given" do
|
85
|
+
before(:each) do
|
86
|
+
mail.body = "text body"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should set :raw_plain_text" do
|
90
|
+
options[:raw_plain_text].should == "text body"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
73
94
|
context "with an HTML part" do
|
74
95
|
before(:each) do
|
75
96
|
mail.html_part do
|
@@ -83,6 +104,17 @@ describe Mail::MadMimi do
|
|
83
104
|
end
|
84
105
|
end
|
85
106
|
|
107
|
+
context "with a non-multipart HTML body" do
|
108
|
+
before(:each) do
|
109
|
+
mail.body = "html body"
|
110
|
+
mail.content_type = "text/html"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should set :raw_html" do
|
114
|
+
options[:raw_html].should == "html body"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
86
118
|
context "with a mailer_action method" do
|
87
119
|
before(:each) do
|
88
120
|
mail.stub :mailer_action => "Mailer.method"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-mad_mimi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Grant Hollingworth
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-07 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: madmimi
|