Kouhei Sutou
null+****@clear*****
Fri Jan 3 18:14:11 JST 2014
Kouhei Sutou 2014-01-03 18:14:11 +0900 (Fri, 03 Jan 2014) New Revision: 76badd9513b6058c80034738e6727444414227a9 https://github.com/ranguba/chupa-text/commit/76badd9513b6058c80034738e6727444414227a9 Message: Accept "text/XXX" content-type as text Modified files: lib/chupa-text/data.rb test/command/test-chupa-text.rb test/test-extractor.rb Modified: lib/chupa-text/data.rb (+1 -1) =================================================================== --- lib/chupa-text/data.rb 2014-01-03 18:13:56 +0900 (c27c449) +++ lib/chupa-text/data.rb 2014-01-03 18:14:11 +0900 (f74dc5e) @@ -93,7 +93,7 @@ module ChupaText # @return [Bool] true if content-type is "text/plain", false # otherwise. def text? - content_type == "text/plain" + (content_type || "").start_with?("text/") end private Modified: test/command/test-chupa-text.rb (+6 -0) =================================================================== --- test/command/test-chupa-text.rb 2014-01-03 18:13:56 +0900 (122ce63) +++ test/command/test-chupa-text.rb 2014-01-03 18:14:11 +0900 (85d41c6) @@ -121,6 +121,12 @@ class TestCommandChupaText < Test::Unit::TestCase "size" => @html.bytesize, "uri" => @uri, "texts" => [ + { + "content-type" => "text/html", + "size" => @html.bytesize, + "uri" => @uri, + "body" => @html, + }, ], }, ], Modified: test/test-extractor.rb (+2 -2) =================================================================== --- test/test-extractor.rb 2014-01-03 18:13:56 +0900 (9f22147) +++ test/test-extractor.rb 2014-01-03 18:14:11 +0900 (6312bd6) @@ -39,8 +39,8 @@ class TestExtractor < Test::Unit::TestCase def test_not_text data = ChupaText::Data.new - data.content_type = "text/html" - data.body = "<html><body>Hello</body></html>" + data.content_type = "application/x-javascript" + data.body = "alert('Hello');" assert_equal([], extract(data)) end end -------------- next part -------------- HTML����������������������������... Download