chupa-text-decomposer-libreoffice 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/chupa-text-decomposer-libreoffice.gemspec +2 -1
- data/doc/text/news.md +6 -0
- data/lib/chupa-text/decomposers/libreoffice.rb +36 -18
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a4cebc4c301e01567236b782b186fbb89b0828b229744c46a9bb03e04adf954
|
4
|
+
data.tar.gz: 6220a482e2a218cc46018467ce0ecec4a7efb8669dc30a691076622338378ba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a01ff0f8c14b3bff084145b978dfa8fa3cd936eb3aef6bafe61dac0c5127b04446fec9c75722ef2bb5b02ca840cac21e293a98fb8f81ba15ec245d2eb4ad53f1
|
7
|
+
data.tar.gz: 0c001dc26e769a10b8f6f62172bb364cc4e0e58dc5a3e9040be63fbd2a8e99cab0f63c5ff13b54fd46b75e5e285cbbfce3ad4ea6c5c0c1e0a7a6624ec85396dd
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
|
23
23
|
Gem::Specification.new do |spec|
|
24
24
|
spec.name = "chupa-text-decomposer-libreoffice"
|
25
|
-
spec.version = "1.0.
|
25
|
+
spec.version = "1.0.2"
|
26
26
|
spec.homepage = "https://github.com/ranguba/chupa-text-decomposer-libreoffice"
|
27
27
|
spec.authors = ["Kouhei Sutou"]
|
28
28
|
spec.email = ["kou@clear-code.com"]
|
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
|
|
41
41
|
|
42
42
|
spec.requirements << "LibreOffice"
|
43
43
|
|
44
|
+
spec.add_runtime_dependency("chupa-text", ">= 1.0.9")
|
44
45
|
spec.add_runtime_dependency("chupa-text-decomposer-pdf")
|
45
46
|
|
46
47
|
spec.add_development_dependency("bundler")
|
data/doc/text/news.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2014-2017 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
|
@@ -20,11 +20,20 @@ require "tmpdir"
|
|
20
20
|
module ChupaText
|
21
21
|
module Decomposers
|
22
22
|
class LibreOffice < Decomposer
|
23
|
+
include Loggable
|
24
|
+
|
23
25
|
registry.register("libreoffice", self)
|
24
26
|
|
25
27
|
def initialize(options)
|
26
28
|
super
|
27
29
|
@command = find_command
|
30
|
+
debug do
|
31
|
+
if @command
|
32
|
+
"#{log_tag}[command][found] #{@command.path}"
|
33
|
+
else
|
34
|
+
"#{log_tag}[command][not-found]"
|
35
|
+
end
|
36
|
+
end
|
28
37
|
end
|
29
38
|
|
30
39
|
TARGET_EXTENSIONS = [
|
@@ -89,7 +98,7 @@ module ChupaText
|
|
89
98
|
def convert_to_pdf(data)
|
90
99
|
Dir.mktmpdir do |temporary_directory|
|
91
100
|
output = Tempfile.new("chupa-text-decomposer-libreoffice-output")
|
92
|
-
|
101
|
+
error_output = Tempfile.new("chupa-text-decomposer-libreoffice-error")
|
93
102
|
succeeded = @command.run("--headless",
|
94
103
|
"--nologo",
|
95
104
|
"--convert-to", "pdf",
|
@@ -98,35 +107,44 @@ module ChupaText
|
|
98
107
|
{
|
99
108
|
:spawn_options => {
|
100
109
|
:out => output.path,
|
101
|
-
:err =>
|
110
|
+
:err => error_output.path,
|
102
111
|
},
|
103
112
|
})
|
104
113
|
unless succeeded
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
114
|
+
error do
|
115
|
+
tag = "#{log_tag}[convert][exited][abnormally]"
|
116
|
+
[
|
117
|
+
tag,
|
118
|
+
"output: <#{output.read}>",
|
119
|
+
"error: <#{error_output.read}>",
|
120
|
+
].join("\n")
|
121
|
+
end
|
112
122
|
return nil
|
113
123
|
end
|
114
124
|
pdf_path, = Dir.glob("#{temporary_directory}/*.pdf")
|
115
125
|
if pdf_path.nil?
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
126
|
+
error do
|
127
|
+
tag = "#{log_tag}[convert][failed]"
|
128
|
+
message = [
|
129
|
+
"#{tag}: LibreOffice may be running",
|
130
|
+
"output: <#{output.read}>",
|
131
|
+
"error: <#{error_output.read}>",
|
132
|
+
].join("\n")
|
133
|
+
end
|
123
134
|
return nil
|
124
135
|
end
|
136
|
+
normalized_pdf_uri = data.uri.to_s.gsub(/\.[^.]+\z/, ".pdf")
|
125
137
|
File.open(pdf_path, "rb") do |pdf|
|
126
|
-
ChupaText::VirtualFileData.new(
|
138
|
+
ChupaText::VirtualFileData.new(normalized_pdf_uri,
|
139
|
+
pdf,
|
140
|
+
:source_data => data)
|
127
141
|
end
|
128
142
|
end
|
129
143
|
end
|
144
|
+
|
145
|
+
def log_tag
|
146
|
+
"[decomposer][libreoffice]"
|
147
|
+
end
|
130
148
|
end
|
131
149
|
end
|
132
150
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chupa-text-decomposer-libreoffice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chupa-text
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.9
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.9
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: chupa-text-decomposer-pdf
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
191
|
requirements:
|
178
192
|
- LibreOffice
|
179
193
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.7.6
|
181
195
|
signing_key:
|
182
196
|
specification_version: 4
|
183
197
|
summary: This is a ChupaText decomposer plugin for to extract text and meta-data from
|