Kouhei Sutou
null+****@clear*****
Wed Jan 13 16:41:43 JST 2016
Kouhei Sutou 2016-01-13 16:41:43 +0900 (Wed, 13 Jan 2016) New Revision: 7f3b836c26b0366e5b82c34681b8fc52a34a7fb9 https://github.com/groonga/groonga-command/commit/7f3b836c26b0366e5b82c34681b8fc52a34a7fb9 Message: Support conf-get, conf-set and conf-delete Added files: lib/groonga/command/conf-delete.rb lib/groonga/command/conf-get.rb lib/groonga/command/conf-set.rb test/command/test-conf-delete.rb test/command/test-conf-get.rb test/command/test-conf-set.rb Modified files: lib/groonga/command.rb Modified: lib/groonga/command.rb (+4 -1) =================================================================== --- lib/groonga/command.rb 2015-11-24 16:42:47 +0900 (b890973) +++ lib/groonga/command.rb 2016-01-13 16:41:43 +0900 (d6b6b74) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2012-2015 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2012-2016 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 @@ -25,6 +25,9 @@ require "groonga/command/column-create" require "groonga/command/column-list" require "groonga/command/column-remove" require "groonga/command/column-rename" +require "groonga/command/conf-delete" +require "groonga/command/conf-get" +require "groonga/command/conf-set" require "groonga/command/delete" require "groonga/command/dump" require "groonga/command/get" Added: lib/groonga/command/conf-delete.rb (+43 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/command/conf-delete.rb 2016-01-13 16:41:43 +0900 (ad54c82) @@ -0,0 +1,43 @@ +# Copyright (C) 2016 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 `conf_delete` command. + # + # @since 1.1.4 + class ConfDelete < Base + Command.register("conf_delete", self) + + class << self + def parameter_names + [ + :key, + ] + end + end + + # @return [String] `key` parameter value. + # + # @since 1.1.4 + def key + self[:key] + end + end + end +end Added: lib/groonga/command/conf-get.rb (+43 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/command/conf-get.rb 2016-01-13 16:41:43 +0900 (d12b900) @@ -0,0 +1,43 @@ +# Copyright (C) 2016 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 `conf_get` command. + # + # @since 1.1.4 + class ConfGet < Base + Command.register("conf_get", self) + + class << self + def parameter_names + [ + :key, + ] + end + end + + # @return [String] `key` parameter value. + # + # @since 1.1.4 + def key + self[:key] + end + end + end +end Added: lib/groonga/command/conf-set.rb (+51 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/command/conf-set.rb 2016-01-13 16:41:43 +0900 (2341660) @@ -0,0 +1,51 @@ +# Copyright (C) 2016 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 `conf_set` command. + # + # @since 1.1.4 + class ConfSet < Base + Command.register("conf_set", self) + + class << self + def parameter_names + [ + :key, + :value, + ] + end + end + + # @return [String] `key` parameter value. + # + # @since 1.1.4 + def key + self[:key] + end + + # @return [String] `value` parameter value. + # + # @since 1.1.4 + def value + self[:value] + end + end + end +end Added: test/command/test-conf-delete.rb (+46 -0) 100644 =================================================================== --- /dev/null +++ test/command/test-conf-delete.rb 2016-01-13 16:41:43 +0900 (8219706) @@ -0,0 +1,46 @@ +# Copyright (C) 2016 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 ConfDeleteCommandTest < Test::Unit::TestCase + private + def conf_delete_command(pair_arguments={}, ordered_arguments=[]) + Groonga::Command::ConfDelete.new("conf_delete", + pair_arguments, + ordered_arguments) + end + + class ConstructorTest < self + def test_ordered_arguments + key = "alias.table" + + command = conf_delete_command({}, + [ + key, + ]) + assert_equal({ + :key => key, + }, + command.arguments) + end + end + + class KeyTest < self + def test_reader + command = conf_delete_command(:key => "alias.table") + assert_equal("alias.table", command.key) + end + end +end Added: test/command/test-conf-get.rb (+46 -0) 100644 =================================================================== --- /dev/null +++ test/command/test-conf-get.rb 2016-01-13 16:41:43 +0900 (4cc83c3) @@ -0,0 +1,46 @@ +# Copyright (C) 2016 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 ConfGetCommandTest < Test::Unit::TestCase + private + def conf_get_command(pair_arguments={}, ordered_arguments=[]) + Groonga::Command::ConfGet.new("conf_get", + pair_arguments, + ordered_arguments) + end + + class ConstructorTest < self + def test_ordered_arguments + key = "alias.table" + + command = conf_get_command({}, + [ + key, + ]) + assert_equal({ + :key => key, + }, + command.arguments) + end + end + + class KeyTest < self + def test_reader + command = conf_get_command(:key => "alias.table") + assert_equal("alias.table", command.key) + end + end +end Added: test/command/test-conf-set.rb (+57 -0) 100644 =================================================================== --- /dev/null +++ test/command/test-conf-set.rb 2016-01-13 16:41:43 +0900 (affc9c8) @@ -0,0 +1,57 @@ +# Copyright (C) 2016 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 ConfSetCommandTest < Test::Unit::TestCase + private + def conf_set_command(pair_arguments={}, ordered_arguments=[]) + Groonga::Command::ConfSet.new("conf_set", + pair_arguments, + ordered_arguments) + end + + class ConstructorTest < self + def test_ordered_arguments + key = "alias.table" + value = "Aliases" + + command = conf_set_command({}, + [ + key, + value, + ]) + assert_equal({ + :key => key, + :value => value, + }, + command.arguments) + end + end + + class KeyTest < self + def test_reader + command = conf_set_command(:key => "alias.table") + assert_equal("alias.table", command.key) + end + end + + class ValueTest < self + def test_reader + command = conf_set_command(:key => "alias.table", + :value => "Aliases") + assert_equal("Aliases", command.value) + end + end +end -------------- next part -------------- HTML����������������������������...Download