[Groonga-commit] ranguba/chupa-text-decomposer-pdf at ef62794 [master] Always add a new line at the end of page

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Feb 18 00:00:04 JST 2014


Kouhei Sutou	2014-02-18 00:00:04 +0900 (Tue, 18 Feb 2014)

  New Revision: ef62794ed3acfc55ed18f850593946b262f25b52
  https://github.com/ranguba/chupa-text-decomposer-pdf/commit/ef62794ed3acfc55ed18f850593946b262f25b52

  Message:
    Always add a new line at the end of page

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

  Modified: lib/chupa-text/decomposers/pdf.rb (+1 -3)
===================================================================
--- lib/chupa-text/decomposers/pdf.rb    2014-02-17 23:57:20 +0900 (5578699)
+++ lib/chupa-text/decomposers/pdf.rb    2014-02-18 00:00:04 +0900 (47f7d72)
@@ -34,10 +34,8 @@ module ChupaText
         document.each do |page|
           page_text = page.get_text
           next if page_text.empty?
-          if !text.empty? and !text.end_with?("\n")
-            text << "\n"
-          end
           text << page_text
+          text << "\n" unless page_text.end_with?("\n")
         end
         text_data = TextData.new(text)
         text_data.uri = data.uri

  Modified: test/test-pdf.rb (+4 -4)
===================================================================
--- test/test-pdf.rb    2014-02-17 23:57:20 +0900 (2ef712d)
+++ test/test-pdf.rb    2014-02-18 00:00:04 +0900 (0369497)
@@ -119,7 +119,7 @@ class TestPDF < Test::Unit::TestCase
 
     sub_test_case("one page") do
       def test_body
-        assert_equal(["Page1"], decompose.collect(&:body))
+        assert_equal(["Page1\n"], decompose.collect(&:body))
       end
 
       private
@@ -130,7 +130,7 @@ class TestPDF < Test::Unit::TestCase
 
     sub_test_case("multi pages") do
       def test_body
-        assert_equal(["Page1\nPage2"], decompose.collect(&:body))
+        assert_equal(["Page1\nPage2\n"], decompose.collect(&:body))
       end
 
       private
@@ -142,13 +142,13 @@ class TestPDF < Test::Unit::TestCase
     sub_test_case("encrypted") do
       def test_with_password
         @options = {:password => "encrypted"}
-        assert_equal(["Password is 'encrypted'."],
+        assert_equal(["Password is 'encrypted'.\n"],
                      decompose.collect(&:body))
       end
 
       def test_with_password_block
         @options = {:password => lambda {|data| "encrypted"}}
-        assert_equal(["Password is 'encrypted'."],
+        assert_equal(["Password is 'encrypted'.\n"],
                      decompose.collect(&:body))
       end
 
-------------- next part --------------
HTML����������������������������...
Download 



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