[Groonga-commit] droonga/drndump at b203be0 [master] Don't output result by Dumper itself

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Apr 10 12:24:05 JST 2015


YUKI Hiroshi	2015-04-10 12:24:05 +0900 (Fri, 10 Apr 2015)

  New Revision: b203be07ec1633ef5e19d01767e668c453070887
  https://github.com/droonga/drndump/commit/b203be07ec1633ef5e19d01767e668c453070887

  Message:
    Don't output result by Dumper itself

  Modified files:
    lib/drndump/command.rb
    lib/drndump/dumper.rb

  Modified: lib/drndump/command.rb (+4 -1)
===================================================================
--- lib/drndump/command.rb    2015-04-10 12:20:51 +0900 (0e4cf1c)
+++ lib/drndump/command.rb    2015-04-10 12:24:05 +0900 (ed4ab3f)
@@ -15,6 +15,7 @@
 
 require "socket"
 require "optparse"
+require "json"
 
 require "cool.io"
 
@@ -114,7 +115,9 @@ module Drndump
         :backend => :coolio,
         :loop    => @loop,
       }
-      @dumper.run(:client_options => client_options)
+      @dumper.run(:client_options => client_options) do |message|
+        puts(JSON.pretty_generate(message))
+      end
       @loop.run
       @dumper.error_message
     end

  Modified: lib/drndump/dumper.rb (+6 -6)
===================================================================
--- lib/drndump/dumper.rb    2015-04-10 12:20:51 +0900 (edb8793)
+++ lib/drndump/dumper.rb    2015-04-10 12:24:05 +0900 (17cce25)
@@ -14,7 +14,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 require "socket"
-require "json"
 
 require "droonga/client"
 
@@ -30,13 +29,14 @@ module Drndump
 
       @receiver_host = params[:receiver_host] || Socket.gethostname
       @receiver_port = params[:receiver_port] || 0
+
+      @error_message = nil
     end
 
-    def run(options={})
+    def run(options={}, &block)
       extra_client_options = options[:client_options] || {}
       client = Droonga::Client.new(client_options.merge(extra_client_options))
 
-      @error_message = nil
       n_dumpers = 0
 
       dump_message = {
@@ -58,15 +58,15 @@ module Drndump
             end
           when "dump.table"
             table_create_message = convert_to_table_create_message(message)
-            puts(JSON.pretty_generate(table_create_message))
+            yield(table_create_message)
           when "dump.column"
             column_create_message = convert_to_column_create_message(message)
-            puts(JSON.pretty_generate(column_create_message))
+            yield(column_create_message)
           when "dump.record"
             add_message = message.dup
             add_message.delete("inReplyTo")
             add_message["type"] = "add"
-            puts(JSON.pretty_generate(add_message))
+            yield(add_message)
           when "dump.start"
             n_dumpers += 1
           when "dump.end"
-------------- next part --------------
HTML����������������������������...
다운로드 



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