mutool 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/mutool.rb +27 -2
- data/lib/mutool/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1818977b9db239383e635158a3f137f30e31f0c8ee3abd5bbb6b2664786b8f4
|
4
|
+
data.tar.gz: 526e84ad9e332f9cd63a9674b66a3196342350664c593be1482fde3b9ec7d383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 178493fed1ace40da1fb179422467842e3b5b92c46645f5c647d5c42569d5346263f8afbd6c01f3e1005e98a0e982cd6ddb7e8401330ee5cbaa04d7931d0e8d9
|
7
|
+
data.tar.gz: c383030249c29107dae74a386b36cf64405576df79006cb7f8d306edc2bbd87adf5d1066759631e5cbbcb1b6951658db522d53f128d7a08449adc46968779683
|
data/Gemfile.lock
CHANGED
data/lib/mutool.rb
CHANGED
@@ -1,23 +1,48 @@
|
|
1
1
|
require 'mutool/version'
|
2
|
+
require 'thread'
|
3
|
+
require 'open3'
|
2
4
|
|
3
5
|
class Mutool
|
4
6
|
class << Mutool
|
7
|
+
attr_accessor :mutool_path, :has_mutool
|
8
|
+
|
9
|
+
def has_mutool?
|
10
|
+
@has_mutool ||= run([mutool_path]).exitstatus == 1
|
11
|
+
end
|
12
|
+
|
5
13
|
def flags(ops = {})
|
6
14
|
ops.map { |key, value| ["-#{key}", value] }
|
7
15
|
end
|
8
16
|
|
17
|
+
def version
|
18
|
+
raise 'mutool not found' unless has_mutool?
|
19
|
+
@version ||= version_str.gsub("\n", '').split(' ').last
|
20
|
+
end
|
21
|
+
|
9
22
|
# Reference: https://mupdf.com/docs/manual-mutool-convert.html
|
10
23
|
def convert(input, pages='1-N', ops)
|
11
|
-
|
24
|
+
raise 'mutool not found' unless has_mutool?
|
25
|
+
run([mutool_path, 'convert', flags(ops), input, pages].flatten)
|
12
26
|
end
|
13
27
|
|
14
28
|
# https://mupdf.com/docs/manual-mutool-clean.html
|
15
29
|
def clean(input, output, pages='1-N', ops)
|
16
|
-
|
30
|
+
raise 'mutool not found' unless has_mutool?
|
31
|
+
run([mutool_path, 'clean', flags(ops), input, output, pages].flatten)
|
17
32
|
end
|
18
33
|
|
19
34
|
private
|
20
35
|
|
36
|
+
def version_str
|
37
|
+
_, _, stderr, thread = Open3.popen3('mutool -v')
|
38
|
+
thread.join
|
39
|
+
stderr.read
|
40
|
+
end
|
41
|
+
|
42
|
+
def mutool_path
|
43
|
+
@mutool_path ||= ENV["MUTOOL_PATH"] || 'mutool'
|
44
|
+
end
|
45
|
+
|
21
46
|
def run(command = [])
|
22
47
|
system(*command, out: File::NULL, err: File::NULL)
|
23
48
|
$?
|
data/lib/mutool/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marlon Henry Schweigert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|