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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 182ef69820d451072125b2dd35ddba905f8b20f1
4
- data.tar.gz: 594263246e7f0c27683d3a03ff0c7b7cf21439d5
3
+ metadata.gz: f84bc4403ed2b6c0cf0ced691e4ebf69449de8fb
4
+ data.tar.gz: 826c773e078eb685b7dacfa0b7c9936a07b5c29c
5
5
  SHA512:
6
- metadata.gz: a65f959f87671acf35176d73e9cce8d951e0a3b2d6695dc672697c27b09004afb77633ed89d3cb1f94394e17f5c33db3880e34d87ae7638cd760e0168d821768
7
- data.tar.gz: 934d75316da2cabf902d6a06bcacd5cdb875f6782db140c1cc5fcb29f702c19b20dc17eda6715d66637b430ef20ba3edcaa1bf01005ad130930a950e876a73e9
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 setup
21
- @tmp_dirname = Dir.mktmpdir ['mnogootex-']
26
+ def tmp_dirname
27
+ @tmp_dirname ||= Pathname(Dir.tmpdir).join("mnogootex-#{@id}")
28
+ end
22
29
 
23
- FileUtils.cp_r File.join(@main_dirname, '.'), @tmp_dirname
30
+ def setup
31
+ FileUtils.cp_r File.join(@main_dirname, '.'), tmp_dirname
24
32
 
25
- @path = File.join @tmp_dirname, @main_basename
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: @tmp_dirname
53
+ chdir: tmp_dirname
46
54
  )
47
55
  end
48
56
 
@@ -1,3 +1,3 @@
1
1
  module Mnogootex
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mnogootex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Brasolin