mnogootex 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/mnogootex +14 -1
- data/lib/mnogootex/job.rb +13 -5
- data/lib/mnogootex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa5c4c34f4297f240efb250291489dc7e475809c
|
4
|
+
data.tar.gz: 192650acf878934caea98fa0377043e34956936e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 383f762f56a031ca71c41a821dbe877c0028b2c5e53c806694283237967aec7e1b6b1744a453aed2fa5e76781cba7ec12f9db3f0433c7fc30cd5784bac73bc18
|
7
|
+
data.tar.gz: 4dc7c17a9af98cd3a1681b14966364284a627fed718b8f23bc4948ac80e6dc73b9c3ebe46fc9cb92c71307c755c5e92ff77eefcf453aec0619a72b525afb831e
|
data/exe/mnogootex
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
require 'mnogootex'
|
5
5
|
|
6
|
-
puts "Mnogootex v#{Mnogootex::VERSION}"
|
7
6
|
|
8
7
|
# require 'pathname'
|
9
8
|
|
@@ -20,6 +19,20 @@ require 'colorize'
|
|
20
19
|
|
21
20
|
target = ARGV[0]
|
22
21
|
|
22
|
+
|
23
|
+
raise "No parameters given." if ARGV.length.zero?
|
24
|
+
|
25
|
+
if ARGV.length == 3
|
26
|
+
raise "Unknown command." unless %w{show view open}.include? ARGV[1].downcase
|
27
|
+
job = Mnogootex::Job.new cls: ARGV[2], target: File.expand_path(target)
|
28
|
+
pdf = Dir.glob("#{job.tmp_dirname}/*.pdf").first
|
29
|
+
raise "PDF non esiste." unless File.exist? pdf
|
30
|
+
`command -v open >/dev/null && open #{pdf} || xdg-open #{pdf}`
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
puts "Mnogootex v#{Mnogootex::VERSION}"
|
35
|
+
|
23
36
|
main_path = File.expand_path(target)
|
24
37
|
main_basename = File.basename main_path
|
25
38
|
main_dirname = File.dirname main_path
|
data/lib/mnogootex/job.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'pathname'
|
4
|
+
|
1
5
|
module Mnogootex
|
2
6
|
class Job
|
3
7
|
attr_reader :thread, :stdout_stderr, :log, :ticks, :cls
|
@@ -11,18 +15,22 @@ module Mnogootex
|
|
11
15
|
@cls = cls
|
12
16
|
@log = []
|
13
17
|
@ticks = 0
|
18
|
+
|
19
|
+
@id = Digest::MD5.hexdigest(@cls + @main_path)
|
14
20
|
end
|
15
21
|
|
16
22
|
def success?
|
17
23
|
@thread.value.exitstatus == 0
|
18
24
|
end
|
19
25
|
|
20
|
-
def
|
21
|
-
@tmp_dirname
|
26
|
+
def tmp_dirname
|
27
|
+
@tmp_dirname ||= Pathname(Dir.tmpdir).join("mnogootex-#{@id}")
|
28
|
+
end
|
22
29
|
|
23
|
-
|
30
|
+
def setup
|
31
|
+
FileUtils.cp_r File.join(@main_dirname, '.'), tmp_dirname
|
24
32
|
|
25
|
-
@path = File.join
|
33
|
+
@path = File.join tmp_dirname, @main_basename
|
26
34
|
|
27
35
|
code = File.read @path
|
28
36
|
replace = code.sub /\\documentclass(\[.*?\])?{.*?}/,
|
@@ -42,7 +50,7 @@ module Mnogootex
|
|
42
50
|
"--shell-escape", # TODO: remove me!
|
43
51
|
"--interaction=nonstopmode",
|
44
52
|
@main_basename,
|
45
|
-
chdir:
|
53
|
+
chdir: tmp_dirname
|
46
54
|
)
|
47
55
|
end
|
48
56
|
|
data/lib/mnogootex/version.rb
CHANGED