Kouhei Sutou
null+****@clear*****
Mon Feb 17 13:12:11 JST 2014
Kouhei Sutou 2014-02-17 13:12:11 +0900 (Mon, 17 Feb 2014) New Revision: 584bc573fcb3c2e28c5eadd4f413b8a7b8901a83 https://github.com/droonga/fluent-plugin-droonga/commit/584bc573fcb3c2e28c5eadd4f413b8a7b8901a83 Message: MessageMatcher: mark "?" style such as :include? and :exist? deprecated All operators are predicates. So "?" is meaningless. You can still use :include? and :exist? but use :include and :exist instead. Modified files: lib/droonga/message_matcher.rb test/unit/test_message_matcher.rb Modified: lib/droonga/message_matcher.rb (+4 -3) =================================================================== --- lib/droonga/message_matcher.rb 2014-02-17 13:10:24 +0900 (4b1f902) +++ lib/droonga/message_matcher.rb 2014-02-17 13:12:11 +0900 (cd266f3) @@ -21,7 +21,8 @@ module Droonga # * PATTERN = [TARGET_PATH, OPERATOR, ARGUMENTS*] # * PATTERN = [PATTERN, LOGICAL_OPERATOR, PATTERN] # * TARGET_PATH = "COMPONENT(.COMPONENT)*" - # * OPERATOR = :equal, :in, :include?, :exist?, :start_with + # * OPERATOR = :equal, :in, :include, :exist, :start_with + # (:include? and :exist? are deprecated. Use no "?" version.) # (More operators may be added in the future. # For example, :end_with and so on.) # * ARGUMENTS = OBJECT_DEFINED_IN_JSON* @@ -86,12 +87,12 @@ module Droonga arguments.any? do |argument| argument.include?(target) end - when :include? + when :include, :include? return false unless target.respond_to?(:include?) arguments.any? do |argument| target.include?(argument) end - when :exist? + when :exist, :exist? target != NONEXISTENT_PATH when :start_with return false unless target.respond_to?(:start_with?) Modified: test/unit/test_message_matcher.rb (+22 -6) =================================================================== --- test/unit/test_message_matcher.rb 2014-02-17 13:10:24 +0900 (ab7e8a1) +++ test/unit/test_message_matcher.rb 2014-02-17 13:12:11 +0900 (65858e3) @@ -90,35 +90,42 @@ class MessageMatcherTest < Test::Unit::TestCase class IncludeTest < self def test_exist - assert_true(match?(["originalTypes", :include?, "select"], + assert_true(match?(["originalTypes", :include, "select"], { "originalTypes" => ["search", "select"], })) end def test_not_exist - assert_false(match?(["originalTypes", :include?, "select"], + assert_false(match?(["originalTypes", :include, "select"], { "originalTypes" => ["load"], })) end def test_no_key - assert_false(match?(["originalTypes", :include?, "select"], + assert_false(match?(["originalTypes", :include, "select"], {})) end def test_not_enumerable - assert_false(match?(["originalTypes", :include?, "select"], + assert_false(match?(["originalTypes", :include, "select"], { "originalTypes" => 29, })) end + + def test_backward_compatibility + assert_true(match?(["originalTypes", :include?, "select"], + { + "originalTypes" => ["search", "select"], + })) + end end class ExistTest < self def test_exist - assert_true(match?(["body.result", :exist?], + assert_true(match?(["body.result", :exist], { "body" => { "result" => nil, @@ -127,11 +134,20 @@ class MessageMatcherTest < Test::Unit::TestCase end def test_not_exist - assert_false(match?(["body.result", :exist?], + assert_false(match?(["body.result", :exist], { "body" => nil, })) end + + def test_backward_compatibility + assert_true(match?(["body.result", :exist?], + { + "body" => { + "result" => nil, + }, + })) + end end class StartWithTest < self -------------- next part -------------- HTML����������������������������...Download