]> git.cworth.org Git - sup/commitdiff
wrap text attachments
authorIsrael Herraiz <israel.herraiz@gmail.com>
Tue, 4 Nov 2008 14:07:21 +0000 (15:07 +0100)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 7 Nov 2008 16:55:19 +0000 (08:55 -0800)
lib/sup/message-chunks.rb

index cc895f3e480e591d077a18a83a84b85ca7d0cf5a..b3726923a85e31fdc7993c7efa5287035751a8d4 100644 (file)
@@ -41,6 +41,8 @@ end
 
 module Redwood
 module Chunk
+  WRAP_LEN = 80 # wrap messages and text attachments at this width
+
   class Attachment
     HookManager.register "mime-decode", <<EOS
 Executes when decoding a MIME attachment.
@@ -95,6 +97,7 @@ EOS
       @lines = nil
       if text
         @lines = text.gsub("\r\n", "\n").gsub(/\t/, "        ").gsub(/\r/, "").split("\n")
+        @lines = lines.map {|l| l.chomp.wrap WRAP_LEN}.flatten
         @quotable = true
       end
     end
@@ -143,7 +146,6 @@ EOS
   end
 
   class Text
-    WRAP_LEN = 80 # wrap at this width
 
     attr_reader :lines
     def initialize lines