[Groonga-commit] ranguba/chupa-text at 08870f7 [master] Don't use Ruby 2.0.0 or later feature, File::FNM_EXTGLOB

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jan 3 15:37:12 JST 2014


Kouhei Sutou	2014-01-03 15:37:12 +0900 (Fri, 03 Jan 2014)

  New Revision: 08870f7be42050c6d8be2c7d41b010c66cbec5aa
  https://github.com/ranguba/chupa-text/commit/08870f7be42050c6d8be2c7d41b010c66cbec5aa

  Message:
    Don't use Ruby 2.0.0 or later feature, File::FNM_EXTGLOB

  Modified files:
    lib/chupa-text/decomposers.rb
    test/test-decomposers.rb

  Modified: lib/chupa-text/decomposers.rb (+3 -1)
===================================================================
--- lib/chupa-text/decomposers.rb    2014-01-03 15:33:07 +0900 (d8c8a65)
+++ lib/chupa-text/decomposers.rb    2014-01-03 15:37:12 +0900 (c87eca7)
@@ -42,9 +42,11 @@ module ChupaText
       private
       def resolve_names(registry, enabled_names)
         resolved_names = []
+        flag = 0
+        flag |= File::FNM_EXTGLOB if File.const_defined?(:FNM_EXTGLOB)
         enabled_names.each do |enabled_name|
           registry.each do |name,|
-            next unless File.fnmatch(enabled_name, name, File::FNM_EXTGLOB)
+            next unless File.fnmatch(enabled_name, name, flag)
             resolved_names << name
           end
         end

  Modified: test/test-decomposers.rb (+6 -0)
===================================================================
--- test/test-decomposers.rb    2014-01-03 15:33:07 +0900 (071c88a)
+++ test/test-decomposers.rb    2014-01-03 15:37:12 +0900 (674b847)
@@ -36,6 +36,12 @@ class TestDecomposers < Test::Unit::TestCase
       assert_equal([], decomposers.collect(&:class))
     end
 
+    def test_glob
+      @configuration.decomposer.names = ["{a,b,c}sv"]
+      decomposers = create
+      assert_equal([CSVDecomposer], decomposers.collect(&:class))
+    end
+
     private
     def create
       ChupaText::Decomposers.create(@registry, @configuration.decomposer)
-------------- next part --------------
HTML����������������������������...
Download 



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