mnogootex 0.1.0 → 0.2.0
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: f84bc4403ed2b6c0cf0ced691e4ebf69449de8fb
|
4
|
+
data.tar.gz: 826c773e078eb685b7dacfa0b7c9936a07b5c29c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dd132fa97940367f3aab6b6ef9a284ab5bb7164adb5b7c20f6aaeaa791218f13d33af0529fcb5809f37755e434d09eda3938488a083f0706c7f33b6642d7e77
|
7
|
+
data.tar.gz: 81aecc276bc9a5f880bb5b92043859c0e130ec5b07b5caa0b1190b1f1cafef75e531f4271bd59d2a40475cd41169a8d42363dfdc681df73b45bcd1a5c4df5e29
|
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
|
+
`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