YUKI Hiroshi
null+****@clear*****
Thu Jul 10 11:58:53 JST 2014
YUKI Hiroshi 2014-07-10 11:58:53 +0900 (Thu, 10 Jul 2014) New Revision: 2c007c4b75a52d7f535fcc2e1ac85ef765edf37f https://github.com/droonga/grn2drn/commit/2c007c4b75a52d7f535fcc2e1ac85ef765edf37f Message: Accept "--encoding" option Modified files: bin/grn2drn lib/grn2drn/command-converter.rb Modified: bin/grn2drn (+8 -3) =================================================================== --- bin/grn2drn 2014-07-10 11:48:51 +0900 (bb91c45) +++ bin/grn2drn 2014-07-10 11:58:53 +0900 (2624e23) @@ -25,6 +25,7 @@ require "grn2drn/command-converter" options = OpenStruct.new options.output_path = "-" options.dataset = "Default" +options.encoding = "UTF-8" option_parser = OptionParser.new do |parser| parser.version = Grn2Drn::VERSION @@ -34,15 +35,18 @@ option_parser = OptionParser.new do |parser| parser.separator("Converts Groonga commands to Droonga messages") parser.separator("") - parser.separator("Required parameters:") parser.on("--dataset=DATASET", "Use DATASET as \"dataset\" field value", "(#{options.dataset})") do |dataset| options.dataset = dataset end - parser.separator("") - parser.separator("Optional parameters:") + parser.on("-e, --encoding=ENCODING", + "Read input dump as strings encoded in ENCODING" + "(#{options.encoding})") do |encoding| + options.encoding = encoding + end + parser.on("--id-prefix=PREFIX", "Use PREFIX as prefix of IDs") do |prefix| options.id_prefix = prefix @@ -78,6 +82,7 @@ convert_options = { :date => options.date, :reply_to => options.reply_to, :dataset => options.dataset, + :encoding => options.encoding, } converter = Grn2Drn::CommandConverter.new(convert_options) Modified: lib/grn2drn/command-converter.rb (+2 -1) =================================================================== --- lib/grn2drn/command-converter.rb 2014-07-10 11:48:51 +0900 (b926b92) +++ lib/grn2drn/command-converter.rb 2014-07-10 11:58:53 +0900 (7aae535) @@ -53,8 +53,9 @@ module Grn2Drn command.original_source.clear end + encoding = @options[:encoding] || "UTF-8" input.each_line do |line| - @command_parser << line.force_encoding("UTF-8") + @command_parser << line.force_encoding(encoding) end @command_parser.finish end -------------- next part -------------- HTML����������������������������... 下載