[Groonga-commit] ranguba/groonga-client at dfe3718 [master] Use dynamic command execution

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Mar 21 13:07:11 JST 2016


Kouhei Sutou	2016-03-21 13:07:11 +0900 (Mon, 21 Mar 2016)

  New Revision: dfe3718aceceac506fcc8717605ceb597cb05012
  https://github.com/ranguba/groonga-client/commit/dfe3718aceceac506fcc8717605ceb597cb05012

  Message:
    Use dynamic command execution

  Modified files:
    lib/groonga/client.rb
    lib/groonga/client/protocol/http/coolio.rb
    lib/groonga/client/protocol/http/synchronous.rb
    test/test-command.rb

  Modified: lib/groonga/client.rb (+1 -84)
===================================================================
--- lib/groonga/client.rb    2016-03-21 13:01:17 +0900 (be2a890)
+++ lib/groonga/client.rb    2016-03-21 13:07:11 +0900 (aedb2aa)
@@ -129,46 +129,6 @@ module Groonga
       end
     end
 
-    def cache_limit(parameters, &block)
-      execute("cache_limit", parameters, &block)
-    end
-
-    def check(parameters, &block)
-      execute("check", parameters, &block)
-    end
-
-    def clearlock(parameters={}, &block)
-      execute("clearlock", parameters, &block)
-    end
-
-    def column_create(parameters, &block)
-      execute("column_create", parameters, &block)
-    end
-
-    def column_list(parameters, &block)
-      execute("column_list", parameters, &block)
-    end
-
-    def column_remove(parameters, &block)
-      execute("column_remove", parameters, &block)
-    end
-
-    def column_rename(parameters, &block)
-      execute("column_rename", parameters, &block)
-    end
-
-    def defrag(parameters={}, &block)
-      execute("defrag", parameters, &block)
-    end
-
-    def delete(parameters, &block)
-      execute("delete", parameters, &block)
-    end
-
-    def dump(parameters={}, &block)
-      execute("dump", parameters, &block)
-    end
-
     def load(parameters, &block)
       values = parameters[:values]
       if values.is_a?(Array)
@@ -184,50 +144,7 @@ module Groonga
         json << "\n]"
         parameters[:values] = json
       end
-      execute("load", parameters, &block)
-    end
-
-    def log_level(parameters, &block)
-      execute("log_level", parameters, &block)
-    end
-
-    def log_put(parameters, &block)
-      execute("log_put", parameters, &block)
-    end
-
-    def log_reopen(parameters={}, &block)
-      execute("log_reopen", parameters, &block)
-    end
-
-    def quit(parameters={}, &block)
-      execute("quit", parameters, &block)
-    end
-
-    def register(parameters, &block)
-      execute("register", parameters, &block)
-    end
-
-    def select(parameters, &block)
-      execute("select", parameters, &block)
-    end
-
-    def shutdown(parameters={}, &block)
-    end
-
-    def status(parameters={}, &block)
-      execute("status", parameters, &block)
-    end
-
-    def table_create(parameters, &block)
-      execute("table_create", parameters, &block)
-    end
-
-    def table_list(parameters={}, &block)
-      execute("table_list", parameters, &block)
-    end
-
-    def table_remove(parameters, &block)
-      execute("table_remove", parameters, &block)
+      execute(:load, parameters, &block)
     end
 
     def execute(command_or_name, parameters={}, &block)

  Modified: lib/groonga/client/protocol/http/coolio.rb (+1 -1)
===================================================================
--- lib/groonga/client/protocol/http/coolio.rb    2016-03-21 13:01:17 +0900 (71dda8d)
+++ lib/groonga/client/protocol/http/coolio.rb    2016-03-21 13:07:11 +0900 (21bda0b)
@@ -73,7 +73,7 @@ module Groonga
           def send(command, &block)
             client = GroongaHTTPClient.connect(@host, @port, block)
             client.attach(@loop)
-            if command.name == "load"
+            if command.is_a?(Groonga::Command::Load)
               raw_values = command[:values]
               command[:values] = nil
               path = command.to_uri_format

  Modified: lib/groonga/client/protocol/http/synchronous.rb (+1 -1)
===================================================================
--- lib/groonga/client/protocol/http/synchronous.rb    2016-03-21 13:01:17 +0900 (b04a1bb)
+++ lib/groonga/client/protocol/http/synchronous.rb    2016-03-21 13:07:11 +0900 (4daee69)
@@ -116,7 +116,7 @@ module Groonga
           end
 
           def send_request(http, command)
-            if command.name == "load"
+            if command.is_a?(Groonga::Command::Load)
               raw_values = command[:values]
               command[:values] = nil
               path = command.to_uri_format

  Modified: test/test-command.rb (+7 -7)
===================================================================
--- test/test-command.rb    2016-03-21 13:01:17 +0900 (1e2f0d3)
+++ test/test-command.rb    2016-03-21 13:07:11 +0900 (b9a0675)
@@ -5,7 +5,7 @@ class TestCommand < Test::Unit::TestCase
 
   def test_column_create
     response = Object.new
-    mock(@client).execute("column_create", :table => :Test, :name => :Body, :type => :ShortText) do
+    mock(@client).execute(:column_create, :table => :Test, :name => :Body, :type => :ShortText) do
       response
     end
     @client.column_create(:table => :Test, :name => :Body, :type => :ShortText)
@@ -13,7 +13,7 @@ class TestCommand < Test::Unit::TestCase
 
   def test_column_list
     response = Object.new
-    mock(@client).execute("column_list", :table => :Test) do
+    mock(@client).execute(:column_list, :table => :Test) do
       response
     end
     @client.column_list(:table => :Test)
@@ -27,7 +27,7 @@ class TestCommand < Test::Unit::TestCase
       }
     ]
     response = Object.new
-    mock(@client).execute("load", :table => :Test, :values => values.to_json) do
+    mock(@client).execute(:load, :table => :Test, :values => values.to_json) do
       response
     end
     @client.load(:table => :Test, :values => values.to_json)
@@ -35,7 +35,7 @@ class TestCommand < Test::Unit::TestCase
 
   def test_select
     response = Object.new
-    mock(@client).execute("select", :table => :Test) do
+    mock(@client).execute(:select, :table => :Test) do
       response
     end
     @client.select(:table => :Test)
@@ -43,7 +43,7 @@ class TestCommand < Test::Unit::TestCase
 
   def test_table_create
     response = Object.new
-    mock(@client).execute("table_create", :name => :Test) do
+    mock(@client).execute(:table_create, :name => :Test) do
       response
     end
     @client.table_create(:name => :Test)
@@ -51,14 +51,14 @@ class TestCommand < Test::Unit::TestCase
 
   def test_table_list
     response = Object.new
-    mock(@client).execute("table_list", {}) do
+    mock(@client).execute(:table_list, {}) do
       response
     end
     @client.table_list
   end
 
   def test_table_remove
-    mock(@client).execute("table_remove", :name => "Test")
+    mock(@client).execute(:table_remove, :name => "Test")
     @client.table_remove(:name => "Test")
   end
 end
-------------- next part --------------
HTML����������������������������...
下载 



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