[Groonga-commit] groonga/groonga-command at 3488de2 [fix-travis-ci-error] Add ColumnCreate#sources

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jan 13 17:43:42 JST 2016


Kouhei Sutou	2014-03-14 16:48:17 +0900 (Fri, 14 Mar 2014)

  New Revision: 3488de20541076318a46e9dde40fe1199bda992a
  https://github.com/groonga/groonga-command/commit/3488de20541076318a46e9dde40fe1199bda992a

  Message:
    Add ColumnCreate#sources

  Modified files:
    lib/groonga/command/column-create.rb
    test/command/test-column-create.rb

  Modified: lib/groonga/command/column-create.rb (+8 -1)
===================================================================
--- lib/groonga/command/column-create.rb    2013-10-29 18:15:52 +0900 (3371cba)
+++ lib/groonga/command/column-create.rb    2014-03-14 16:48:17 +0900 (5d6ca3c)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2012  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2014  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -80,6 +80,13 @@ module Groonga
       def with_position?
         flags.include?("WITH_POSITION")
       end
+
+      # @return [::Array<String>] an array of index sources. If {#source} is
+      #   empty or nil, this method returns an empty array.
+      # @since 1.0.7
+      def sources
+        @sources ||= (self[:source] || "").split(/\s*,\s*/)
+      end
     end
   end
 end

  Modified: test/command/test-column-create.rb (+24 -1)
===================================================================
--- test/command/test-column-create.rb    2013-10-29 18:15:52 +0900 (3f25ad7)
+++ test/command/test-column-create.rb    2014-03-14 16:48:17 +0900 (eaddfcf)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2012-213  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2014  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -154,4 +154,27 @@ class ColumnCreateCommandTest < Test::Unit::TestCase
       end
     end
   end
+
+  class SourcesTest < self
+    def test_no_source
+      command = column_create_command
+      assert_equal([], command.sources)
+    end
+
+    def test_empty
+      command = column_create_command("source" => "")
+      assert_equal([], command.sources)
+    end
+
+    def test_one
+      command = column_create_command("source" => "title")
+      assert_equal(["title"], command.sources)
+    end
+
+    def test_multiple
+      command = column_create_command("source" => "title, text, comment")
+      assert_equal(["title", "text", "comment"],
+                   command.sources)
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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