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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 859ada0af7c396a080ec92336d58203ddcc87bbf1f82c3beb4f47db31eebed5b
4
- data.tar.gz: c3929b1cc964a3b97a8c7ce690ead7482c342a0296a210a013262aaf93955509
3
+ metadata.gz: 73c492c3a3f54ee4fe396212e0e485ba5a52e78aafdd83803613e39e13f248b7
4
+ data.tar.gz: a12b3cc6676ef4c9698d0c76d417c71264aac5ce9110986fccbaa7cf7e3c57a6
5
5
  SHA512:
6
- metadata.gz: f45d5a84b38180298864f8ec4829b2b21688205d8dfcf151390e426c9625bc0e453c182fac1b45553a798eec9c6bfb6a0a784c6b9fbcf18f558bee958396d8de
7
- data.tar.gz: a131e344ec4d9e2f79ef08a00673fd564ddbe986e39611beedb14e0e666cb401102338d0c12264302138bea6e29a760a674398e53977969c0f094dcac268d815
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.1"
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")
@@ -1,10 +1,16 @@
1
1
  # News
2
2
 
3
+ ## 1.0.2: 2019-06-18
4
+
5
+ ### Improvements
6
+
7
+ * Converted to text directly.
8
+
3
9
  ## 1.0.1: 2019-06-13
4
10
 
5
11
  ### Improvements
6
12
 
7
- * Increases score.
13
+ * Increases score.
8
14
 
9
15
  ## 1.0.0: 2019-06-13
10
16
 
@@ -66,30 +66,9 @@ module ChupaText
66
66
  end
67
67
 
68
68
  def decompose(data)
69
- pdf_data = convert_to_pdf(data)
70
- return if pdf_data.nil?
71
- yield(pdf_data)
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 nil
89
+ return
111
90
  end
112
- normalized_pdf_uri = data.uri.to_s.gsub(/\.[^.]+\z/, ".pdf")
113
- File.open(pdf.path, "rb") do |pdf_input|
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
- pdf = Tempfile.new([basename, ".pdf"])
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(pdf, stdout, stderr)
118
+ yield(text, stdout, stderr)
128
119
  ensure
129
- pdf.close!
120
+ text.close!
130
121
  stdout.close!
131
122
  stderr.close!
132
123
  end
@@ -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\n"], decompose.collect(&:body))
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
@@ -71,6 +71,7 @@ class TestDoc < Test::Unit::TestCase
71
71
  def test_body
72
72
  assert_equal([<<-BODY], decompose.collect(&:body))
73
73
  Page1
74
+ \f
74
75
  Page2
75
76
  BODY
76
77
  end
@@ -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\n"], decompose.collect(&:body))
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
- Page2
74
+ \fPage2
75
75
  BODY
76
76
  end
77
77
 
@@ -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\n"], decompose.collect(&:body))
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
@@ -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\n"], decompose.collect(&:body))
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
@@ -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\n"], decompose.collect(&:body))
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.1
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-13 00:00:00.000000000 Z
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