rutex 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5712ce9901a3f2745b95543efa8a66bf04e18d587130757aed0eb3e3941b7af1
4
- data.tar.gz: e54cebec6a18307e70f38d225ca5b65ae76ad9dcf9be6b4ed6f9d4f38b071519
3
+ metadata.gz: f1fab9253e0153bea22a424ab82c0f6a3d0e9b1e473dba8e572c285f3a1a036e
4
+ data.tar.gz: 7d3c1dab072850fb0ccf14bfbfa018a8418f9e405224bd39cb6ff52b3afe080d
5
5
  SHA512:
6
- metadata.gz: 3deba6a6105dbffc38542ccaf8d8af01f9157d175cf399fc42750421c6e85c2d027ce2bc61b5bf25d91c100e1dcfff99eadb4adb854f7c9627c6ec76a4adb438
7
- data.tar.gz: eaf8170625ef64237bc0283db9ff704d544245793118bbfe4ae061ca38068cb3b699c0eb7a8f413068d8c317870237361ffef495c6efb81a6a6b43818f05eaae
6
+ metadata.gz: 2fba01bca948b166584da49fc9f0e504d6c18f05562c73c74554c7d5e26580a66b989bddf400f1da1205d7fab1090a6f7931adffdcb23af88e665fdd8687679b
7
+ data.tar.gz: 3d7194cd7ac6728a3a05e7617c0b909de695fae3a067b9e5c93b6378027599bb9c89175f20e795d1b3d0b632183670c08c77d92cb0f95f9c20b4f8055faacc6d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rutex (0.1.6)
4
+ rutex (0.1.7)
5
5
  mini_magick (~> 4.10.1)
6
6
 
7
7
  GEM
@@ -10,6 +10,12 @@ module MakeMakefile
10
10
  end
11
11
  end
12
12
 
13
+ class String
14
+ def remove_extension
15
+ sub(/\.[^.]*$/,'')
16
+ end
17
+ end
18
+
13
19
  # Generate images from TeX equations
14
20
  module Rutex
15
21
  class RutexError < StandardError; end # :nodoc:
@@ -43,6 +49,7 @@ module Rutex
43
49
  _, @output_file = args.slice!(args.index('-f'),2)
44
50
  end
45
51
  @output_file||=Tempfile.open('equation') {|f| f.path}
52
+ @output_file=@output_file.remove_extension
46
53
 
47
54
  if args.include?('-c')
48
55
  _, @color = args.slice!(args.index('-c'),2)
@@ -72,13 +79,13 @@ module Rutex
72
79
  end
73
80
 
74
81
  def pdflatex_options # :nodoc:
75
- "-halt-on-error -interaction=nonstopmode -output-directory=#{pdflatex_log_dir}"
82
+ "-halt-on-error -interaction=nonstopmode -output-directory=#{tmp_dir}"
76
83
  end
77
84
 
78
85
  # run pdflatex command with +pdflatex_options+
79
86
  def pdflatex_run
80
87
  %x(pdflatex #{pdflatex_options} #{tex_file})
81
- raise PdfError "Errors logged in #{pdflatex_log_dir}" unless $?.exitstatus==0
88
+ raise PdfError "Errors logged in #{tmp_dir}" unless $?.exitstatus==0
82
89
  rescue PdfError => e
83
90
  puts "PdfError (#{e.message})"
84
91
  abort "Try installing standalone package https://www.ctan.org/pkg/standalone"
@@ -103,7 +110,7 @@ module Rutex
103
110
  exit
104
111
  end
105
112
 
106
- def pdflatex_log_dir # :nodoc:
113
+ def tmp_dir # :nodoc:
107
114
  File.dirname(Tempfile.new)
108
115
  end
109
116
 
@@ -119,18 +126,16 @@ module Rutex
119
126
  File.write(tex_file, tex_string)
120
127
  end
121
128
 
122
- def tex_file # :nodoc:
123
- "#{output_file}.tex"
129
+ %w[tex pdf].each do |format|
130
+ define_method("#{format}_file") do
131
+ File.join(tmp_dir,"#{File.basename(output_file)}.#{format}")
132
+ end
124
133
  end
125
134
 
126
135
  def png_file
127
136
  "#{output_file}.png"
128
137
  end
129
138
 
130
- def pdf_file
131
- "#{output_file}.pdf"
132
- end
133
-
134
139
  def pdf_to_png
135
140
  pdf = MiniMagick::Image.open pdf_file
136
141
  MiniMagick::Tool::Convert.new do |convert|
@@ -1,3 +1,3 @@
1
1
  module Rutex
2
- VERSION = "0.1.6" # :nodoc:
2
+ VERSION = "0.1.7" # :nodoc:
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rutex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergioro