]> git.cworth.org Git - sup/commitdiff
better rubymail usage
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 16 Apr 2007 22:58:59 +0000 (22:58 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 16 Apr 2007 22:58:59 +0000 (22:58 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@380 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/message.rb

index 4b94482c6ee5791032c1b047c15805d18374202d..da3d0af8d1e48809a16cc335ff010ba56e3e07f5 100644 (file)
@@ -263,22 +263,22 @@ EOS
 
 private
 
-  ## everything RubyMail-specific goes here.
+  ## (almost) everything rmail-specific goes here
   def message_to_chunks m
-    ret = [] <<
+    if m.multipart?
+      m.body.map { |p| message_to_chunks p }.flatten.compact
+    else
       case m.header.content_type
       when "text/plain", nil
         m.body && body = m.decode or raise MessageFormatError, "For some bizarre reason, RubyMail was unable to parse this message."
-        text_to_chunks body.normalize_whitespace.split("\n")
+        text_to_chunks(body.normalize_whitespace.split("\n"))
       when /^multipart\//
-        nil
+        []
       else
         disp = m.header["Content-Disposition"] || ""
-        Attachment.new m.header.content_type, disp.gsub(/[\s\n]+/, " "), m
+        [Attachment.new(m.header.content_type, disp.gsub(/[\s\n]+/, " "), m)]
       end
-    
-    m.each_part { |p| ret << message_to_chunks(p) } if m.multipart?
-    ret.compact.flatten
+    end
   end
 
   ## parse the lines of text into chunk objects.  the heuristics here