Kouhei Sutou
null+****@clear*****
Wed Jan 13 17:23:19 JST 2016
Kouhei Sutou 2015-06-12 15:51:51 +0900 (Fri, 12 Jun 2015) New Revision: 8df128b40236f5d04a6607fd724055b95afe27eb https://github.com/groonga/groonga-command/commit/8df128b40236f5d04a6607fd724055b95afe27eb Message: Support io_flush Added files: lib/groonga/command/io-flush.rb test/command/test-io-flush.rb Modified files: lib/groonga/command.rb Modified: lib/groonga/command.rb (+1 -0) =================================================================== --- lib/groonga/command.rb 2015-05-17 11:54:28 +0900 (88a547c) +++ lib/groonga/command.rb 2015-06-12 15:51:51 +0900 (767f619) @@ -27,6 +27,7 @@ require "groonga/command/column-rename" require "groonga/command/delete" require "groonga/command/dump" require "groonga/command/get" +require "groonga/command/io-flush" require "groonga/command/load" require "groonga/command/logical-count" require "groonga/command/logical-range-filter" Added: lib/groonga/command/io-flush.rb (+51 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/command/io-flush.rb 2015-06-12 15:51:51 +0900 (abd11a9) @@ -0,0 +1,51 @@ +# 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 `io_flush` command. + # + # @since 1.1.3 + class IOFlush < Base + Command.register("io_flush", self) + + class << self + def parameter_names + [ + :target_name, + :recursive, + ] + end + end + + # @return [String] `target_name` parameter value. + # + # @since 1.1.3 + def target_name + self[:target_name] + end + + # @return [Boolean] `recursive` parameter value. + # + # @since 1.1.3 + def recursive? + self[:recursive] != "no" + end + end + end +end Added: test/command/test-io-flush.rb (+67 -0) 100644 =================================================================== --- /dev/null +++ test/command/test-io-flush.rb 2015-06-12 15:51:51 +0900 (9b9ce7c) @@ -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 + +class IOFlushCommandTest < Test::Unit::TestCase + private + def io_flush_command(pair_arguments={}, ordered_arguments=[]) + Groonga::Command::IOFlush.new("io_flush", + pair_arguments, + ordered_arguments) + end + + class ConstructorTest < self + def test_ordered_arguments + target_name = "Users" + recursive = "no" + + ordered_arguments = [ + target_name, + recursive, + ] + command = io_flush_command({}, ordered_arguments) + assert_equal({ + :target_name => target_name, + :recursive => recursive, + }, + command.arguments) + end + end + + class TargetNameTest < self + def test_reader + command = io_flush_command(:target_name => "Users") + assert_equal("Users", command.target_name) + end + end + + class RecursiveTest < self + class ReaderTest < self + def test_default + command = io_flush_command + assert do + command.recursive? + end + end + + def test_no + command = io_flush_command(:recursive => "no") + assert do + not command.recursive? + end + end + end + end +end -------------- next part -------------- HTML����������������������������... Download