[Groonga-commit] ranguba/groonga-client at 22c2be7 [master] schema: support token filter

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Mar 22 12:17:11 JST 2016


Kouhei Sutou	2016-03-22 12:17:11 +0900 (Tue, 22 Mar 2016)

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

  Message:
    schema: support token filter

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

  Modified: lib/groonga/client/response/schema.rb (+20 -0)
===================================================================
--- lib/groonga/client/response/schema.rb    2016-03-22 11:59:52 +0900 (1b2890c)
+++ lib/groonga/client/response/schema.rb    2016-03-22 12:17:11 +0900 (0f62200)
@@ -55,6 +55,16 @@ module Groonga
           end
         end
 
+        # @return [Hash<String, TokenFilter>] Key is token filter name and
+        #   value is the definition of the token filter.
+        #
+        # @since 0.2.3
+        def token_filters
+          @token_filters ||= HashValueConverter.convert(@body["token_filters"]) do |token_filter|
+            TokenFilter[token_filter]
+          end
+        end
+
         # @return [Hash<String, Table>] Key is table name and value is the
         #   definition of the table.
         #
@@ -104,6 +114,10 @@ module Groonga
           include Hashie::Extensions::MethodAccess
         end
 
+        class TokenFilter < Hash
+          include Hashie::Extensions::MethodAccess
+        end
+
         class KeyType < Hash
           include Hashie::Extensions::MethodAccess
         end
@@ -227,6 +241,12 @@ module Groonga
             end
           end
 
+          def coerce_token_filters(raw_token_filters)
+            raw_token_filters.collect do |raw_token_filter|
+              TokenFilter[raw_token_filter]
+            end
+          end
+
           def coerce_columns(raw_columns)
             HashValueConverter.convert(raw_columns) do |raw_column|
               Column.new(@schema, raw_column)

  Modified: test/response/test-schema.rb (+23 -1)
===================================================================
--- test/response/test-schema.rb    2016-03-22 11:59:52 +0900 (9136f48)
+++ test/response/test-schema.rb    2016-03-22 12:17:11 +0900 (6d42f43)
@@ -40,7 +40,7 @@ class TestResponseSchema < Test::Unit::TestCase
       Groonga::Client::Response::Schema.new(@command, header, body)
     end
 
-    class TestTables < self
+    class TestTable < self
       def test_key_type
         body = {
           "types" => {
@@ -82,6 +82,28 @@ class TestResponseSchema < Test::Unit::TestCase
                      response.tables["Users"].normalizer)
       end
 
+      def test_token_filters
+        body = {
+          "token_filters" => {
+            "TokenFilterStopWord" => {
+              "name" => "TokenFilterStopWord",
+            },
+          },
+          "tables" => {
+            "Names" => {
+              "token_filters" => [
+                {
+                  "name" => "TokenFilterStopWord",
+                },
+              ]
+            }
+          }
+        }
+        response = create_response(body)
+        assert_equal([response.token_filters["TokenFilterStopWord"]],
+                     response.tables["Names"].token_filters)
+      end
+
       def test_columns
         body = {
           "tables" => {
-------------- next part --------------
HTML����������������������������...
下载 



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