Kouhei Sutou
null+****@clear*****
Wed Jan 13 17:23:40 JST 2016
Kouhei Sutou 2015-08-13 10:20:39 +0900 (Thu, 13 Aug 2015) New Revision: 742558e0832cb2000cf9dceeed9aae9358ac972f https://github.com/groonga/groonga-command/commit/742558e0832cb2000cf9dceeed9aae9358ac972f Message: Support column_copy Added files: lib/groonga/command/column-copy.rb test/command/test-column-copy.rb Modified files: lib/groonga/command.rb Modified: lib/groonga/command.rb (+1 -0) =================================================================== --- lib/groonga/command.rb 2015-08-09 00:08:29 +0900 (4c64e8d) +++ lib/groonga/command.rb 2015-08-13 10:20:39 +0900 (7a53e15) @@ -20,6 +20,7 @@ require "groonga/command/version" require "groonga/command/error" +require "groonga/command/column-copy" require "groonga/command/column-create" require "groonga/command/column-list" require "groonga/command/column-remove" Added: lib/groonga/command/column-copy.rb (+67 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/command/column-copy.rb 2015-08-13 10:20:39 +0900 (3e224ea) @@ -0,0 +1,67 @@ +# Copyright (C) 2015 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 +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "groonga/command/base" + +module Groonga + module Command + # A command class that represents `column_copy` command. + # + # @since 1.1.3 + class ColumnCopy < Base + Command.register("column_copy", self) + + class << self + def parameter_names + [ + :from_table, + :from_name, + :to_table, + :to_name, + ] + end + end + + # @return [String] `from_table` parameter value. + # + # @since 1.1.3 + def from_table + self[:from_table] + end + + # @return [String] `from_name` parameter value. + # + # @since 1.1.3 + def from_name + self[:from_name] + end + + # @return [String] `to_table` parameter value. + # + # @since 1.1.3 + def to_table + self[:to_table] + end + + # @return [String] `to_name` parameter value. + # + # @since 1.1.3 + def to_name + self[:to_name] + end + end + end +end Added: test/command/test-column-copy.rb (+76 -0) 100644 =================================================================== --- /dev/null +++ test/command/test-column-copy.rb 2015-08-13 10:20:39 +0900 (bbe96a1) @@ -0,0 +1,76 @@ +# Copyright (C) 2015 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 +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class ColumnCopyCommandTest < Test::Unit::TestCase + private + def column_copy_command(pair_arguments={}, ordered_arguments=[]) + Groonga::Command::ColumnCopy.new("column_copy", + pair_arguments, + ordered_arguments) + end + + class ConstructorTest < self + def test_ordered_arguments + from_table = "Users" + from_name = "age_text" + to_table = "TypesUsers" + to_name = "age_uint8" + + command = column_copy_command({}, + [ + from_table, + from_name, + to_table, + to_name, + ]) + assert_equal({ + :from_table => from_table, + :from_name => from_name, + :to_table => to_table, + :to_name => to_name, + }, + command.arguments) + end + end + + class FromTableTest < self + def test_reader + command = column_copy_command(:from_table => "Users") + assert_equal("Users", command.from_table) + end + end + + class FromNameTest < self + def test_reader + command = column_copy_command(:from_name => "age_text") + assert_equal("age_text", command.from_name) + end + end + + class ToTableTest < self + def test_reader + command = column_copy_command(:to_table => "TypedUsers") + assert_equal("TypedUsers", command.to_table) + end + end + + class ToNameTest < self + def test_reader + command = column_copy_command(:to_name => "age_uint8") + assert_equal("age_uint8", command.to_name) + end + end +end -------------- next part -------------- HTML����������������������������...Download