4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/omgtex/runner.rb', line 4
def self.run!
options = Options.parse!
abort("A single input file must be specified") if ARGV.length != 1
file = ARGV.shift
abort("No .tex file was specified") if ( file =~ /(.*?)(\.tex)/ ).nil?
filename = $1
filetype = $2
latexCommand = "#{options[:typesetter]} #{options[:latexOptions].join(' ')}"
file = "'#{file}'"
pdffile = "'#{filename}.pdf'"
auxfile = "'#{filename}.aux'"
current_dir = Dir.pwd
cmd = " if [ -e '#{auxfile}' ]; then HASH=$(md5 -q #{auxfile}); fi"
cmd += " && #{latexCommand} #{file}"
cmd += " && makeglossaries #{filename}" if options[:glossary]
cmd += " && if [ \"$HASH\" != \"$(md5 -q #{auxfile})\" ]; then "
cmd += " echo ''"
cmd += " && bibtex #{filename}" if options[:bibtex]
cmd += " && #{latexCommand} #{file}"
cmd += " && #{latexCommand} #{file} ;"
cmd += " fi"
cmd += " && open #{pdffile}" if options[:openpdf]
cmd += " && rm -f *.aux *.glo *.ist *.log *.out" unless options[:dontclean]
if options[:dryrun]
puts cmd
else
Kernel.exec(cmd)
end
end
|