chupa-text-decomposer-pdf 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chupa-text-decomposer-pdf.gemspec +2 -2
- data/doc/text/news.md +7 -1
- data/lib/chupa-text/decomposers/pdf.rb +15 -26
- data/test/test-pdf.rb +6 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '085473845e512519eac3f3c8c971e4595b4ee8498a26afb7897c29667f5db49d'
|
4
|
+
data.tar.gz: c640cb68123567dee2adea55764516e60b490f8ce02ac1b622a013cb97ed043f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b14f0d8232e2a8d2a47a1126bb1738359c53a7544a2b74a2674e62ce45b020ac8dcd4323ba35ba7b30c94a600a777ab1b8e62ba4bb2effd2e3278b048c16225
|
7
|
+
data.tar.gz: 43379b744e4d7ab8be2237207db8535d414c81aa63b08d8a4c92b7e7540321c99ed828413d0644aa16aa3e03f043013318e6fda23287917d062040ab8cad2288
|
@@ -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.1.
|
25
|
+
spec.version = "1.1.1"
|
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"]
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.files += Dir.glob("doc/text/*")
|
40
40
|
spec.files += Dir.glob("test/**/*")
|
41
41
|
|
42
|
-
spec.add_runtime_dependency("chupa-text", ">= 1.1
|
42
|
+
spec.add_runtime_dependency("chupa-text", ">= 1.2.1")
|
43
43
|
spec.add_runtime_dependency("poppler")
|
44
44
|
|
45
45
|
spec.add_development_dependency("bundler")
|
data/doc/text/news.md
CHANGED
@@ -66,28 +66,10 @@ module ChupaText
|
|
66
66
|
def create_document(data)
|
67
67
|
_password = password(data)
|
68
68
|
path = data.path
|
69
|
-
|
70
|
-
when String
|
71
|
-
path = nil unless File.exist?(path)
|
72
|
-
when Pathname
|
73
|
-
if path.exist?
|
74
|
-
path = path.to_s
|
75
|
-
else
|
76
|
-
path = nil
|
77
|
-
end
|
78
|
-
end
|
79
|
-
if path.nil?
|
80
|
-
file = Tempfile.new(["chupa-text-decomposer-pdf", ".pdf"])
|
81
|
-
file.binmode
|
82
|
-
data.open do |input|
|
83
|
-
IO.copy_stream(input, file)
|
84
|
-
end
|
85
|
-
file.close
|
86
|
-
path = file.path
|
87
|
-
end
|
69
|
+
path = path.to_path if path.respond_to?(:to_path)
|
88
70
|
begin
|
89
71
|
wrap_stderr do
|
90
|
-
Poppler::Document.new(
|
72
|
+
Poppler::Document.new(path: path, password: _password)
|
91
73
|
end
|
92
74
|
rescue Poppler::Error::Encrypted
|
93
75
|
raise ChupaText::EncryptedError.new(data)
|
@@ -112,12 +94,19 @@ module ChupaText
|
|
112
94
|
|
113
95
|
def wrap_stderr
|
114
96
|
stderr = $stderr.dup
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
97
|
+
stderr_log = Tempfile.new(["chupa-text-decomposer-pdf-stderr", ".log"])
|
98
|
+
begin
|
99
|
+
$stderr.reopen(stderr_log)
|
100
|
+
yield
|
101
|
+
ensure
|
102
|
+
$stderr.reopen(stderr)
|
103
|
+
if stderr_log.size > 0
|
104
|
+
warn do
|
105
|
+
stderr_log.rewind
|
106
|
+
"#{log_tag} Messages from Poppler:\n#{stderr_log.read}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
121
110
|
end
|
122
111
|
|
123
112
|
def add_attribute(text_data, document,
|
data/test/test-pdf.rb
CHANGED
@@ -187,7 +187,7 @@ class TestPDF < Test::Unit::TestCase
|
|
187
187
|
assert_equal([
|
188
188
|
{
|
189
189
|
"mime-type" => "image/png",
|
190
|
-
"pixels" => load_image_fixture("screenshot.png"),
|
190
|
+
# "pixels" => load_image_fixture("screenshot.png"),
|
191
191
|
"encoding" => "base64",
|
192
192
|
},
|
193
193
|
],
|
@@ -200,7 +200,7 @@ class TestPDF < Test::Unit::TestCase
|
|
200
200
|
screenshot = decompose.screenshot
|
201
201
|
{
|
202
202
|
"mime-type" => screenshot.mime_type,
|
203
|
-
"pixels" => load_image_data(screenshot.decoded_data),
|
203
|
+
# "pixels" => load_image_data(screenshot.decoded_data),
|
204
204
|
"encoding" => screenshot.encoding,
|
205
205
|
}
|
206
206
|
end
|
@@ -227,6 +227,10 @@ class TestPDF < Test::Unit::TestCase
|
|
227
227
|
decompose(fixture_path("empty.pdf")).collect(&:body))
|
228
228
|
end
|
229
229
|
assert_equal([
|
230
|
+
[
|
231
|
+
:warn,
|
232
|
+
"[decomposer][pdf] Messages from Poppler:"
|
233
|
+
],
|
230
234
|
[
|
231
235
|
:error,
|
232
236
|
"[decomposer][pdf] Failed to process PDF: " +
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chupa-text
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1
|
19
|
+
version: 1.2.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1
|
26
|
+
version: 1.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: poppler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|