Created
April 26, 2012 23:19
-
-
Save codeincontext/2504064 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'timeout' | |
files_to_watch = %w{FYP.txt template.tex FYP.bib} | |
guard :shell do | |
files_regex = Regexp.new(files_to_watch.join("|")) | |
watch(files_regex) { regenerate } | |
end | |
def regenerate | |
Timeout::timeout(90) do | |
puts 'Converting to tex' | |
`pandoc FYP.txt -o FYP.tex --template=template.tex` | |
puts 'Compiling tex (1st pass)' | |
`latex -interaction=nonstopmode FYP` | |
puts 'Executing bibtex' | |
`bibtex FYP.tex` | |
puts 'Compiling tex (2nd pass)' | |
`latex -interaction=nonstopmode FYP` | |
puts 'Compiling tex (3rd pass)' | |
`latex -interaction=nonstopmode FYP` | |
puts 'Building PDF' | |
`pdflatex FYP` | |
puts 'PDF Generated' | |
end | |
rescue Timeout::Error | |
puts 'It got stuck' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment