Kouhei Sutou 2019-03-04 09:09:27 +0900 (Mon, 04 Mar 2019) Revision: e274a117963c792a9172f231232966249b826cf6 https://github.com/ranguba/chupa-text-decomposer-pdf/commit/e274a117963c792a9172f231232966249b826cf6 Message: Simplify path handling Modified files: chupa-text-decomposer-pdf.gemspec lib/chupa-text/decomposers/pdf.rb Modified: chupa-text-decomposer-pdf.gemspec (+1 -1) =================================================================== --- chupa-text-decomposer-pdf.gemspec 2019-03-03 06:40:55 +0900 (9737b12) +++ chupa-text-decomposer-pdf.gemspec 2019-03-04 09:09:27 +0900 (f37eeaa) @@ -39,7 +39,7 @@ Gem::Specification.new do |spec| spec.files += Dir.glob("doc/text/*") spec.files += Dir.glob("test/**/*") - spec.add_runtime_dependency("chupa-text", ">= 1.1.9") + spec.add_runtime_dependency("chupa-text", ">= 1.2.1") spec.add_runtime_dependency("poppler") spec.add_development_dependency("bundler") Modified: lib/chupa-text/decomposers/pdf.rb (+2 -20) =================================================================== --- lib/chupa-text/decomposers/pdf.rb 2019-03-03 06:40:55 +0900 (7ad7e45) +++ lib/chupa-text/decomposers/pdf.rb 2019-03-04 09:09:27 +0900 (324ce94) @@ -66,28 +66,10 @@ module ChupaText def create_document(data) _password = password(data) path = data.path - case path - when String - path = nil unless File.exist?(path) - when Pathname - if path.exist? - path = path.to_s - else - path = nil - end - end - if path.nil? - file = Tempfile.new(["chupa-text-decomposer-pdf", ".pdf"]) - file.binmode - data.open do |input| - IO.copy_stream(input, file) - end - file.close - path = file.path - end + path = path.to_path if path.respond_to?(:to_path) begin wrap_stderr do - Poppler::Document.new(file: path, password: _password) + Poppler::Document.new(path: path, password: _password) end rescue Poppler::Error::Encrypted raise ChupaText::EncryptedError.new(data) -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190304/86f6fff7/attachment-0001.html>