libreconv 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/libreconv.rb +7 -7
- data/lib/libreconv/version.rb +1 -1
- data/libreconv.gemspec +3 -3
- data/spec/libreconv_spec.rb +20 -20
- data/spec/spec_helper.rb +1 -2
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14a16a3e394c4ba9f9d7f69656286f2cdd309a07
|
4
|
+
data.tar.gz: f2768dd2c7905a798f24b62e107270430f37dd57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07d5b921a16008271f6a4eaf5ed074279e3ab47199fe694ab5b96d9608e8f322f4c4297a1f3119c436bb2701c16a691050a29ce9efbeca4fa24c4991e2a9b676
|
7
|
+
data.tar.gz: 04805b8bf5fd94960161f22c2d9635ddb8361990059e18fdfb2d61758ead3030292c16b261550c28ece1531739e930dbf564bd7da39400c3eb4aa56a7b605c17
|
data/.travis.yml
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
You need to install Libreoffice or Openoffice on your system to use this gem. The code has been tested with Libreoffice 4.
|
24
|
+
You need to install Libreoffice or Openoffice on your system to use this gem. The code has been tested with Libreoffice 4.2.
|
25
25
|
|
26
26
|
```ruby
|
27
27
|
require 'libreconv'
|
data/lib/libreconv.rb
CHANGED
@@ -17,11 +17,11 @@ module Libreconv
|
|
17
17
|
@source = source
|
18
18
|
@target = target
|
19
19
|
@target_path = Dir.tmpdir
|
20
|
-
@soffice_command = soffice_command
|
20
|
+
@soffice_command = soffice_command
|
21
21
|
determine_soffice_command
|
22
22
|
check_source_type
|
23
|
-
|
24
|
-
unless @soffice_command && File.exists?(@soffice_command)
|
23
|
+
|
24
|
+
unless @soffice_command && File.exists?(@soffice_command)
|
25
25
|
raise IOError, "Can't find Libreoffice or Openoffice executable."
|
26
26
|
end
|
27
27
|
end
|
@@ -29,7 +29,7 @@ module Libreconv
|
|
29
29
|
def convert
|
30
30
|
orig_stdout = $stdout.clone
|
31
31
|
$stdout.reopen File.new('/dev/null', 'w')
|
32
|
-
pid = Spoon.spawnp(@soffice_command, "--headless", "--convert-to", "pdf", @source, "
|
32
|
+
pid = Spoon.spawnp(@soffice_command, "--headless", "--convert-to", "pdf", @source, "--outdir", @target_path)
|
33
33
|
Process.waitpid(pid)
|
34
34
|
$stdout.reopen orig_stdout
|
35
35
|
target_tmp_file = "#{@target_path}/#{File.basename(@source, ".*")}.pdf"
|
@@ -53,15 +53,15 @@ module Libreconv
|
|
53
53
|
return exe if File.executable? exe
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
return nil
|
58
58
|
end
|
59
59
|
|
60
60
|
def check_source_type
|
61
61
|
is_file = File.exists?(@source) && !File.directory?(@source)
|
62
62
|
is_http = URI(@source).scheme == "http" && Net::HTTP.get_response(URI(@source)).is_a?(Net::HTTPSuccess)
|
63
|
-
is_https = URI(@source).scheme == "https" && Net::HTTP.get_response(URI(@source)).is_a?(Net::HTTPSuccess)
|
63
|
+
is_https = URI(@source).scheme == "https" && Net::HTTP.get_response(URI(@source)).is_a?(Net::HTTPSuccess)
|
64
64
|
raise IOError, "Source (#{@source}) is neither a file nor an URL." unless is_file || is_http || is_https
|
65
65
|
end
|
66
66
|
end
|
67
|
-
end
|
67
|
+
end
|
data/lib/libreconv/version.rb
CHANGED
data/libreconv.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
spec.add_dependency "spoon"
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6.0.rc2"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
|
-
end
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0.0.rc1"
|
24
|
+
end
|
data/spec/libreconv_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Libreconv do
|
5
|
-
|
3
|
+
|
4
|
+
describe Libreconv do
|
5
|
+
|
6
6
|
before(:all) do
|
7
7
|
@docx_file = file_path("docx.docx")
|
8
8
|
@doc_file = file_path("doc.doc")
|
@@ -23,11 +23,11 @@ describe Libreconv do
|
|
23
23
|
describe Libreconv::Converter do
|
24
24
|
describe "#new" do
|
25
25
|
it "should raise error if soffice command does not exists" do
|
26
|
-
|
26
|
+
expect { Libreconv::Converter.new(@doc_file, "/target", "/Whatever/soffice") }.to raise_error(IOError)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should raise error if source does not exists" do
|
30
|
-
|
30
|
+
expect { Libreconv::Converter.new(file_path("nonsense.txt"), "/target") }.to raise_error(IOError)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -36,42 +36,42 @@ describe Libreconv do
|
|
36
36
|
target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
|
37
37
|
converter = Libreconv::Converter.new(@doc_file, target_file)
|
38
38
|
converter.convert
|
39
|
-
File.file?(target_file).
|
39
|
+
expect(File.file?(target_file)).to eq true
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should convert a doc to pdf" do
|
43
|
-
target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
|
43
|
+
target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
|
44
44
|
converter = Libreconv::Converter.new(@doc_file, @target_path)
|
45
45
|
converter.convert
|
46
|
-
File.file?(target_file).
|
46
|
+
expect(File.file?(target_file)).to eq true
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should convert a docx to pdf" do
|
50
|
-
target_file = "#{@target_path}/#{File.basename(@docx_file, ".docx")}.pdf"
|
50
|
+
target_file = "#{@target_path}/#{File.basename(@docx_file, ".docx")}.pdf"
|
51
51
|
converter = Libreconv::Converter.new(@docx_file, @target_path)
|
52
52
|
converter.convert
|
53
|
-
File.file?(target_file).
|
53
|
+
expect(File.file?(target_file)).to eq true
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should convert a pptx to pdf" do
|
57
|
-
target_file = "#{@target_path}/#{File.basename(@pptx_file, ".pptx")}.pdf"
|
57
|
+
target_file = "#{@target_path}/#{File.basename(@pptx_file, ".pptx")}.pdf"
|
58
58
|
converter = Libreconv::Converter.new(@pptx_file, @target_path)
|
59
59
|
converter.convert
|
60
|
-
File.file?(target_file).
|
60
|
+
expect(File.file?(target_file)).to eq true
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should convert a ppt to pdf" do
|
64
|
-
target_file = "#{@target_path}/#{File.basename(@ppt_file, ".ppt")}.pdf"
|
64
|
+
target_file = "#{@target_path}/#{File.basename(@ppt_file, ".ppt")}.pdf"
|
65
65
|
converter = Libreconv::Converter.new(@ppt_file, @target_path)
|
66
66
|
converter.convert
|
67
|
-
File.file?(target_file).
|
67
|
+
expect(File.file?(target_file)).to eq true
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should convert a docx to pdf specifying an URL as source" do
|
71
71
|
target_file = "#{@target_path}/docx.pdf"
|
72
72
|
converter = Libreconv::Converter.new(@url, @target_path)
|
73
73
|
converter.convert
|
74
|
-
File.file?(target_file).
|
74
|
+
expect(File.file?(target_file)).to eq true
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -79,22 +79,22 @@ describe Libreconv do
|
|
79
79
|
it "should return the user specified command path" do
|
80
80
|
cmd = file_path("soffice") # just faking that the command is present here
|
81
81
|
converter = Libreconv::Converter.new(@doc_file, "/target", cmd)
|
82
|
-
converter.soffice_command.
|
82
|
+
expect(converter.soffice_command).to eq cmd
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should return the command found in path" do
|
86
86
|
cmd = `which soffice`.strip
|
87
87
|
converter = Libreconv::Converter.new(@doc_file, "/target")
|
88
|
-
converter.soffice_command.
|
88
|
+
expect(converter.soffice_command).to eq cmd
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe ".convert" do
|
93
93
|
it "should convert a file to pdf" do
|
94
|
-
target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
|
94
|
+
target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
|
95
95
|
Libreconv.convert(@doc_file, @target_path)
|
96
|
-
File.file?(target_file).
|
96
|
+
expect(File.file?(target_file)).to eq true
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
|
-
end
|
100
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,81 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libreconv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Nyström
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spoon
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
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
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.6.0.rc2
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.6.0.rc2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.0.0.rc1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
68
|
+
version: 3.0.0.rc1
|
69
|
+
description: " Convert office documents to PDF using LibreOffice. "
|
70
70
|
email:
|
71
71
|
- ricny046@gmail.com
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rspec
|
78
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
@@ -100,17 +100,17 @@ require_paths:
|
|
100
100
|
- lib
|
101
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.2.2
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Convert office documents to PDF.
|