[Groonga-commit] ranguba/chupa-text at 6093dfc [master] Add Data#text_plain?

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jan 5 14:57:52 JST 2014


Kouhei Sutou	2014-01-05 14:57:52 +0900 (Sun, 05 Jan 2014)

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

  Message:
    Add Data#text_plain?

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

  Modified: lib/chupa-text/data.rb (+6 -0)
===================================================================
--- lib/chupa-text/data.rb    2014-01-05 14:53:49 +0900 (1ff4ede)
+++ lib/chupa-text/data.rb    2014-01-05 14:57:52 +0900 (26034fc)
@@ -117,6 +117,12 @@ module ChupaText
       (mime_type || "").start_with?("text/")
     end
 
+    # @return [Bool] true if MIME type is "text/plain", false
+    #   otherwise.
+    def text_plain?
+      mime_type == "text/plain"
+    end
+
     private
     def guess_mime_type
       guess_mime_type_from_uri or

  Modified: test/test-data.rb (+34 -0)
===================================================================
--- test/test-data.rb    2014-01-05 14:53:49 +0900 (97452cc)
+++ test/test-data.rb    2014-01-05 14:57:52 +0900 (9f0f62a)
@@ -56,6 +56,40 @@ class TestData < Test::Unit::TestCase
         end
       end
     end
+
+    sub_test_case("text?") do
+      def test_text_plain
+        @data.mime_type = "text/plain"
+        assert_true(@data.text?)
+      end
+
+      def test_text_html
+        @data.mime_type = "text/html"
+        assert_true(@data.text?)
+      end
+
+      def test_application_xhtml_xml
+        @data.mime_type = "application/xhtml+xml"
+        assert_false(@data.text?)
+      end
+    end
+
+    sub_test_case("text_plain?") do
+      def test_text_plain
+        @data.mime_type = "text/plain"
+        assert_true(@data.text_plain?)
+      end
+
+      def test_text_html
+        @data.mime_type = "text/html"
+        assert_false(@data.text_plain?)
+      end
+
+      def test_application_xhtml_xml
+        @data.mime_type = "application/xhtml+xml"
+        assert_false(@data.text_plain?)
+      end
+    end
   end
 
   sub_test_case("extension") do
-------------- next part --------------
HTML����������������������������...
Download 



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