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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 182ef69820d451072125b2dd35ddba905f8b20f1
4
- data.tar.gz: 594263246e7f0c27683d3a03ff0c7b7cf21439d5
3
+ metadata.gz: aa5c4c34f4297f240efb250291489dc7e475809c
4
+ data.tar.gz: 192650acf878934caea98fa0377043e34956936e
5
5
  SHA512:
6
- metadata.gz: a65f959f87671acf35176d73e9cce8d951e0a3b2d6695dc672697c27b09004afb77633ed89d3cb1f94394e17f5c33db3880e34d87ae7638cd760e0168d821768
7
- data.tar.gz: 934d75316da2cabf902d6a06bcacd5cdb875f6782db140c1cc5fcb29f702c19b20dc17eda6715d66637b430ef20ba3edcaa1bf01005ad130930a950e876a73e9
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 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.1"
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Brasolin