Kouhei Sutou 2019-02-26 15:04:24 +0900 (Tue, 26 Feb 2019) Revision: a44d23b395497cb09eabb5b198407dbdea8514c7 https://github.com/ranguba/chupa-text/commit/a44d23b395497cb09eabb5b198407dbdea8514c7 Message: Add --mime-boundary option Modified files: lib/chupa-text/command/chupa-text.rb lib/chupa-text/formatters/mime.rb Modified: lib/chupa-text/command/chupa-text.rb (+7 -1) =================================================================== --- lib/chupa-text/command/chupa-text.rb 2019-02-26 11:35:24 +0900 (80e0d46) +++ lib/chupa-text/command/chupa-text.rb 2019-02-26 15:04:24 +0900 (e68f6c3) @@ -46,6 +46,7 @@ module ChupaText @uri = nil @mime_type = nil @format = :json + @mime_formatter_options = {} @need_screenshot = true @expected_screenshot_size = [200, 200] end @@ -127,6 +128,11 @@ module ChupaText "(default: #{@format})") do |format| @format = format end + parser.on("--mime-boundary=BOUNDARY", + "Use BOUNDARY for MIME boundary.", + "(default: Use SHA1 digest of URI)") do |boundary| + @mime_formatter_options[:boundary] = boundary + end parser.on("--[no-]need-screenshot", "Generate screenshot if available.", "(default: #{@need_screenshot})") do |boolean| @@ -220,7 +226,7 @@ module ChupaText when :text Formatters::Text.new($stdout) when :mime - Formatters::MIME.new($stdout) + Formatters::MIME.new($stdout, @mime_formatter_options) end end end Modified: lib/chupa-text/formatters/mime.rb (+3 -2) =================================================================== --- lib/chupa-text/formatters/mime.rb 2019-02-26 11:35:24 +0900 (6c64e20) +++ lib/chupa-text/formatters/mime.rb 2019-02-26 15:04:24 +0900 (027a5ac) @@ -22,9 +22,10 @@ require "chupa-text/formatters/hash" module ChupaText module Formatters class MIME < Hash - def initialize(output) + def initialize(output, options={}) super() @output = output + @boundary = options[:boundary] end def format_finish(data) @@ -33,7 +34,7 @@ module ChupaText @output << "MIME-Version: 1.0\r\n" format_hash(formatted, ["texts"]) texts = formatted["texts"] - boundary = Digest::SHA1.hexdigest(data.uri.to_s) + boundary = @boundary || Digest::SHA1.hexdigest(data.uri.to_s) @output << "Content-Type: multipart/mixed; boundary=#{boundary}\r\n" texts.each do |text| @output << "\r\n--#{boundary}\r\n" -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190226/72115d51/attachment-0001.html>