Kouhei Sutou
null+****@clear*****
Tue Jul 28 10:50:52 JST 2015
Kouhei Sutou 2015-07-28 10:50:52 +0900 (Tue, 28 Jul 2015) New Revision: 3f1e5c2832f2177ba0365af182bc7dc95c7a6c0d https://github.com/groonga/groonga-command/commit/3f1e5c2832f2177ba0365af182bc7dc95c7a6c0d Message: Support log_put Added files: lib/groonga/command/log-put.rb test/command/test-log-put.rb Modified files: lib/groonga/command.rb Modified: lib/groonga/command.rb (+1 -0) =================================================================== --- lib/groonga/command.rb 2015-07-28 10:48:29 +0900 (bc4d0dd) +++ lib/groonga/command.rb 2015-07-28 10:50:52 +0900 (d54d46f) @@ -33,6 +33,7 @@ require "groonga/command/logical-count" require "groonga/command/logical-range-filter" require "groonga/command/logical-select" require "groonga/command/logical-table-remove" +require "groonga/command/log-put" require "groonga/command/normalize" require "groonga/command/object-exist" require "groonga/command/plugin-register" Added: lib/groonga/command/log-put.rb (+51 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/command/log-put.rb 2015-07-28 10:50:52 +0900 (4ed7c18) @@ -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 `log_put` command. + # + # @since 1.1.3 + class LogPut < Base + Command.register("log_put", self) + + class << self + def parameter_names + [ + :level, + :message, + ] + end + end + + # @return [String] `level` parameter value. + # + # @since 1.1.3 + def level + self[:level] + end + + # @return [String] `message` parameter value. + # + # @since 1.1.3 + def message + self[:message] + end + end + end +end Added: test/command/test-log-put.rb (+56 -0) 100644 =================================================================== --- /dev/null +++ test/command/test-log-put.rb 2015-07-28 10:50:52 +0900 (ac0a273) @@ -0,0 +1,56 @@ +# 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 LogPutCommandTest < Test::Unit::TestCase + private + def log_put_command(pair_arguments={}, ordered_arguments=[]) + Groonga::Command::LogPut.new("log_put", + pair_arguments, + ordered_arguments) + end + + class ConstructorTest < self + def test_ordered_arguments + level = "debug" + message = "Hello!" + + ordered_arguments = [ + level, + message, + ] + command = log_put_command({}, ordered_arguments) + assert_equal({ + :level => level, + :message => message, + }, + command.arguments) + end + end + + class LevelTest < self + def test_reader + command = log_put_command(:level => "debug") + assert_equal("debug", command.level) + end + end + + class MessageTest < self + def test_reader + command = log_put_command(:message => "Hello!") + assert_equal("Hello!", command.message) + end + end +end -------------- next part -------------- HTML����������������������������... Download