poleica 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/poleica/converters/graphics_magick.rb +1 -1
- data/lib/poleica/converters/libre_office.rb +1 -1
- data/lib/poleica/converters/utils.rb +14 -3
- data/lib/poleica/version.rb +1 -1
- data/test/poleica/converters/utils_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2JkOTZiMjQ2MmQ3Y2MyYmI3OTI2N2I2MWUzNDI5ZTM5YTE2MmZhOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzdmZDljYWRmMGFiNWJjNDZmMGJlMjE4NWE4YjljY2I5YTJiYjdlMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmNhMTE3YjQ3MjE4OTdhMjFlOTBiYjQyN2Y0ZmJhM2Y0YzU1ZDhiMDNlZjA1
|
10
|
+
MjNlZDEwNmFjM2RkMWY4OTRiNmI0OGE2Y2FmZThkMzdhY2ZkMDEzMDNjZGY2
|
11
|
+
MDIzZTNhOTM0NTU5MGYzZDgwNGFiNDQzODA1NjA3YmUzMTFjYjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzBkMGJmNjgxMmJiZTNhNDNiMWM0MGQwOTIwYTczODdmMTRiNGFhMjY5ZTZm
|
14
|
+
MDk2ZWMzNDU5Y2E4MjMwMGQ1YjFmM2M0NGUwMjU1N2FiODQ4NmYyMDk0ZWY0
|
15
|
+
OWM0MjYyMjNhNzY3MmQ5MTlkOWMxNWZmMTEyNTNhNWYwMTlmYTM=
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
[![Build Status](https://travis-ci.org/antoinelyset/poleica.png?branch=master)](https://travis-ci.org/antoinelyset/poleica)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/antoinelyset/Poleica/badge.png)](https://coveralls.io/r/antoinelyset/Poleica)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/antoinelyset/Poleica.png)](https://codeclimate.com/github/antoinelyset/Poleica)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/poleica.png)](http://badge.fury.io/rb/poleica)
|
7
8
|
[![Dependency Status](https://gemnasium.com/antoinelyset/Poleica.png)](https://gemnasium.com/antoinelyset/Poleica)
|
8
9
|
|
9
10
|
## Install
|
@@ -57,7 +58,7 @@ Poleica.new(file_path).to_png(width: 400, weight: 400)
|
|
57
58
|
|
58
59
|
## Dependencies
|
59
60
|
|
60
|
-
- GraphicsMagick (gm)
|
61
|
+
- GraphicsMagick (gm) >= 1.3.11
|
61
62
|
- LibreOffice
|
62
63
|
|
63
64
|
## Requirements
|
@@ -28,7 +28,7 @@ module Poleica
|
|
28
28
|
opts_gen = OptionsGenerator.new(polei, options)
|
29
29
|
cmd = "#{bin_path} convert "
|
30
30
|
cmd << "#{Utils.escape(polei.path)}#{opts_gen.generate}"
|
31
|
-
|
31
|
+
exec_with_timeout(cmd)
|
32
32
|
expected_file_path = opts_gen[:path]
|
33
33
|
File.exists?(expected_file_path) ? expected_file_path : nil
|
34
34
|
end
|
@@ -25,7 +25,7 @@ module Poleica
|
|
25
25
|
def to_pdf(options = {})
|
26
26
|
opts_gen = OptionsGenerator.new(polei, options, :pdf)
|
27
27
|
cmd = "#{bin_path} #{opts_gen.generate}"
|
28
|
-
|
28
|
+
exec_with_timeout(cmd)
|
29
29
|
expected_file_path = opts_gen[:path] || polei.path_with_md5(:pdf)
|
30
30
|
File.exists?(expected_file_path) ? expected_file_path : nil
|
31
31
|
ensure
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require 'digest/md5'
|
3
3
|
require 'shellwords'
|
4
|
+
require 'timeout'
|
4
5
|
|
5
6
|
module Poleica
|
6
7
|
module Converters
|
@@ -8,6 +9,8 @@ module Poleica
|
|
8
9
|
module Utils
|
9
10
|
HOST_OS ||= (defined?('RbConfig') ? RbConfig : Config)::CONFIG['host_os']
|
10
11
|
|
12
|
+
DEFAULT_TIMEOUT = 120
|
13
|
+
|
11
14
|
def windows?
|
12
15
|
!!HOST_OS.match(/mswin|windows|cygwin/i)
|
13
16
|
end
|
@@ -44,6 +47,14 @@ module Poleica
|
|
44
47
|
def escape(string)
|
45
48
|
Shellwords.shellescape(string)
|
46
49
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
|
51
|
+
def exec_with_timeout(cmd, timeout = DEFAULT_TIMEOUT, no_stdout = true)
|
52
|
+
cmd << ' >/dev/null' if no_stdout
|
53
|
+
pid = Process.spawn(cmd)
|
54
|
+
Timeout.timeout(timeout) { Process.wait(pid) }
|
55
|
+
rescue Timeout::Error
|
56
|
+
Process.kill('TERM', pid)
|
57
|
+
end
|
58
|
+
end # module Utils
|
59
|
+
end # module Converters
|
60
|
+
end # module Poleica
|
data/lib/poleica/version.rb
CHANGED
@@ -2,4 +2,10 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
# Test the Utils Converter Module
|
4
4
|
class UtilsTest < Minitest::Test
|
5
|
+
def test_exect_with_timeout
|
6
|
+
start_time = Time.now
|
7
|
+
Poleica::Converters::Utils.exec_with_timeout('sleep 2', 1)
|
8
|
+
duration = Time.now - start_time
|
9
|
+
assert(duration < 2)
|
10
|
+
end
|
5
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poleica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antoine Lyset
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|