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 CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
data/bodyparts.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bodyparts}
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Max Ogden"]
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
- body = mail_attributes[:body]
54
-
55
- if mail_attributes[:content_encoding] == 'base64'
56
- body = Base64.decode64 body
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!
@@ -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
- [TMail::Mail, Mail].each do |mail_type|
45
- it "should correctly parse base64 encoded #{mail_type} messages" do
46
- base64_encoded = FakeMessage.fake_emails[:base64_encoded]
47
- message = FakeMessage.new_mail(mail_type, base64_encoded[:headers])
48
- BodyParts.find_reply_in(message)[:new_message].should == base64_encoded[:reply_text]
49
- end
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
- :base64_encoded:
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Max Ogden