[Groonga-commit] groonga/groonga-query-log [master] extractor: add missing regular expression support of #target?

Back to archive index

Haruka Yoshihara null+****@clear*****
Fri Dec 14 18:27:36 JST 2012


Haruka Yoshihara	2012-12-14 18:27:36 +0900 (Fri, 14 Dec 2012)

  New Revision: fab2b37a5fd9b1380ca46ac68cf1d4856c333a55
  https://github.com/groonga/groonga-query-log/commit/fab2b37a5fd9b1380ca46ac68cf1d4856c333a55

  Log:
    extractor: add missing regular expression support of #target?

  Modified files:
    lib/groonga/query-log/extractor.rb
    test/test-extractor.rb

  Modified: lib/groonga/query-log/extractor.rb (+2 -2)
===================================================================
--- lib/groonga/query-log/extractor.rb    2012-12-14 18:15:27 +0900 (36b5494)
+++ lib/groonga/query-log/extractor.rb    2012-12-14 18:27:36 +0900 (72224aa)
@@ -48,11 +48,11 @@ module Groonga
         exclude_commands =****@optio*****_commands
 
         unless commands.empty?
-          return commands.include?(name)
+          return commands.any? {|command| command === name}
         end
 
         unless exclude_commands.empty?
-          return (not exclude_commands.include?(name))
+          return (not exclude_commands.any? {|command| command === name})
         end
 
         true

  Modified: test/test-extractor.rb (+12 -0)
===================================================================
--- test/test-extractor.rb    2012-12-14 18:15:27 +0900 (05387b2)
+++ test/test-extractor.rb    2012-12-14 18:27:36 +0900 (4cd0f3d)
@@ -42,6 +42,18 @@ class TestExtractor < Test::Unit::TestCase
       assert_true(target?("dump"))
     end
 
+    def test_regular_expression_include
+      @extractor.options.commands = [/table/]
+      assert_true(target?("table_create"))
+      assert_false(target?("dump"))
+    end
+
+    def test_regular_expression_exclude
+      @extractor.options.exclude_commands = [/table/]
+      assert_false(target?("table_create"))
+      assert_true(target?("dump"))
+    end
+
     private
     def target?(name)
       command_class = Groonga::Command.find(name)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index