Class: CGen::Util::LatexToPdf
- Inherits:
-
Object
- Object
- CGen::Util::LatexToPdf
- Defined in:
- lib/cgen/util/latex_to_pdf.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(input_file_name, input_dir, resources_pths, out_dir, log_file, halt_on_error = true, shell_enabled = true, interpreter = 'xelatex', additional_args = []) ⇒ LatexToPdf
constructor
A new instance of LatexToPdf.
Constructor Details
#initialize(input_file_name, input_dir, resources_pths, out_dir, log_file, halt_on_error = true, shell_enabled = true, interpreter = 'xelatex', additional_args = []) ⇒ LatexToPdf
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cgen/util/latex_to_pdf.rb', line 3 def initialize( input_file_name, input_dir, resources_pths, out_dir, log_file, halt_on_error=true, shell_enabled=true, interpreter='xelatex', additional_args=[]) @interpreter = interpreter @halt_on_error = !!halt_on_error @shell_enabled = !!shell_enabled @out_dir = out_dir @input_file_name = input_file_name @input_dir = input_dir @resources_pths = resources_pths @log_file = log_file @additional_args = additional_args.is_a?(Array) ? additional_args : [] end |
Instance Method Details
#generate ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cgen/util/latex_to_pdf.rb', line 17 def generate # Store the starting resources for later cleanup starting_resources = resources_files # Create the command used to generate the PDF gen_pdf_cmd = CGen::Util::ShellCommand.new(get_tex_cmd, @input_dir, @log_file) # Create the command used to generate the bibliography gen_bib_cmd = CGen::Util::ShellCommand.new(get_bibtex_cmd, @out_dir, @log_file) Either.chain do bind -> { gen_pdf_cmd.run } bind -> { gen_bib_cmd.run } bind -> { gen_pdf_cmd.run } bind -> { gen_pdf_cmd.run } bind -> { # ==> Cleanup resources files dirty_files = resources_files - starting_resources dirty_files.length > 0 ? system("rm #{dirty_files.join(' ')}") : false } end end |