commit eda1db3a81cec8839dd8c31b92439f9dcf6b5550
parent 9eead59a75c43973e679909ad56d9c1f8e3c54c9
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Mon, 16 Apr 2007 22:58:59 +0000
better rubymail usage
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@380 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
@@ -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