[Groonga-commit] ranguba/chupa-text-decomposer-pdf at f01a5f2 [master] Suppress stderr messages from Poppler

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Feb 17 23:49:20 JST 2014


Kouhei Sutou	2014-02-17 23:49:20 +0900 (Mon, 17 Feb 2014)

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

  Message:
    Suppress stderr messages from Poppler

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

  Modified: lib/chupa-text/decomposers/pdf.rb (+14 -1)
===================================================================
--- lib/chupa-text/decomposers/pdf.rb    2014-02-17 23:40:56 +0900 (e2f7337)
+++ lib/chupa-text/decomposers/pdf.rb    2014-02-17 23:49:20 +0900 (b9d80eb)
@@ -51,8 +51,11 @@ module ChupaText
 
       private
       def create_document(data)
+        _password = password(data)
         begin
-          Poppler::Document.new(data.body, password(data))
+          wrap_stdout do
+            Poppler::Document.new(data.body, _password)
+          end
         rescue GLib::Error => error
           case error.code
           when Poppler::Error::ENCRYPTED.to_i
@@ -71,6 +74,16 @@ module ChupaText
         password
       end
 
+      def wrap_stderr
+        stderr = $stderr.dup
+        input, output = IO.pipe
+        _ = input # TODO: Report output
+        $stderr.reopen(output)
+        yield
+      ensure
+        $stderr.reopen(stderr)
+      end
+
       def add_attribute(text_data, document,
                         pdf_attribute_name, data_attribute_name=nil)
         value = document.send(pdf_attribute_name)
-------------- next part --------------
HTML����������������������������...
Download 



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