Kenji Okimoto
null+****@clear*****
Wed Dec 13 11:25:37 JST 2017
Kenji Okimoto 2017-05-08 13:11:40 +0900 (Mon, 08 May 2017) New Revision: a4d86edc6a1f031df9144dde9f159a5c7ea57118 https://github.com/ranguba/chupa-text/commit/a4d86edc6a1f031df9144dde9f159a5c7ea57118 Merged 6944bff: Merge pull request #4 from okkez/add-mime-text-formatter Message: Use Multipart MIME See: * https://tools.ietf.org/html/rfc2045 * https://tools.ietf.org/html/rfc2046 Modified files: lib/chupa-text/formatters/mime.rb Modified: lib/chupa-text/formatters/mime.rb (+14 -2) =================================================================== --- lib/chupa-text/formatters/mime.rb 2017-04-28 17:27:49 +0900 (ef3940c) +++ lib/chupa-text/formatters/mime.rb 2017-05-08 13:11:40 +0900 (0c1a99f) @@ -1,3 +1,5 @@ +require "digest/sha1" + module ChupaText module Formatters class MIME @@ -7,6 +9,8 @@ module ChupaText end def format_start(data) + @output << "Original-URI: #{data.uri}\n" + @output << "Content-Size: #{data.size}\n" end def format_extracted(data) @@ -17,8 +21,16 @@ module ChupaText end def format_finish(data) - @output << @texts.join("\n\x0c\n") - @output << "\n" + if****@texts***** > 1 + boundary = Digest::SHA1.hexdigest(data.uri.to_s) + @output << "Content-Type: multipart/mixed; boundary=#{boundary}\n\n" + @output << "--#{boundary}\n" + @output << @texts.join("\n\n--#{boundary}\n") + @output << "\n--#{boundary}--\n" + else + @output << @texts.first + @output << "\n" + end end private -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171213/13a9f973/attachment.htm