poleica 0.10.0 → 0.10.1.fix1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.travis.yml +11 -6
- data/Gemfile +2 -2
- data/Gemfile.lock +63 -71
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/poleica/converters/convertible.rb +4 -4
- data/lib/poleica/converters/general.rb +1 -1
- data/lib/poleica/converters/graphics_magick/convert_options_generator.rb +6 -9
- data/lib/poleica/converters/graphics_magick/thumbnail_options_generator.rb +6 -9
- data/lib/poleica/converters/libre_office.rb +15 -22
- data/lib/poleica/converters/utils.rb +7 -8
- data/lib/poleica/types/document.rb +1 -1
- data/lib/poleica/types/general.rb +1 -1
- data/lib/poleica/types/image.rb +1 -1
- data/lib/poleica/types/pdf.rb +1 -1
- data/lib/poleica/version.rb +1 -1
- data/test/test_helper.rb +2 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d83d3535fc8767e224ae910c97e2920ebdb1e0
|
4
|
+
data.tar.gz: d1d946ba9b11059b9660fbcf400f130b73677868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf65f99778e581a3254379e8cfbde2f9ec6ca56f3bdfdc95ddf611f87bc949e76379b53e8bf0bb5c43bec69fb2caae6615f09ee1ff0a1168a0480da2f8612b4
|
7
|
+
data.tar.gz: 8e332e264e5795b071800806b053b77bf65bec3d341e76d5b54fbd4f37a5d832dc55fab23d2c741900fb4f52512097e1b4bc405855d2c787ea3441ed738ea6f6
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -2,15 +2,17 @@ language: ruby
|
|
2
2
|
bundler_args: --without development
|
3
3
|
rvm:
|
4
4
|
- 1.9.3
|
5
|
-
- 2.
|
6
|
-
-
|
5
|
+
- 2.1
|
6
|
+
- 2.0
|
7
|
+
- 2.2
|
8
|
+
- rbx-2
|
7
9
|
- jruby-19mode
|
8
10
|
before_script:
|
9
11
|
- sudo apt-get update -qq
|
10
12
|
- sudo apt-get install -qq libreoffice
|
11
|
-
- wget http://78.108.103.11/MIRROR/ftp/GraphicsMagick/1.3/GraphicsMagick-1.3.
|
12
|
-
- tar -xvf GraphicsMagick-1.3.
|
13
|
-
- cd GraphicsMagick-1.3.
|
13
|
+
- wget http://78.108.103.11/MIRROR/ftp/GraphicsMagick/1.3/GraphicsMagick-1.3.20.tar.gz
|
14
|
+
- tar -xvf GraphicsMagick-1.3.20.tar.gz
|
15
|
+
- cd GraphicsMagick-1.3.20
|
14
16
|
- ./configure
|
15
17
|
- make
|
16
18
|
- sudo make install
|
@@ -20,7 +22,10 @@ script:
|
|
20
22
|
matrix:
|
21
23
|
fast_finish: true
|
22
24
|
allow_failures:
|
25
|
+
- rvm: rbx-2
|
23
26
|
- rvm: jruby-19mode
|
24
|
-
- rvm: rbx-19mode
|
25
27
|
notifications:
|
26
28
|
email: false
|
29
|
+
addons:
|
30
|
+
code_climate:
|
31
|
+
repo_token: 6e49c9e59b6593fc1eb510222536706a1ab6fbbed3a50747f597a1d4ed74d511
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,116 +1,108 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/bbatsov/rubocop.git
|
3
|
-
revision: 07c5d73b050e242ce17c4ee4ee5e91fdad554a18
|
4
|
-
specs:
|
5
|
-
rubocop (0.18.1)
|
6
|
-
json (>= 1.7.7, < 2)
|
7
|
-
parser (~> 2.1.7)
|
8
|
-
powerpack (~> 0.0.6)
|
9
|
-
rainbow (>= 1.99.1, < 3.0)
|
10
|
-
ruby-progressbar (~> 1.4)
|
11
|
-
|
12
1
|
GIT
|
13
2
|
remote: git://github.com/guard/guard-minitest.git
|
14
|
-
revision:
|
3
|
+
revision: 7738c49bfe9c1a6a54181d8f413abd9633de9c2e
|
15
4
|
specs:
|
16
|
-
guard-minitest (2.
|
17
|
-
guard (~> 2
|
5
|
+
guard-minitest (2.4.4)
|
6
|
+
guard-compat (~> 1.2)
|
18
7
|
minitest (>= 3.0)
|
19
8
|
|
20
9
|
PATH
|
21
10
|
remote: .
|
22
11
|
specs:
|
23
|
-
poleica (0.
|
12
|
+
poleica (0.10.0)
|
24
13
|
childprocess
|
25
14
|
|
26
15
|
GEM
|
27
16
|
remote: https://rubygems.org/
|
28
17
|
specs:
|
29
|
-
ast (
|
30
|
-
|
31
|
-
|
18
|
+
ast (2.0.0)
|
19
|
+
astrolabe (1.3.0)
|
20
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
21
|
+
byebug (3.5.1)
|
22
|
+
columnize (~> 0.8)
|
32
23
|
debugger-linecache (~> 1.2)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
nio4r (>= 0.5.0)
|
38
|
-
childprocess (0.5.1)
|
24
|
+
slop (~> 3.6)
|
25
|
+
celluloid (0.16.0)
|
26
|
+
timers (~> 4.0.0)
|
27
|
+
childprocess (0.5.5)
|
39
28
|
ffi (~> 1.0, >= 1.0.11)
|
29
|
+
codeclimate-test-reporter (0.4.7)
|
30
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
40
31
|
coderay (1.1.0)
|
41
32
|
columnize (0.9.0)
|
42
|
-
coveralls (0.7.0)
|
43
|
-
multi_json (~> 1.3)
|
44
|
-
rest-client
|
45
|
-
simplecov (>= 0.7)
|
46
|
-
term-ansicolor
|
47
|
-
thor
|
48
33
|
debugger-linecache (1.2.0)
|
49
|
-
docile (1.1.
|
50
|
-
ffi (1.9.
|
51
|
-
formatador (0.2.
|
52
|
-
guard (2.
|
34
|
+
docile (1.1.5)
|
35
|
+
ffi (1.9.6)
|
36
|
+
formatador (0.2.5)
|
37
|
+
guard (2.12.4)
|
53
38
|
formatador (>= 0.2.4)
|
54
|
-
listen (~> 2.
|
39
|
+
listen (~> 2.7)
|
55
40
|
lumberjack (~> 1.0)
|
41
|
+
nenv (~> 0.1)
|
42
|
+
notiffany (~> 0.0)
|
56
43
|
pry (>= 0.9.12)
|
44
|
+
shellany (~> 0.0)
|
57
45
|
thor (>= 0.18.1)
|
58
|
-
guard-
|
46
|
+
guard-compat (1.2.1)
|
47
|
+
guard-rubocop (1.2.0)
|
59
48
|
guard (~> 2.0)
|
60
|
-
rubocop (~> 0.
|
61
|
-
|
62
|
-
listen (2.
|
49
|
+
rubocop (~> 0.20)
|
50
|
+
hitimes (1.2.2)
|
51
|
+
listen (2.9.0)
|
63
52
|
celluloid (>= 0.15.2)
|
64
|
-
celluloid-io (>= 0.15.0)
|
65
53
|
rb-fsevent (>= 0.9.3)
|
66
54
|
rb-inotify (>= 0.9)
|
67
|
-
lumberjack (1.0.
|
55
|
+
lumberjack (1.0.9)
|
68
56
|
method_source (0.8.2)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
57
|
+
minitest (5.5.1)
|
58
|
+
multi_json (1.11.0)
|
59
|
+
nenv (0.2.0)
|
60
|
+
notiffany (0.0.6)
|
61
|
+
nenv (~> 0.1)
|
62
|
+
shellany (~> 0.0)
|
63
|
+
parser (2.2.0.3)
|
64
|
+
ast (>= 1.1, < 3.0)
|
65
|
+
powerpack (0.1.0)
|
66
|
+
pry (0.10.1)
|
67
|
+
coderay (~> 1.1.0)
|
68
|
+
method_source (~> 0.8.1)
|
80
69
|
slop (~> 3.4)
|
81
|
-
pry-byebug (
|
82
|
-
byebug (~>
|
83
|
-
pry (~> 0.
|
70
|
+
pry-byebug (3.0.1)
|
71
|
+
byebug (~> 3.4)
|
72
|
+
pry (~> 0.10)
|
84
73
|
rainbow (2.0.0)
|
85
|
-
rake (10.
|
74
|
+
rake (10.4.2)
|
86
75
|
rb-fsevent (0.9.4)
|
87
|
-
rb-inotify (0.9.
|
76
|
+
rb-inotify (0.9.5)
|
88
77
|
ffi (>= 0.5.0)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
78
|
+
rubocop (0.29.1)
|
79
|
+
astrolabe (~> 1.3)
|
80
|
+
parser (>= 2.2.0.1, < 3.0)
|
81
|
+
powerpack (~> 0.1)
|
82
|
+
rainbow (>= 1.99.1, < 3.0)
|
83
|
+
ruby-progressbar (~> 1.4)
|
84
|
+
ruby-progressbar (1.7.1)
|
85
|
+
shellany (0.0.1)
|
86
|
+
simplecov (0.9.2)
|
93
87
|
docile (~> 1.1.0)
|
94
|
-
multi_json
|
95
|
-
simplecov-html (~> 0.
|
96
|
-
simplecov-html (0.
|
97
|
-
slop (3.
|
98
|
-
term-ansicolor (1.3.0)
|
99
|
-
tins (~> 1.0)
|
88
|
+
multi_json (~> 1.0)
|
89
|
+
simplecov-html (~> 0.9.0)
|
90
|
+
simplecov-html (0.9.0)
|
91
|
+
slop (3.6.0)
|
100
92
|
thor (0.19.1)
|
101
|
-
timers (
|
102
|
-
|
93
|
+
timers (4.0.1)
|
94
|
+
hitimes
|
103
95
|
|
104
96
|
PLATFORMS
|
105
97
|
ruby
|
106
98
|
|
107
99
|
DEPENDENCIES
|
108
100
|
bundler (~> 1.3)
|
109
|
-
|
101
|
+
codeclimate-test-reporter
|
110
102
|
guard-minitest!
|
111
103
|
guard-rubocop
|
112
104
|
minitest
|
113
105
|
poleica!
|
114
106
|
pry-byebug
|
115
107
|
rake
|
116
|
-
rubocop
|
108
|
+
rubocop
|
data/README.md
CHANGED
@@ -37,14 +37,14 @@ gem install poleica
|
|
37
37
|
|
38
38
|
or in __Gemfile__ :
|
39
39
|
|
40
|
-
```
|
40
|
+
```ruby
|
41
41
|
gem 'poleica'
|
42
42
|
```
|
43
43
|
|
44
44
|
|
45
45
|
## Usage
|
46
46
|
|
47
|
-
```
|
47
|
+
```ruby
|
48
48
|
Poleica.new(file_path).to_png
|
49
49
|
Poleica.new(file_path).to_pdf
|
50
50
|
Poleica.new(file_path).to_thumbnail
|
@@ -55,7 +55,7 @@ Poleica.new(file_path).to_png(width: 400, weight: 400)
|
|
55
55
|
|
56
56
|
Example :
|
57
57
|
|
58
|
-
```
|
58
|
+
```ruby
|
59
59
|
Poleica.configure do |config|
|
60
60
|
config.timeout = 2 # time in secs
|
61
61
|
config.libre_office[:bin_paths][:linux] = '/usr/local/bin/gm'
|
data/Rakefile
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
module Poleica
|
3
3
|
# Conversion Logic, given a type it can search for compatible converters
|
4
4
|
module Convertible
|
5
|
-
CONVERTERS = Poleica::Converters
|
6
|
-
.
|
7
|
-
|
5
|
+
CONVERTERS = Poleica::Converters.constants
|
6
|
+
.map { |c| Poleica::Converters.const_get(c) } -
|
7
|
+
[Poleica::Converters::Utils]
|
8
8
|
|
9
9
|
def method_missing(method, *args, &block)
|
10
10
|
extension, options =
|
@@ -28,7 +28,7 @@ module Poleica
|
|
28
28
|
def compatible_converters
|
29
29
|
@compatible_converters ||=
|
30
30
|
compatible_converters_by_type(file_type.class) <<
|
31
|
-
|
31
|
+
Converters::General
|
32
32
|
end
|
33
33
|
|
34
34
|
def compatible_convert_methods
|
@@ -26,8 +26,9 @@ module Poleica
|
|
26
26
|
|
27
27
|
def default_options
|
28
28
|
{
|
29
|
+
path: polei.path_with_md5(:png),
|
29
30
|
height: DEFAULT_MEASURE,
|
30
|
-
width:
|
31
|
+
width: DEFAULT_MEASURE,
|
31
32
|
force_resize: false,
|
32
33
|
auto_orient: true,
|
33
34
|
page: 0
|
@@ -52,15 +53,11 @@ module Poleica
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def output_options
|
55
|
-
@output_path = if options[:path]
|
56
|
-
|
57
|
-
|
58
|
-
File.join(options[:path], name)
|
59
|
-
else
|
60
|
-
options[:path]
|
61
|
-
end
|
56
|
+
@output_path = if File.directory?(options[:path])
|
57
|
+
name = File.basename(polei.path_with_md5(:png))
|
58
|
+
File.join(options[:path], name)
|
62
59
|
else
|
63
|
-
|
60
|
+
options[:path]
|
64
61
|
end
|
65
62
|
end
|
66
63
|
end # class OptionsGenerator
|
@@ -29,6 +29,7 @@ module Poleica
|
|
29
29
|
|
30
30
|
def default_options
|
31
31
|
{
|
32
|
+
path: polei.path_with_md5(:png),
|
32
33
|
height: DEFAULT_MEASURE,
|
33
34
|
width: DEFAULT_MEASURE,
|
34
35
|
auto_orient: true
|
@@ -44,7 +45,7 @@ module Poleica
|
|
44
45
|
[
|
45
46
|
'-resize',
|
46
47
|
"#{width_and_height_options}"
|
47
|
-
|
48
|
+
]
|
48
49
|
end
|
49
50
|
|
50
51
|
def width_and_height_options
|
@@ -91,15 +92,11 @@ module Poleica
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def output_options
|
94
|
-
@output_path = if options[:path]
|
95
|
-
|
96
|
-
|
97
|
-
File.join(options[:path], name)
|
98
|
-
else
|
99
|
-
options[:path]
|
100
|
-
end
|
95
|
+
@output_path = if File.directory?(options[:path])
|
96
|
+
name = File.basename(polei.path_with_md5(:png))
|
97
|
+
File.join(options[:path], name)
|
101
98
|
else
|
102
|
-
|
99
|
+
options[:path]
|
103
100
|
end
|
104
101
|
end
|
105
102
|
end # class ThumbnailOptionsGenerator
|
@@ -20,38 +20,36 @@ module Poleica
|
|
20
20
|
def to_pdf(options = {})
|
21
21
|
opts_gen = OptionsGenerator.new(polei, options, :pdf)
|
22
22
|
exec_with_timeout(bin_path, opts_gen.generate)
|
23
|
-
expected_file_path = opts_gen
|
23
|
+
expected_file_path = opts_gen.output_path
|
24
24
|
File.exist?(expected_file_path) ? expected_file_path : nil
|
25
25
|
ensure
|
26
26
|
temp_file_path = opts_gen.temp_path
|
27
27
|
File.delete(temp_file_path) if File.exist?(temp_file_path)
|
28
28
|
end
|
29
29
|
|
30
|
-
private
|
31
|
-
|
32
30
|
# Generate options for the soffice command
|
33
31
|
class OptionsGenerator
|
34
|
-
attr_reader :options, :format, :polei
|
32
|
+
attr_reader :options, :format, :polei, :output_path
|
35
33
|
|
36
34
|
def initialize(polei, options = {}, format = :pdf)
|
37
|
-
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
35
|
+
@polei = polei
|
36
|
+
@format = format
|
37
|
+
@output_path = options[:path] || polei.path_with_md5(format)
|
38
|
+
@options = default_options.merge(options)
|
39
|
+
end
|
40
|
+
|
41
|
+
def default_options
|
42
|
+
{ path: polei.path_with_md5 }
|
41
43
|
end
|
42
44
|
|
43
45
|
def generate
|
44
46
|
[
|
45
|
-
|
47
|
+
default_arguments,
|
46
48
|
format,
|
47
49
|
output_options
|
48
50
|
].flatten
|
49
51
|
end
|
50
52
|
|
51
|
-
def [](key)
|
52
|
-
options[key]
|
53
|
-
end
|
54
|
-
|
55
53
|
# Generate a temp path, and create the file this is needed in order to
|
56
54
|
# have the right filename, LibreOffice just copy the original filename
|
57
55
|
# in the choosen directory, it doesn't accept filename params.
|
@@ -65,15 +63,10 @@ module Poleica
|
|
65
63
|
private
|
66
64
|
|
67
65
|
def generate_temp_path
|
68
|
-
if options[:path]
|
69
|
-
|
70
|
-
basename = File.basename(polei.path_with_md5)
|
71
|
-
return File.join(options[:path], basename)
|
72
|
-
end
|
73
|
-
extension = File.extname(polei.path)
|
74
|
-
return pathable_object.path_for_extension(extension[1..-1])
|
66
|
+
if File.directory?(options[:path])
|
67
|
+
File.join(options[:path], File.basename(polei.path_with_md5))
|
75
68
|
else
|
76
|
-
|
69
|
+
pathable_object.path_for_extension(File.extname(polei.path))
|
77
70
|
end
|
78
71
|
end
|
79
72
|
|
@@ -82,7 +75,7 @@ module Poleica
|
|
82
75
|
pathable_object.extend(Poleica::Pathable)
|
83
76
|
end
|
84
77
|
|
85
|
-
def
|
78
|
+
def default_arguments
|
86
79
|
%w(
|
87
80
|
--nologo
|
88
81
|
--headless
|
@@ -9,15 +9,15 @@ module Poleica
|
|
9
9
|
HOST_OS ||= (defined?('RbConfig') ? RbConfig : Config)::CONFIG['host_os']
|
10
10
|
|
11
11
|
def windows?
|
12
|
-
|
12
|
+
!HOST_OS.match(/mswin|windows|cygwin/i).nil?
|
13
13
|
end
|
14
14
|
|
15
15
|
def osx?
|
16
|
-
|
16
|
+
!HOST_OS.match(/darwin/i).nil?
|
17
17
|
end
|
18
18
|
|
19
19
|
def linux?
|
20
|
-
|
20
|
+
!HOST_OS.match(/linux/i).nil?
|
21
21
|
end
|
22
22
|
|
23
23
|
def host_os
|
@@ -61,7 +61,7 @@ module Poleica
|
|
61
61
|
raise Poleica::TimeoutError, e.message
|
62
62
|
end
|
63
63
|
|
64
|
-
def map_std(process, &
|
64
|
+
def map_std(process, &_block)
|
65
65
|
stdout, stdout_w, stderr, stderr_w = init_process_std(process)
|
66
66
|
yield
|
67
67
|
stderr_w.close.nil? && fail_if_error(process, stderr)
|
@@ -82,10 +82,9 @@ module Poleica
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def fail_if_error(process, stderr)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
85
|
+
return if process.exit_code == 0
|
86
|
+
message = "Code: #{process.exit_code} #{stderr.read}"
|
87
|
+
fail Poleica::ProcessError, message
|
89
88
|
end
|
90
89
|
end # module Utils
|
91
90
|
end # module Converters
|
data/lib/poleica/types/image.rb
CHANGED
data/lib/poleica/types/pdf.rb
CHANGED
data/lib/poleica/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
if ENV['COVERAGE'] || ENV['TRAVIS']
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
-
SimpleCov::Formatter::HTMLFormatter,
|
8
|
-
Coveralls::SimpleCov::Formatter
|
9
|
-
]
|
10
|
-
Coveralls.wear!
|
3
|
+
require 'codeclimate-test-reporter'
|
4
|
+
CodeClimate::TestReporter.start
|
11
5
|
end
|
12
6
|
|
13
7
|
Bundler.require(:default, :test)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poleica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1.fix1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antoine Lyset
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".rubocop.yml"
|
49
50
|
- ".travis.yml"
|
50
51
|
- CHANGELOG.md
|
51
52
|
- Gemfile
|
@@ -110,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
111
|
version: '0'
|
111
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
113
|
requirements:
|
113
|
-
- - "
|
114
|
+
- - ">"
|
114
115
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
116
|
+
version: 1.3.1
|
116
117
|
requirements: []
|
117
118
|
rubyforge_project:
|
118
119
|
rubygems_version: 2.2.2
|