Skip to content

Commit

Permalink
Support log_put
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jul 28, 2015
1 parent 12d3be2 commit 3f1e5c2
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/groonga/command.rb
Expand Up @@ -33,6 +33,7 @@
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"
Expand Down
51 changes: 51 additions & 0 deletions lib/groonga/command/log-put.rb
@@ -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
56 changes: 56 additions & 0 deletions test/command/test-log-put.rb
@@ -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

0 comments on commit 3f1e5c2

Please sign in to comment.