[Groonga-commit] droonga/fluent-plugin-droonga at e2256dc [master] Add Table#type_symbol

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Apr 11 16:45:22 JST 2014


Kouhei Sutou	2014-04-11 16:45:22 +0900 (Fri, 11 Apr 2014)

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

  Message:
    Add Table#type_symbol

  Modified files:
    lib/droonga/catalog/schema.rb
    test/unit/catalog/test_schema.rb

  Modified: lib/droonga/catalog/schema.rb (+13 -0)
===================================================================
--- lib/droonga/catalog/schema.rb    2014-04-11 16:42:29 +0900 (216c1a8)
+++ lib/droonga/catalog/schema.rb    2014-04-11 16:45:22 +0900 (173f486)
@@ -171,6 +171,19 @@ module Droonga
           @data["type"] || "Hash"
         end
 
+        def type_symbol
+          case type
+          when "Array"
+            :array
+          when "Hash"
+            :hash
+          when "PatriciaTrie"
+            :patricia_trie
+          when "DoubleArrayTrie"
+            :double_array_trie
+          end
+        end
+
         def key_type
           @data["keyType"]
         end

  Modified: test/unit/catalog/test_schema.rb (+25 -0)
===================================================================
--- test/unit/catalog/test_schema.rb    2014-04-11 16:42:29 +0900 (c7476da)
+++ test/unit/catalog/test_schema.rb    2014-04-11 16:45:22 +0900 (f1265f5)
@@ -114,6 +114,31 @@ class CatalogSchemaTest < Test::Unit::TestCase
         end
       end
 
+      class TypeSymbolTest < self
+        def type_symbol(type)
+          data = {
+            "type" => type,
+          }
+          create_table("table_name", data).type_symbol
+        end
+
+        def test_array
+          assert_equal(:array, type_symbol("Array"))
+        end
+
+        def test_hash
+          assert_equal(:hash, type_symbol("Hash"))
+        end
+
+        def test_patricia_trie
+          assert_equal(:patricia_trie, type_symbol("PatriciaTrie"))
+        end
+
+        def test_double_array_trie
+          assert_equal(:double_array_trie, type_symbol("DoubleArrayTrie"))
+        end
+      end
+
       def test_flags
         assert_equal(["TABLE_HASH_KEY"],
                      create_table("table_name",
-------------- next part --------------
HTML����������������������������...
Download 



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