bodyparts 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bodyparts.gemspec +1 -1
- data/lib/bodyparts.rb +6 -5
- data/spec/bodyparts_spec.rb +10 -6
- data/spec/emails.yml +11 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/bodyparts.gemspec
CHANGED
data/lib/bodyparts.rb
CHANGED
@@ -11,7 +11,7 @@ class BodyParts
|
|
11
11
|
|
12
12
|
def self.extract_tmail_attributes(tmail_object)
|
13
13
|
if mail_encoding = tmail_object['content_transfer_encoding']
|
14
|
-
content_encoding = mail_encoding.to_s
|
14
|
+
content_encoding = mail_encoding.to_s.downcase
|
15
15
|
else
|
16
16
|
content_encoding = "not known"
|
17
17
|
end
|
@@ -50,10 +50,11 @@ class BodyParts
|
|
50
50
|
else raise "You must pass in either a TMail or Mail object or raw email source text"
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
raw_body = mail_attributes[:body]
|
54
|
+
body = case mail_attributes[:content_encoding]
|
55
|
+
when "base64" then Base64.decode64 raw_body
|
56
|
+
when "quoted-printable" then Mail::Encodings::QuotedPrintable.decode raw_body
|
57
|
+
else raw_body
|
57
58
|
end
|
58
59
|
|
59
60
|
matches = rules.map {|rule| body.match(rule[:reply_delimiter])}.compact!
|
data/spec/bodyparts_spec.rb
CHANGED
@@ -41,11 +41,15 @@ describe "BodyParts" do
|
|
41
41
|
BodyParts.find_reply_in(message)[:new_message].should == with_attachment[:reply_text]
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
describe "encodings" do
|
45
|
+
[TMail::Mail, Mail].each do |mail_type|
|
46
|
+
["base64", "Quoted-printable"].each do |encoding|
|
47
|
+
it "should correctly parse #{encoding} encoded #{mail_type} messages" do
|
48
|
+
encoded_message = FakeMessage.fake_emails[encoding.to_sym]
|
49
|
+
message = FakeMessage.new_mail(mail_type, encoded_message[:headers])
|
50
|
+
BodyParts.find_reply_in(message)[:new_message].strip.should == encoded_message[:reply_text]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
50
54
|
end
|
51
55
|
end
|
data/spec/emails.yml
CHANGED
@@ -140,11 +140,20 @@
|
|
140
140
|
"email_with_attachment"
|
141
141
|
:reply_text:
|
142
142
|
HELLO
|
143
|
-
:
|
143
|
+
:base64:
|
144
144
|
:reply_text:
|
145
145
|
INSTAIN REPLY. DO WAY
|
146
146
|
:headers:
|
147
147
|
content_transfer_encoding:
|
148
148
|
base64
|
149
149
|
body:
|
150
|
-
SU5TVEFJTiBSRVBMWS4gRE8gV0FZ\n
|
150
|
+
SU5TVEFJTiBSRVBMWS4gRE8gV0FZ\n
|
151
|
+
:"Quoted-printable":
|
152
|
+
:reply_text:
|
153
|
+
To make your upload take a significantly less amount of time, you can use Windows Movie Maker to shrink your video before uploading it.
|
154
|
+
:headers:
|
155
|
+
content_transfer_encoding:
|
156
|
+
Quoted-printable
|
157
|
+
body: |
|
158
|
+
To make your upload take a significantly less amount of time, you can use W=
|
159
|
+
indows Movie Maker to shrink your video before uploading it.=20
|