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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rutex.rb +14 -9
- data/lib/rutex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1fab9253e0153bea22a424ab82c0f6a3d0e9b1e473dba8e572c285f3a1a036e
|
4
|
+
data.tar.gz: 7d3c1dab072850fb0ccf14bfbfa018a8418f9e405224bd39cb6ff52b3afe080d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fba01bca948b166584da49fc9f0e504d6c18f05562c73c74554c7d5e26580a66b989bddf400f1da1205d7fab1090a6f7931adffdcb23af88e665fdd8687679b
|
7
|
+
data.tar.gz: 3d7194cd7ac6728a3a05e7617c0b909de695fae3a067b9e5c93b6378027599bb9c89175f20e795d1b3d0b632183670c08c77d92cb0f95f9c20b4f8055faacc6d
|
data/Gemfile.lock
CHANGED
data/lib/rutex.rb
CHANGED
@@ -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=#{
|
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 #{
|
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
|
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
|
-
|
123
|
-
"#{
|
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|
|
data/lib/rutex/version.rb
CHANGED