libreconv 0.9.1 → 0.9.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
- SHA1:
3
- metadata.gz: 522fce89fe66792d062925292ab1104b4c4d4c7e
4
- data.tar.gz: 7c2f41f839955d1900417339bdf4be23833debaf
2
+ SHA256:
3
+ metadata.gz: 6c15c8557e480e6dff15a4c3fe8f3e5d9a9c6a46c43203df1def06fd7ddbb7fe
4
+ data.tar.gz: 41c3505b47c3de9dfe6ead9b965d0462fdc38e2afcf56b2454f9c2b3a583cfb6
5
5
  SHA512:
6
- metadata.gz: 8d9b40454b77418914765b032a54e6c41f1e995a28ac411d61f13f558ea14ce740ee7414a5b2e700bb3d7d8fb7467e30e461698e4add05e45d712fdd11178a3e
7
- data.tar.gz: 4913f63b22d7da58a2eec6a3f5f909e10a4f074e1cfe51d32a872b43a8ec7c604d44702ba4101af0c3a7c505706845b4a6ec3598f702c9e23328eb65e2e7a30a
6
+ metadata.gz: 2d28320784b82c47670bdde73138e664b073c94455327403dcd3e444157bdb093b0a2f3f93f8335703010c3237cae80c154cee42605842e7dd8275f877197758
7
+ data.tar.gz: 911898a953f283f81d957ab6aabf8a273038e0856f446baa5e9c133eaa0b6163cee24e968c7c03ccbd600677426680fc5ff49b54bd6161913081c91f79256913
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
data/.rubocop.yml ADDED
@@ -0,0 +1,25 @@
1
+ require: rubocop-rspec
2
+
3
+ Metrics/AbcSize:
4
+ # Max: 25
5
+ Enabled: false
6
+
7
+ Metrics/MethodLength:
8
+ # Max: 20
9
+ Enabled: false
10
+
11
+ Metrics/CyclomaticComplexity:
12
+ # Max: 10
13
+ Enabled: false
14
+
15
+ Metrics/BlockLength:
16
+ Enabled: false
17
+
18
+ Metrics/PerceivedComplexity:
19
+ Enabled: false
20
+
21
+ RSpec/ExampleLength:
22
+ Enabled: false
23
+
24
+ Style/Documentation:
25
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.3
data/.travis.yml CHANGED
@@ -1,10 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.1
4
- - 2.2.2
5
- notifications:
6
- recipients:
7
- - ricn@rny.io
3
+ - 2.2.0
4
+ - 2.5.3
8
5
  before_install:
9
6
  - sudo apt-get update -qq
10
7
  - sudo apt-get install libreoffice
data/Gemfile CHANGED
@@ -1,4 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in libreconv.gemspec
4
6
  gemspec
7
+
8
+ group :development, :test do
9
+ gem 'pry-byebug'
10
+ gem 'rubocop', require: false
11
+ gem 'rubocop-rspec', require: false
12
+ gem 'webmock'
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ libreconv (0.9.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.5.2)
10
+ public_suffix (>= 2.0.2, < 4.0)
11
+ ast (2.4.0)
12
+ byebug (10.0.2)
13
+ coderay (1.1.2)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
16
+ diff-lcs (1.3)
17
+ hashdiff (0.3.7)
18
+ jaro_winkler (1.5.1)
19
+ method_source (0.9.2)
20
+ parallel (1.12.1)
21
+ parser (2.5.3.0)
22
+ ast (~> 2.4.0)
23
+ powerpack (0.1.2)
24
+ pry (0.12.2)
25
+ coderay (~> 1.1.0)
26
+ method_source (~> 0.9.0)
27
+ pry-byebug (3.6.0)
28
+ byebug (~> 10.0)
29
+ pry (~> 0.10)
30
+ public_suffix (3.0.3)
31
+ rainbow (3.0.0)
32
+ rake (12.3.2)
33
+ rspec (3.8.0)
34
+ rspec-core (~> 3.8.0)
35
+ rspec-expectations (~> 3.8.0)
36
+ rspec-mocks (~> 3.8.0)
37
+ rspec-core (3.8.0)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-expectations (3.8.2)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-mocks (3.8.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.8.0)
45
+ rspec-support (3.8.0)
46
+ rubocop (0.61.1)
47
+ jaro_winkler (~> 1.5.1)
48
+ parallel (~> 1.10)
49
+ parser (>= 2.5, != 2.5.1.1)
50
+ powerpack (~> 0.1)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (~> 1.4.0)
54
+ rubocop-rspec (1.30.1)
55
+ rubocop (>= 0.60.0)
56
+ ruby-progressbar (1.10.0)
57
+ safe_yaml (1.0.4)
58
+ unicode-display_width (1.4.0)
59
+ webmock (3.4.2)
60
+ addressable (>= 2.3.6)
61
+ crack (>= 0.3.2)
62
+ hashdiff
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ bundler
69
+ libreconv!
70
+ pry-byebug
71
+ rake
72
+ rspec (~> 3.8.0)
73
+ rubocop
74
+ rubocop-rspec
75
+ webmock
76
+
77
+ BUNDLED WITH
78
+ 1.17.1
data/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  Convert office documents using LibreOffice / OpenOffice to one of their supported formats.
4
4
 
5
- [![Code Climate](https://codeclimate.com/github/ricn/libreconv.png)](https://codeclimate.com/github/ricn/libreconv)
6
- [![Build Status](https://travis-ci.org/ricn/libreconv.png?branch=master)](https://travis-ci.org/ricn/libreconv)
5
+ [![Build Status](https://travis-ci.org/FormAPI/libreconv.png?branch=master)](https://travis-ci.org/FormAPI/libreconv)
7
6
  [![Gem Version](https://badge.fury.io/rb/libreconv.svg)](http://badge.fury.io/rb/libreconv)
8
7
 
9
8
  ## Installation
@@ -22,7 +21,7 @@ Or install it yourself as:
22
21
 
23
22
  ## Usage
24
23
 
25
- You need to install Libreoffice or Openoffice on your system to use this gem. The code has been tested with Libreoffice 4.2.
24
+ You need to install Libreoffice or Openoffice on your system to use this gem. The code has been tested with Libreoffice 6.1.3.
26
25
 
27
26
  ```ruby
28
27
  require 'libreconv'
@@ -38,6 +37,9 @@ Libreconv.convert('document.docx', '/Users/ricn/pdf_documents')
38
37
  # You can also convert a source file directly from an URL
39
38
  Libreconv.convert('http://myserver.com/123/document.docx', '/Users/ricn/pdf_documents/doc.pdf')
40
39
 
40
+ # You cal pass a URL with GET params like this S3 example
41
+ Libreconv.convert('https://mybucket.s3.amazonaws.com/myserver/123/document.docx?X-Amz-Expires=456&X-Amz-Signature=abc', '/Users/ricn/pdf_documents/doc.pdf')
42
+
41
43
  # Converts document.docx to document.pdf
42
44
  # If you for some reason can't have soffice in your PATH you can specifiy the file path to the soffice binary
43
45
  Libreconv.convert('document.docx', '/Users/ricn/pdf_documents', '/Applications/LibreOffice.app/Contents/MacOS/soffice')
@@ -55,9 +57,13 @@ Libreconv.convert('document.docx', '/Users/ricn/pdf_documents/my_document_as.pdf
55
57
  The following people have contributed ideas, documentation, or code to Libreconv:
56
58
 
57
59
  * Richard Nyström
60
+ * Nathan Broadbent
58
61
 
59
62
  ## Contributing
60
63
 
64
+ * Install LibreOffice on Linux: `sudo apt-get install libreoffice`
65
+ * Install LibreOffice on Mac: `brew cask install libreoffice`
66
+
61
67
  1. Fork it
62
68
  2. Create your feature branch (`git checkout -b my-new-feature`)
63
69
  3. Commit your changes (`git commit -am 'Add some feature'`)
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/lib/libreconv.rb CHANGED
@@ -1,10 +1,19 @@
1
- require "libreconv/version"
2
- require "uri"
3
- require "net/http"
4
- require "tmpdir"
5
- require "spoon"
1
+ # frozen_string_literal: true
2
+
3
+ require 'libreconv/version'
4
+ require 'uri'
5
+ require 'net/http'
6
+ require 'tmpdir'
7
+ require 'securerandom'
8
+ require 'open3'
6
9
 
7
10
  module Libreconv
11
+ class ConversionFailedError < StandardError; end
12
+
13
+ SOURCE_TYPES = {
14
+ file: 1,
15
+ url: 2
16
+ }.freeze
8
17
 
9
18
  def self.convert(source, target, soffice_command = nil, convert_to = nil)
10
19
  Converter.new(source, target, soffice_command, convert_to).convert
@@ -16,34 +25,84 @@ module Libreconv
16
25
  def initialize(source, target, soffice_command = nil, convert_to = nil)
17
26
  @source = source
18
27
  @target = target
19
- @target_path = Dir.tmpdir
20
- @soffice_command = soffice_command
21
- @convert_to = convert_to || "pdf"
22
- determine_soffice_command
23
- check_source_type
24
-
25
- unless @soffice_command && File.exists?(@soffice_command)
26
- raise IOError, "Can't find Libreoffice or Openoffice executable."
27
- end
28
+ @soffice_command =
29
+ soffice_command ||
30
+ which('soffice') ||
31
+ which('soffice.bin')
32
+ @convert_to = convert_to || 'pdf'
33
+ @source_type = check_source_type
34
+
35
+ # If the URL contains GET params, the '&' could break when
36
+ # being used as an argument to soffice. Wrap it in single
37
+ # quotes to escape it. Then strip them from the target
38
+ # temp file name.
39
+ @escaped_source =
40
+ if @source_type == 1
41
+ @source
42
+ else
43
+ "'#{@source}'"
44
+ end
45
+ @escaped_source_path =
46
+ if @source_type == 1
47
+ @source
48
+ else
49
+ URI.parse(@source).path
50
+ end
51
+
52
+ ensure_soffice_exists
28
53
  end
29
54
 
30
55
  def convert
31
- orig_stdout = $stdout.clone
32
- $stdout.reopen File.new('/dev/null', 'w')
33
- pid = Spoon.spawnp(@soffice_command, "--headless", "--convert-to", @convert_to, @source, "--outdir", @target_path)
34
- Process.waitpid(pid)
35
- $stdout.reopen orig_stdout
36
- target_tmp_file = "#{@target_path}/#{File.basename(@source, ".*")}.#{File.basename(@convert_to, ":*")}"
37
- FileUtils.cp target_tmp_file, @target
56
+ pipe_uuid = SecureRandom.uuid
57
+
58
+ Dir.mktmpdir do |target_path|
59
+ accept_args = [
60
+ "pipe,name=soffice-pipe-#{pipe_uuid}",
61
+ 'url',
62
+ 'StarOffice.ServiceManager'
63
+ ].join(';')
64
+
65
+ command = [
66
+ soffice_command,
67
+ "--accept=\"#{accept_args}\"",
68
+ "-env:UserInstallation=file:///tmp/soffice-dir-#{pipe_uuid}",
69
+ '--headless',
70
+ '--convert-to',
71
+ @convert_to,
72
+ @escaped_source,
73
+ '--outdir',
74
+ target_path
75
+ ]
76
+
77
+ output, error, status = Open3.capture3(
78
+ {
79
+ 'HOME' => ENV['HOME'],
80
+ 'PATH' => ENV['PATH'],
81
+ 'LANG' => ENV['LANG']
82
+ },
83
+ *command,
84
+ unsetenv_others: true
85
+ )
86
+ unless status.success? && error == ''
87
+ raise ConversionFailedError,
88
+ "Conversion failed! Output: #{output.strip.inspect}, " \
89
+ "Error: #{error.strip.inspect}"
90
+ end
91
+
92
+ target_tmp_file = "#{target_path}/" \
93
+ "#{File.basename(@escaped_source_path, '.*')}." \
94
+ "#{File.basename(@convert_to, ':*')}"
95
+ FileUtils.cp target_tmp_file, @target
96
+ FileUtils.rm_rf("/tmp/soffice-dir-#{pipe_uuid}")
97
+ end
38
98
  end
39
99
 
40
100
  private
41
101
 
42
- def determine_soffice_command
43
- unless @soffice_command
44
- @soffice_command ||= which("soffice")
45
- @soffice_command ||= which("soffice.bin")
46
- end
102
+ def ensure_soffice_exists
103
+ return if soffice_command && File.exist?(soffice_command)
104
+
105
+ raise IOError, "Can't find Libreoffice or Openoffice executable."
47
106
  end
48
107
 
49
108
  def which(cmd)
@@ -55,14 +114,23 @@ module Libreconv
55
114
  end
56
115
  end
57
116
 
58
- return nil
117
+ nil
59
118
  end
60
119
 
61
120
  def check_source_type
62
- return if File.exists?(@source) && !File.directory?(@source) #file
63
- return if URI(@source).scheme == "http" && Net::HTTP.get_response(URI(@source)).is_a?(Net::HTTPSuccess) #http
64
- return if URI(@source).scheme == "https" && Net::HTTP.get_response(URI(@source)).is_a?(Net::HTTPSuccess) #https
65
- raise IOError, "Source (#{@source}) is neither a file nor an URL."
121
+ if File.exist?(@source) && !File.directory?(@source)
122
+ return SOURCE_TYPES[:file]
123
+ end
124
+ if URI(@source).scheme == 'http' &&
125
+ Net::HTTP.get_response(URI(@source)).is_a?(Net::HTTPSuccess)
126
+ return SOURCE_TYPES[:url]
127
+ end
128
+ if URI(@source).scheme == 'https' &&
129
+ Net::HTTP.get_response(URI(@source)).is_a?(Net::HTTPSuccess)
130
+ return SOURCE_TYPES[:url]
131
+ end
132
+
133
+ raise IOError, "Source (#{@source}) is neither a file nor a URL."
66
134
  end
67
135
  end
68
- end
136
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Libreconv
2
- VERSION = "0.9.1"
4
+ VERSION = '0.9.2'
3
5
  end
data/libreconv.gemspec CHANGED
@@ -1,24 +1,24 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'libreconv/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "libreconv"
8
+ spec.name = 'libreconv'
8
9
  spec.version = Libreconv::VERSION
9
- spec.authors = ["Richard Nyström"]
10
- spec.email = ["ricny046@gmail.com"]
11
- spec.description = %q{ Convert office documents to PDF using LibreOffice. }
12
- spec.summary = %q{ Convert office documents to PDF. }
13
- spec.homepage = "https://github.com/ricn/libreconv"
14
- spec.license = "MIT"
10
+ spec.authors = ['Richard Nyström', 'Nathan Broadbent']
11
+ spec.email = ['nathan@formapi.io']
12
+ spec.description = 'Convert office documents to PDF using LibreOffice.'
13
+ spec.summary = 'Convert office documents to PDF.'
14
+ spec.homepage = 'https://github.com/FormAPI/libreconv'
15
+ spec.license = 'MIT'
15
16
 
16
- spec.files = `git ls-files`.split($/)
17
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
- spec.add_dependency "spoon"
21
- spec.add_development_dependency "bundler", ">= 0"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", "~> 3.2.0"
20
+ spec.require_paths = ['lib']
21
+ spec.add_development_dependency 'bundler', '>= 0'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec', '~> 3.8.0'
24
24
  end
@@ -1,100 +1,111 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  describe Libreconv do
6
+ let(:docx_file) { fixture_path('docx.docx') }
7
+ let(:doc_file) { fixture_path('doc.doc') }
8
+ let(:pptx_file) { fixture_path('pptx.pptx') }
9
+ let(:ppt_file) { fixture_path('ppt.ppt') }
10
+ let(:target_path) { '/tmp/libreconv' }
11
+ let(:url) { 'http://s3.amazonaws.com/libreconv-test/docx.docx' }
5
12
 
6
- before(:all) do
7
- @docx_file = file_path("docx.docx")
8
- @doc_file = file_path("doc.doc")
9
- @pptx_file = file_path("pptx.pptx")
10
- @ppt_file = file_path("ppt.ppt")
11
- @target_path = "/tmp/libreconv"
12
- @url = "http://s3.amazonaws.com/libreconv-test/docx.docx"
13
- end
14
-
15
- before(:each) do
16
- FileUtils.mkdir_p @target_path
13
+ before do
14
+ FileUtils.mkdir_p target_path
17
15
  end
18
16
 
19
- after(:each) do
20
- FileUtils.rm_rf @target_path
17
+ after do
18
+ FileUtils.rm_rf target_path
21
19
  end
22
20
 
23
21
  describe Libreconv::Converter do
24
- describe "#new" do
25
- it "should raise error if soffice command does not exists" do
26
- expect { Libreconv::Converter.new(@doc_file, "/target", "/Whatever/soffice") }.to raise_error(IOError)
22
+ describe '#new' do
23
+ it 'raises error if soffice command does not exists' do
24
+ expect do
25
+ Libreconv::Converter.new(
26
+ doc_file, '/target', '/Whatever/soffice'
27
+ )
28
+ end.to raise_error(IOError)
27
29
  end
28
30
 
29
- it "should raise error if source does not exists" do
30
- expect { Libreconv::Converter.new(file_path("nonsense.txt"), "/target") }.to raise_error(IOError)
31
+ it 'raises error if source does not exists' do
32
+ expect do
33
+ Libreconv::Converter.new(
34
+ fixture_path('nonsense.txt'), '/target'
35
+ )
36
+ end.to raise_error(IOError)
31
37
  end
32
38
  end
33
39
 
34
- describe "#convert" do
35
- it "should convert a docx do pdf specifying target_file" do
36
- target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
37
- converter = Libreconv::Converter.new(@doc_file, target_file)
40
+ describe '#convert' do
41
+ it 'converts a docx do pdf specifying target_file' do
42
+ target_file = "#{target_path}/#{File.basename(doc_file, '.doc')}.pdf"
43
+ converter = Libreconv::Converter.new(doc_file, target_file)
38
44
  converter.convert
39
45
  expect(File.file?(target_file)).to eq true
40
46
  end
41
47
 
42
- it "should convert a doc to pdf" do
43
- target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
44
- converter = Libreconv::Converter.new(@doc_file, @target_path)
48
+ it 'converts a doc to pdf' do
49
+ target_file = "#{target_path}/#{File.basename(doc_file, '.doc')}.pdf"
50
+ converter = Libreconv::Converter.new(doc_file, target_path)
45
51
  converter.convert
46
52
  expect(File.file?(target_file)).to eq true
47
53
  end
48
54
 
49
- it "should convert a docx to pdf" do
50
- target_file = "#{@target_path}/#{File.basename(@docx_file, ".docx")}.pdf"
51
- converter = Libreconv::Converter.new(@docx_file, @target_path)
55
+ it 'converts a docx to pdf' do
56
+ target_file = "#{target_path}/#{File.basename(docx_file, '.docx')}.pdf"
57
+ converter = Libreconv::Converter.new(docx_file, target_path)
52
58
  converter.convert
53
59
  expect(File.file?(target_file)).to eq true
54
60
  end
55
61
 
56
- it "should convert a pptx to pdf" do
57
- target_file = "#{@target_path}/#{File.basename(@pptx_file, ".pptx")}.pdf"
58
- converter = Libreconv::Converter.new(@pptx_file, @target_path)
62
+ it 'converts a pptx to pdf' do
63
+ target_file = "#{target_path}/#{File.basename(pptx_file, '.pptx')}.pdf"
64
+ converter = Libreconv::Converter.new(pptx_file, target_path)
59
65
  converter.convert
60
66
  expect(File.file?(target_file)).to eq true
61
67
  end
62
68
 
63
- it "should convert a ppt to pdf" do
64
- target_file = "#{@target_path}/#{File.basename(@ppt_file, ".ppt")}.pdf"
65
- converter = Libreconv::Converter.new(@ppt_file, @target_path)
69
+ it 'converts a ppt to pdf' do
70
+ target_file = "#{target_path}/#{File.basename(ppt_file, '.ppt')}.pdf"
71
+ converter = Libreconv::Converter.new(ppt_file, target_path)
66
72
  converter.convert
67
73
  expect(File.file?(target_file)).to eq true
68
74
  end
69
75
 
70
- it "should convert a docx to pdf specifying an URL as source" do
71
- target_file = "#{@target_path}/docx.pdf"
72
- converter = Libreconv::Converter.new(@url, @target_path)
73
- converter.convert
74
- expect(File.file?(target_file)).to eq true
75
- end
76
+ # it 'raises ConversionFailedError when URL cannot be loaded' do
77
+ # stub_request(:get, url)
78
+ # expect do
79
+ # converter = Libreconv::Converter.new(url, target_path)
80
+ # converter.convert
81
+ # end.to raise_error(
82
+ # Libreconv::ConversionFailedError,
83
+ # /Conversion failed/
84
+ # )
85
+ # end
76
86
  end
77
87
 
78
- describe "#soffice_command" do
79
- it "should return the user specified command path" do
80
- cmd = file_path("soffice") # just faking that the command is present here
81
- converter = Libreconv::Converter.new(@doc_file, "/target", cmd)
88
+ describe '#soffice_command' do
89
+ it 'returns the user specified command path' do
90
+ # Just faking that the command is present here
91
+ cmd = fixture_path('soffice')
92
+ converter = Libreconv::Converter.new(doc_file, '/target', cmd)
82
93
  expect(converter.soffice_command).to eq cmd
83
94
  end
84
95
 
85
- it "should return the command found in path" do
96
+ it 'returns the command found in path' do
86
97
  cmd = `which soffice`.strip
87
- converter = Libreconv::Converter.new(@doc_file, "/target")
98
+ converter = Libreconv::Converter.new(doc_file, '/target')
88
99
  expect(converter.soffice_command).to eq cmd
89
100
  end
90
101
  end
102
+ end
91
103
 
92
- describe ".convert" do
93
- it "should convert a file to pdf" do
94
- target_file = "#{@target_path}/#{File.basename(@doc_file, ".doc")}.pdf"
95
- Libreconv.convert(@doc_file, @target_path)
96
- expect(File.file?(target_file)).to eq true
97
- end
104
+ describe '#convert' do
105
+ it 'converts a file to pdf' do
106
+ target_file = "#{target_path}/#{File.basename(doc_file, '.doc')}.pdf"
107
+ described_class.convert(doc_file, target_path)
108
+ expect(File.file?(target_file)).to eq true
98
109
  end
99
110
  end
100
111
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'libreconv'
4
+ require 'pry-byebug'
5
+ require 'webmock/rspec'
2
6
 
3
- def file_path( *paths )
7
+ def fixture_path(*paths)
4
8
  File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', *paths))
5
9
  end
6
10
 
metadata CHANGED
@@ -1,82 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libreconv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Nyström
8
+ - Nathan Broadbent
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
12
+ date: 2019-06-07 00:00:00.000000000 Z
12
13
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: spoon
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
14
  - !ruby/object:Gem::Dependency
28
15
  name: bundler
29
16
  requirement: !ruby/object:Gem::Requirement
30
17
  requirements:
31
- - - '>='
18
+ - - ">="
32
19
  - !ruby/object:Gem::Version
33
20
  version: '0'
34
21
  type: :development
35
22
  prerelease: false
36
23
  version_requirements: !ruby/object:Gem::Requirement
37
24
  requirements:
38
- - - '>='
25
+ - - ">="
39
26
  - !ruby/object:Gem::Version
40
27
  version: '0'
41
28
  - !ruby/object:Gem::Dependency
42
29
  name: rake
43
30
  requirement: !ruby/object:Gem::Requirement
44
31
  requirements:
45
- - - '>='
32
+ - - ">="
46
33
  - !ruby/object:Gem::Version
47
34
  version: '0'
48
35
  type: :development
49
36
  prerelease: false
50
37
  version_requirements: !ruby/object:Gem::Requirement
51
38
  requirements:
52
- - - '>='
39
+ - - ">="
53
40
  - !ruby/object:Gem::Version
54
41
  version: '0'
55
42
  - !ruby/object:Gem::Dependency
56
43
  name: rspec
57
44
  requirement: !ruby/object:Gem::Requirement
58
45
  requirements:
59
- - - ~>
46
+ - - "~>"
60
47
  - !ruby/object:Gem::Version
61
- version: 3.2.0
48
+ version: 3.8.0
62
49
  type: :development
63
50
  prerelease: false
64
51
  version_requirements: !ruby/object:Gem::Requirement
65
52
  requirements:
66
- - - ~>
53
+ - - "~>"
67
54
  - !ruby/object:Gem::Version
68
- version: 3.2.0
69
- description: ' Convert office documents to PDF using LibreOffice. '
55
+ version: 3.8.0
56
+ description: Convert office documents to PDF using LibreOffice.
70
57
  email:
71
- - ricny046@gmail.com
58
+ - nathan@formapi.io
72
59
  executables: []
73
60
  extensions: []
74
61
  extra_rdoc_files: []
75
62
  files:
76
- - .gitignore
77
- - .rspec
78
- - .travis.yml
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - ".ruby-version"
67
+ - ".travis.yml"
79
68
  - Gemfile
69
+ - Gemfile.lock
80
70
  - LICENSE.txt
81
71
  - README.md
82
72
  - Rakefile
@@ -90,7 +80,7 @@ files:
90
80
  - spec/fixtures/soffice
91
81
  - spec/libreconv_spec.rb
92
82
  - spec/spec_helper.rb
93
- homepage: https://github.com/ricn/libreconv
83
+ homepage: https://github.com/FormAPI/libreconv
94
84
  licenses:
95
85
  - MIT
96
86
  metadata: {}
@@ -100,17 +90,17 @@ require_paths:
100
90
  - lib
101
91
  required_ruby_version: !ruby/object:Gem::Requirement
102
92
  requirements:
103
- - - '>='
93
+ - - ">="
104
94
  - !ruby/object:Gem::Version
105
95
  version: '0'
106
96
  required_rubygems_version: !ruby/object:Gem::Requirement
107
97
  requirements:
108
- - - '>='
98
+ - - ">="
109
99
  - !ruby/object:Gem::Version
110
100
  version: '0'
111
101
  requirements: []
112
102
  rubyforge_project:
113
- rubygems_version: 2.0.14
103
+ rubygems_version: 2.7.8
114
104
  signing_key:
115
105
  specification_version: 4
116
106
  summary: Convert office documents to PDF.