Kouhei Sutou
null+****@clear*****
Fri Jan 31 17:52:56 JST 2014
Kouhei Sutou 2014-01-31 17:52:56 +0900 (Fri, 31 Jan 2014) New Revision: b2ec29fc4bf4d4ce95db4dd12076be15d99079db https://github.com/droonga/fluent-plugin-droonga/commit/b2ec29fc4bf4d4ce95db4dd12076be15d99079db Message: command: add :include? operator Modified files: lib/droonga/command.rb test/unit/test_command.rb Modified: lib/droonga/command.rb (+6 -3) =================================================================== --- lib/droonga/command.rb 2014-01-31 17:52:35 +0900 (ba335f3) +++ lib/droonga/command.rb 2014-01-31 17:52:56 +0900 (df92ece) @@ -28,8 +28,9 @@ module Droonga # * PATTERN = [TARGET_PATH, OPERATOR, ARGUMENTS*] # * PATTERN = [PATTERN, LOGICAL_OPERATOR, PATTERN] # * TARGET_PATH = "COMPONENT(.COMPONENT)*" - # * OPERATOR = :equal (More operators may be added in the future. - # For example, :include?, :start_with and so on.) + # * OPERATOR = :equal, :include? + # (More operators may be added in the future. + # For example, :exist?, :start_with and so on.) # * ARGUMENTS = OBJECT_DEFINED_IN_JSON* # * LOGICAL_OPERATOR = :or (:add will be added.) # @@ -96,8 +97,10 @@ module Droonga case operator when :equal [target] == arguments + when :include? + arguments.include?(target) else - raise InvalidArgument, "Unknown operator" + raise ArgumentError, "Unknown operator" end end end Modified: test/unit/test_command.rb (+16 -0) =================================================================== --- test/unit/test_command.rb 2014-01-31 17:52:35 +0900 (f992891) +++ test/unit/test_command.rb 2014-01-31 17:52:56 +0900 (78cb97b) @@ -79,5 +79,21 @@ class CommandTest < Test::Unit::TestCase })) end end + + class IncludeTest < self + def test_include + assert_true(match?([["type", :include?, "table_create", "table_remove"]], + { + "type" => "table_remove" + })) + end + + def test_not_included + assert_false(match?([["type", :include?, "table_create", "table_remove"]], + { + "type" => "column_create", + })) + end + end end end -------------- next part -------------- HTML����������������������������...Download