chupa-text-decomposer-abiword 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 +4 -4
- data/chupa-text-decomposer-abiword.gemspec +1 -2
- data/doc/text/news.md +7 -1
- data/lib/chupa-text/decomposers/abiword.rb +24 -33
- data/test/test-abw.rb +3 -2
- data/test/test-doc.rb +1 -0
- data/test/test-docx.rb +3 -3
- data/test/test-odt.rb +3 -2
- data/test/test-rtf.rb +2 -2
- data/test/test-zabw.rb +3 -2
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c492c3a3f54ee4fe396212e0e485ba5a52e78aafdd83803613e39e13f248b7
|
4
|
+
data.tar.gz: a12b3cc6676ef4c9698d0c76d417c71264aac5ce9110986fccbaa7cf7e3c57a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b052e072e41e4d4b747e89530de8e96238a535b6f0876b1487b9ff663e1593dccad07e6a568f8b6be7ad6d87a38c44671e81bc08bcbb3631a1ea89394620e617
|
7
|
+
data.tar.gz: 1064b7375d5e05a9e10ca7ecb60b2fd39feb8dcde6d408c157f33c2216b93b3abd8f7da6910a694249bcdce62f1f793173b443959ee9f9af0d8706d8937868f4
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
|
23
23
|
Gem::Specification.new do |spec|
|
24
24
|
spec.name = "chupa-text-decomposer-abiword"
|
25
|
-
spec.version = "1.0.
|
25
|
+
spec.version = "1.0.2"
|
26
26
|
spec.homepage = "https://github.com/ranguba/chupa-text-decomposer-abiword"
|
27
27
|
spec.authors = ["Sutou Kouhei"]
|
28
28
|
spec.email = ["kou@clear-code.com"]
|
@@ -40,7 +40,6 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.files += Dir.glob("test/**/*")
|
41
41
|
|
42
42
|
spec.add_runtime_dependency("chupa-text")
|
43
|
-
spec.add_runtime_dependency("chupa-text-decomposer-pdf")
|
44
43
|
|
45
44
|
spec.add_development_dependency("bundler")
|
46
45
|
spec.add_development_dependency("rake")
|
data/doc/text/news.md
CHANGED
@@ -66,30 +66,9 @@ module ChupaText
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def decompose(data)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
def find_command
|
76
|
-
candidates = [
|
77
|
-
@options[:abiword],
|
78
|
-
ENV["ABIWORD"],
|
79
|
-
"abiword",
|
80
|
-
]
|
81
|
-
candidates.each do |candidate|
|
82
|
-
next if candidate.nil?
|
83
|
-
command = ExternalCommand.new(candidate)
|
84
|
-
return command if command.exist?
|
85
|
-
end
|
86
|
-
nil
|
87
|
-
end
|
88
|
-
|
89
|
-
def convert_to_pdf(data)
|
90
|
-
create_tempfiles(data) do |pdf, stdout, stderr|
|
91
|
-
succeeded = @command.run("--to", "pdf",
|
92
|
-
"--to-name", pdf.path,
|
69
|
+
create_tempfiles(data) do |text, stdout, stderr|
|
70
|
+
succeeded = @command.run("--to", "text",
|
71
|
+
"--to-name", text.path,
|
93
72
|
data.path.to_s,
|
94
73
|
{
|
95
74
|
data: data,
|
@@ -107,26 +86,38 @@ module ChupaText
|
|
107
86
|
"error: <#{stderr.read}>",
|
108
87
|
].join("\n")
|
109
88
|
end
|
110
|
-
return
|
89
|
+
return
|
111
90
|
end
|
112
|
-
|
113
|
-
|
114
|
-
VirtualFileData.new(normalized_pdf_uri,
|
115
|
-
pdf_input,
|
116
|
-
source_data: data)
|
91
|
+
File.open(text.path) do |text_input|
|
92
|
+
yield(TextData.new(text_input.read, source_data: data))
|
117
93
|
end
|
118
94
|
end
|
119
95
|
end
|
120
96
|
|
97
|
+
private
|
98
|
+
def find_command
|
99
|
+
candidates = [
|
100
|
+
@options[:abiword],
|
101
|
+
ENV["ABIWORD"],
|
102
|
+
"abiword",
|
103
|
+
]
|
104
|
+
candidates.each do |candidate|
|
105
|
+
next if candidate.nil?
|
106
|
+
command = ExternalCommand.new(candidate)
|
107
|
+
return command if command.exist?
|
108
|
+
end
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
|
121
112
|
def create_tempfiles(data)
|
122
113
|
basename = File.basename(data.path)
|
123
|
-
|
114
|
+
text = Tempfile.new([basename, ".txt"])
|
124
115
|
stdout = Tempfile.new([basename, ".stdout.log"])
|
125
116
|
stderr = Tempfile.new([basename, ".stderr.log"])
|
126
117
|
begin
|
127
|
-
yield(
|
118
|
+
yield(text, stdout, stderr)
|
128
119
|
ensure
|
129
|
-
|
120
|
+
text.close!
|
130
121
|
stdout.close!
|
131
122
|
stderr.close!
|
132
123
|
end
|
data/test/test-abw.rb
CHANGED
@@ -58,7 +58,7 @@ class TestAbw < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
sub_test_case("one page") do
|
60
60
|
def test_body
|
61
|
-
assert_equal(["Page1
|
61
|
+
assert_equal(["Page1"], decompose.collect(&:body))
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
@@ -69,8 +69,9 @@ class TestAbw < Test::Unit::TestCase
|
|
69
69
|
|
70
70
|
sub_test_case("multi pages") do
|
71
71
|
def test_body
|
72
|
-
assert_equal([<<-BODY], decompose.collect(&:body))
|
72
|
+
assert_equal([<<-BODY.chomp], decompose.collect(&:body))
|
73
73
|
Page1
|
74
|
+
\f
|
74
75
|
Page2
|
75
76
|
BODY
|
76
77
|
end
|
data/test/test-doc.rb
CHANGED
data/test/test-docx.rb
CHANGED
@@ -58,7 +58,7 @@ class TestDocx < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
sub_test_case("one page") do
|
60
60
|
def test_body
|
61
|
-
assert_equal(["Page1
|
61
|
+
assert_equal(["Page1"], decompose.collect(&:body))
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
@@ -69,9 +69,9 @@ class TestDocx < Test::Unit::TestCase
|
|
69
69
|
|
70
70
|
sub_test_case("multi pages") do
|
71
71
|
def test_body
|
72
|
-
assert_equal([<<-BODY], decompose.collect(&:body))
|
72
|
+
assert_equal([<<-BODY.chomp], decompose.collect(&:body))
|
73
73
|
Page1
|
74
|
-
|
74
|
+
\fPage2
|
75
75
|
BODY
|
76
76
|
end
|
77
77
|
|
data/test/test-odt.rb
CHANGED
@@ -58,7 +58,7 @@ class TestOdt < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
sub_test_case("one page") do
|
60
60
|
def test_body
|
61
|
-
assert_equal(["Page1
|
61
|
+
assert_equal(["Page1"], decompose.collect(&:body))
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
@@ -69,8 +69,9 @@ class TestOdt < Test::Unit::TestCase
|
|
69
69
|
|
70
70
|
sub_test_case("multi pages") do
|
71
71
|
def test_body
|
72
|
-
assert_equal([<<-BODY], decompose.collect(&:body))
|
72
|
+
assert_equal([<<-BODY.chomp], decompose.collect(&:body))
|
73
73
|
Page1
|
74
|
+
\f
|
74
75
|
Page2
|
75
76
|
BODY
|
76
77
|
end
|
data/test/test-rtf.rb
CHANGED
@@ -58,7 +58,7 @@ class TestRtf < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
sub_test_case("one page") do
|
60
60
|
def test_body
|
61
|
-
assert_equal(["Page1
|
61
|
+
assert_equal(["Page1"], decompose.collect(&:body))
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
@@ -69,7 +69,7 @@ class TestRtf < Test::Unit::TestCase
|
|
69
69
|
|
70
70
|
sub_test_case("multi pages") do
|
71
71
|
def test_body
|
72
|
-
assert_equal([<<-BODY], decompose.collect(&:body))
|
72
|
+
assert_equal([<<-BODY.chomp], decompose.collect(&:body))
|
73
73
|
Page1
|
74
74
|
Page2
|
75
75
|
BODY
|
data/test/test-zabw.rb
CHANGED
@@ -45,7 +45,7 @@ class TestZabw < Test::Unit::TestCase
|
|
45
45
|
|
46
46
|
sub_test_case("one page") do
|
47
47
|
def test_body
|
48
|
-
assert_equal(["Page1
|
48
|
+
assert_equal(["Page1"], decompose.collect(&:body))
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
@@ -56,8 +56,9 @@ class TestZabw < Test::Unit::TestCase
|
|
56
56
|
|
57
57
|
sub_test_case("multi pages") do
|
58
58
|
def test_body
|
59
|
-
assert_equal([<<-BODY], decompose.collect(&:body))
|
59
|
+
assert_equal([<<-BODY.chomp], decompose.collect(&:body))
|
60
60
|
Page1
|
61
|
+
\f
|
61
62
|
Page2
|
62
63
|
BODY
|
63
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chupa-text-decomposer-abiword
|
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
|
- Sutou Kouhei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chupa-text
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: chupa-text-decomposer-pdf
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|