Hiroshi Hatake
null+****@clear*****
Wed Jan 13 17:22:29 JST 2016
Hiroshi Hatake 2015-02-13 12:34:47 +0900 (Fri, 13 Feb 2015) New Revision: 6739241481afd3ec92711dfa14ec116bc5f5ce1b https://github.com/groonga/groonga-command/commit/6739241481afd3ec92711dfa14ec116bc5f5ce1b Merged b3cfbdd: Merge pull request #4 from cosmo0920/support-logical-count-command Message: Support logical_count command Added files: lib/groonga/command/logical-count.rb test/command/test-logical-count.rb Modified files: lib/groonga/command.rb Modified: lib/groonga/command.rb (+1 -0) =================================================================== --- lib/groonga/command.rb 2015-02-09 18:46:50 +0900 (9dadc15) +++ lib/groonga/command.rb 2015-02-13 12:34:47 +0900 (e096e20) @@ -28,6 +28,7 @@ require "groonga/command/delete" require "groonga/command/dump" require "groonga/command/get" require "groonga/command/load" +require "groonga/command/logical-count" require "groonga/command/normalize" require "groonga/command/range-filter" require "groonga/command/register" Added: lib/groonga/command/logical-count.rb (+93 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/command/logical-count.rb 2015-02-13 12:34:47 +0900 (2d59f74) @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2015 Hiroshi Hatake <hatake �� 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 `logical_count` command. + # + # @since 1.1.1 + class LogicalCount < Base + Command.register("logical_count", self) + + class << self + def parameter_names + [ + :logical_table, + :shard_key, + :min, + :min_border, + :max, + :max_border, + :filter, + ] + end + end + + # @return [String] `logical_table` parameter value. + # + # @since 1.1.1 + def logical_table + self[:logical_table] + end + + # @return [String] `shard_key` parameter value. + # + # @since 1.1.1 + def shard_key + self[:shard_key] + end + + # @return [String] `min` parameter value. + # + # @since 1.1.1 + def min + self[:min] + end + + # @return [String] `min_border` parameter value. + # + # @since 1.1.1 + def min_border + self[:min_border] + end + + # @return [String] `max` parameter value. + # + # @since 1.1.1 + def max + self[:max] + end + + # @return [String] `max_border` parameter value. + # + # @since 1.1.1 + def max_border + self[:max_border] + end + + # @return [String] `filter` parameter value. + # + # @since 1.1.1 + def filter + self[:filter] + end + end + end +end Added: test/command/test-logical-count.rb (+99 -0) 100644 =================================================================== --- /dev/null +++ test/command/test-logical-count.rb 2015-02-13 12:34:47 +0900 (1b0c172) @@ -0,0 +1,99 @@ +# Copyright (C) 2015 Hiroshi Hatake <hatake �� 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 LogicalCountCommandTest < Test::Unit::TestCase + private + def logical_count_command(pair_arguments={}, ordered_arguments=[]) + Groonga::Command::LogicalCount.new("logical_count", + pair_arguments, + ordered_arguments) + end + + class ConstructorTest < self + def test_ordered_arguments + logical_table = "Logs" + shard_key = "timestamp" + min = "2015-02-12 00:00:00" + min_border = "include" + max = "2015-02-13 00:00:00" + max_border = "exclude" + filter = "message == \"Shutdown\"" + + ordered_arguments = [ + logical_table, + shard_key, + min, + min_border, + max, + max_border, + filter, + ] + command = logical_count_command({}, ordered_arguments) + assert_equal({ + :logical_table => logical_table, + :shard_key => shard_key, + :min => min, + :min_border => min_border, + :max => max, + :max_border => max_border, + :filter => filter, + }, + command.arguments) + end + end + + class TableTest < self + def test_reader + command = logical_count_command(:logical_table => "Logs") + assert_equal("Logs", command.logical_table) + end + end + + class ColumnTest < self + def test_reader + command = logical_count_command(:shard_key => "timestamp") + assert_equal("timestamp", command.shard_key) + end + end + + class MinTest < self + def test_reader + command = logical_count_command(:min => "2015-02-13 00:00:00") + assert_equal("2015-02-13 00:00:00", command.min) + end + end + + class MinBorderTest < self + def test_reader + command = logical_count_command(:min_border => "include") + assert_equal("include", command.min_border) + end + end + + class MaxTest < self + def test_reader + command = logical_count_command(:max => "2015-02-13 00:00:00") + assert_equal("2015-02-13 00:00:00", command.max) + end + end + + class FilterTest < self + def test_reader + command = logical_count_command(:filter => "message == \"Shutdown\"") + assert_equal("message == \"Shutdown\"", command.filter) + end + end +end -------------- next part -------------- HTML����������������������������... Télécharger