[Groonga-commit] ranguba/groonga-client at a1a179c [master] schema response: support method access to command information

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Oct 25 15:38:12 JST 2017


Kouhei Sutou	2017-10-25 15:38:12 +0900 (Wed, 25 Oct 2017)

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

  Message:
    schema response: support method access to command information

  Modified files:
    lib/groonga/client/response/schema.rb
    test/response/test-schema.rb

  Modified: lib/groonga/client/response/schema.rb (+9 -0)
===================================================================
--- lib/groonga/client/response/schema.rb    2017-10-25 15:26:37 +0900 (e68463c)
+++ lib/groonga/client/response/schema.rb    2017-10-25 15:38:12 +0900 (81eca7d)
@@ -147,6 +147,11 @@ module Groonga
           include Hashie::Extensions::MethodAccess
         end
 
+        class Command < ::Hash
+          include Hashie::Extensions::MergeInitializer
+          include Hashie::Extensions::MethodAccess
+        end
+
         class Index < ::Hash
           include Hashie::Extensions::MethodAccess
 
@@ -204,6 +209,8 @@ module Groonga
             when :value_type
               value = ValueType.new(value) unless value.nil?
               super(key, value)
+            when :command
+              super(key, Command.new(value))
             else
               super
             end
@@ -243,6 +250,8 @@ module Groonga
               super(key, coerce_columns(value))
             when :indexes
               super(key, coerce_indexes(value))
+            when :command
+              super(key, Command.new(value))
             else
               super
             end

  Modified: test/response/test-schema.rb (+54 -0)
===================================================================
--- test/response/test-schema.rb    2017-10-25 15:26:37 +0900 (f294fb0)
+++ test/response/test-schema.rb    2017-10-25 15:38:12 +0900 (df87ea2)
@@ -263,6 +263,30 @@ class TestResponseSchema < Test::Unit::TestCase
           end
         end
       end
+
+      def test_command
+        body = {
+          "tables" => {
+            "Users" => {
+              "command" => {
+                "name" => "table_create",
+                "arguments" => {
+                  "name" => "Users",
+                  "flags" => "TABLE_HASH_KEY",
+                  "key_type" => "ShortText",
+                },
+              }
+            }
+          }
+        }
+        response = create_response(body)
+        assert_equal({
+                       "name" => "Users",
+                       "flags" => "TABLE_HASH_KEY",
+                       "key_type" => "ShortText",
+                     },
+                     response.tables["Users"].command.arguments)
+      end
     end
 
     class TestColumn < self
@@ -410,6 +434,36 @@ class TestResponseSchema < Test::Unit::TestCase
           end
         end
       end
+
+      def test_command
+        body = {
+          "tables" => {
+            "Users" => {
+              "columns" => {
+                "name" => {
+                  "command" => {
+                    "name" => "column_create",
+                    "arguments" => {
+                      "table" => "Users",
+                      "name" => "name",
+                      "flags" => "COLUMN_SCALAR",
+                      "type" => "ShortText",
+                    },
+                  }
+                }
+              }
+            }
+          }
+        }
+        response = create_response(body)
+        assert_equal({
+                       "table" => "Users",
+                       "name" => "name",
+                       "flags" => "COLUMN_SCALAR",
+                       "type" => "ShortText",
+                     },
+                     response.tables["Users"].columns["name"].command.arguments)
+      end
     end
 
     class TestIndex < self
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171025/5cf37acb/attachment-0001.htm 



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