[Groonga-commit] ranguba/chupa-text at cd85a86 [master] Remove "=" from option key

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jan 3 16:01:54 JST 2014


Kouhei Sutou	2014-01-03 16:01:54 +0900 (Fri, 03 Jan 2014)

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

  Message:
    Remove "=" from option key

  Added files:
    test/test-configuration-loader.rb
  Modified files:
    chupa-text.conf
    lib/chupa-text/configuration-loader.rb
    test/helper.rb

  Modified: chupa-text.conf (+1 -0)
===================================================================
--- chupa-text.conf    2014-01-03 15:49:51 +0900 (59ea55e)
+++ chupa-text.conf    2014-01-03 16:01:54 +0900 (8c76ef5)
@@ -1,3 +1,4 @@
 # -*- ruby -*-
 
 decomposer.names = ["*"]
+decomposer.tar = {}

  Modified: lib/chupa-text/configuration-loader.rb (+4 -5)
===================================================================
--- lib/chupa-text/configuration-loader.rb    2014-01-03 15:49:51 +0900 (e4e0a64)
+++ lib/chupa-text/configuration-loader.rb    2014-01-03 16:01:54 +0900 (a96f038)
@@ -56,12 +56,11 @@ module ChupaText
       def method_missing(name, *arguments)
         return super if block_given?
 
-        case arguments.size
-        when 0
-          self[name.to_s]
-        when 1
+        if name.to_s.end_with?("=") and arguments.size == 1
           value = arguments.first
-          self[name.to_s] = value
+          self[name.to_s.gsub(/=\z/, "")] = value
+        elsif arguments.empty?
+          self[name.to_s]
         else
           super
         end

  Modified: test/helper.rb (+1 -0)
===================================================================
--- test/helper.rb    2014-01-03 15:49:51 +0900 (c46e2e6)
+++ test/helper.rb    2014-01-03 16:01:54 +0900 (5d3aa15)
@@ -15,6 +15,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 require "pathname"
+require "tempfile"
 
 module Helper
   def fixture_path(*components)

  Added: test/test-configuration-loader.rb (+54 -0) 100644
===================================================================
--- /dev/null
+++ test/test-configuration-loader.rb    2014-01-03 16:01:54 +0900 (fccf61f)
@@ -0,0 +1,54 @@
+# Copyright (C) 2013  Kouhei Sutou <kou �� 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 TestConfiguration < Test::Unit::TestCase
+  def setup
+    @configuration = ChupaText::Configuration.new
+    @loader = ChupaText::ConfigurationLoader.new(@configuration)
+  end
+
+  private
+  def load(content)
+    file = Tempfile.new("chupa-text")
+    file.print(content)
+    file.flush
+    @loader.load(file.path)
+    file
+  end
+
+  sub_test_case("decomposer") do
+    def test_names
+      load(<<-CONFIGURATION)
+decomposer.names = ["tar", "zip"]
+      CONFIGURATION
+      assert_equal(["tar", "zip"], @configuration.decomposer.names)
+    end
+
+    def test_option
+      load(<<-CONFIGURATION)
+decomposer.tar = {
+  :omit_size => true
+}
+      CONFIGURATION
+      assert_equal({
+                     "tar" => {
+                       :omit_size => true,
+                     },
+                   },
+                   @configuration.decomposer.options)
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
下載 



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