chupa-text-decomposer-pdf 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e6ed1f4617372748a026ff23cf24bcd756889a84
4
- data.tar.gz: f9ee6fcc62fee9017def6027534dfa47967b1e99
2
+ SHA256:
3
+ metadata.gz: 030aa792be5eaf3746fe1dfade3f03b7d88d5764a53298e7188206b2640e5fa1
4
+ data.tar.gz: 544fbc65a5a91f90749e698fdc84b6c0b3df9e6c0ddb0056d8c00ebaebef1342
5
5
  SHA512:
6
- metadata.gz: 4083d5d3a4edfc11fd72719091d4e7133d5bd4a2895205d82f8686a1d95a2c463200e2f7e611514efaae75ac946bb0eb317bbf3652e1dc968661b610531d898c
7
- data.tar.gz: '001095acd4220a0c302ed9762120531c576a51b8192069516eb27b07e1303129574dff7973e2810e97d0053589902a41361a9aba652fb258862dd22d17e38873'
6
+ metadata.gz: 0c41d71242e4673c3ca26d954f0437626d73f8b33e088965d78abdbd56f9d94657985ae6c7fe16bf05565a872eb6e1a201c6d4b1b2067c36b0c6fa88167149d5
7
+ data.tar.gz: ea25378c33b97d84711d89fa08d3e10a2693807e8e4db942d57357b72ceac99aac5fffafe7f4567f8126cf86dae15d97e83382b0b14d1b5e0453022d356fcd2c
@@ -1,4 +1,4 @@
1
- # -*- mode: ruby; coding: utf-8 -*-
1
+ # -*- ruby -*-
2
2
  #
3
3
  # Copyright (C) 2013-2017 Kouhei Sutou <kou@clear-code.com>
4
4
  #
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  Gem::Specification.new do |spec|
24
24
  spec.name = "chupa-text-decomposer-pdf"
25
- spec.version = "1.0.5"
25
+ spec.version = "1.0.6"
26
26
  spec.homepage = "https://github.com/ranguba/chupa-text-decomposer-pdf"
27
27
  spec.authors = ["Kouhei Sutou"]
28
28
  spec.email = ["kou@clear-code.com"]
@@ -1,5 +1,11 @@
1
1
  # News
2
2
 
3
+ ## 1.0.6: 2019-02-27
4
+
5
+ ### Improvements
6
+
7
+ * Added support for the latest poppler gem.
8
+
3
9
  ## 1.0.5: 2017-07-12
4
10
 
5
11
  ### Improvements
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2017 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2013-2019 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -14,6 +14,7 @@
14
14
  # License along with this library; if not, write to the Free Software
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
+ require "tempfile"
17
18
  require "time"
18
19
 
19
20
  require "poppler"
@@ -62,17 +63,24 @@ module ChupaText
62
63
  private
63
64
  def create_document(data)
64
65
  _password = password(data)
66
+ path = data.path
67
+ if path and path.exist?
68
+ path = path.to_s
69
+ else
70
+ file = Tempfile.new(["chupa-text-decomposer-pdf", ".pdf"])
71
+ file.binmode
72
+ file.write(data.body)
73
+ file.close
74
+ path = file.path
75
+ end
65
76
  begin
66
77
  wrap_stderr do
67
- Poppler::Document.new(data.body, _password)
78
+ Poppler::Document.new(file: path, password: _password)
68
79
  end
80
+ rescue Poppler::Error::Encrypted
81
+ raise ChupaText::EncryptedError.new(data)
69
82
  rescue GLib::Error => error
70
- case error.code
71
- when Poppler::Error::ENCRYPTED.to_i
72
- raise ChupaText::EncryptedError.new(data)
73
- else
74
- raise ChupaText::InvalidDataError.new(data, error.message)
75
- end
83
+ raise ChupaText::InvalidDataError.new(data, error.message)
76
84
  end
77
85
  end
78
86
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chupa-text-decomposer-pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chupa-text
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.5.2
177
+ rubygems_version: 2.7.6
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: This is a ChupaText decomposer plugin for to extract text and meta-data from