[Groonga-commit] droonga/fluent-plugin-droonga at 3013446 [master] Add a command to convert .grn file to .jsons file

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Sep 18 16:56:30 JST 2013


YUKI Hiroshi	2013-09-18 16:56:30 +0900 (Wed, 18 Sep 2013)

  New Revision: 301344642988785a669bf9dddffc95e5de22e28f
  https://github.com/droonga/fluent-plugin-droonga/commit/301344642988785a669bf9dddffc95e5de22e28f

  Message:
    Add a command to convert .grn file to .jsons file

  Modified files:
    bin/grn2jsons

  Modified: bin/grn2jsons (+26 -2)
===================================================================
--- bin/grn2jsons    2013-09-18 16:18:56 +0900 (ebdd7cc)
+++ bin/grn2jsons    2013-09-18 16:56:30 +0900 (b9f6892)
@@ -1,5 +1,20 @@
 #!/usr/bin/env ruby
 # -*- coding: utf-8 -*-
+#
+# Copyright (C) 2013 droonga project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 require "groonga_command_converter"
 require "json"
@@ -30,12 +45,20 @@ option_parser = OptionParser.new do |parser|
 end
 args = option_parser.parse!(ARGV)
 
+if options.reply_to.nil?
+  raise "You must specify the value of the \"replyTo\" field by --reply-to option."
+end
+if options.dataset.nil?
+  raise "You must specify the name of the dataset by --dataset option."
+end
+
 convert_options = {
   :id => options.id,
   :date => options.date,
   :reply_to => options.reply_to,
   :dataset => options.dataset,
 }
+converter = Droonga::GroongaCommandConverter.new(convert_options)
 
 source_file = args[0]
 result_file = args[1]
@@ -48,13 +71,14 @@ else
 end
 
 result_file = args[1]
+
 if result_file.nil?
-  converter.convert(input, convert_options) do |command|
+  converter.convert(input) do |command|
     puts(JSON.generate(command))
   end
 else
   File.open("w", result_file) do |file|
-    converter.convert(input, convert_options) do |command|
+    converter.convert(input) do |command|
       file.puts(JSON.generate(command))
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index