Class: Rubbr::Builder::Tex

Inherits:
Base
  • Object
show all
Defined in:
lib/rubbr/builder/tex.rb

Class Method Summary collapse

Methods included from Cli

#color?, #disable_stderr, #disable_stdinn, #disable_stdout, #error, #executable?, #notice, #valid_executable, #warning

Class Method Details

.buildObject



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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rubbr/builder/tex.rb', line 5

def build

  clean_build_dir

  base_latex_file = Rubbr.options[:base_latex_file]
  base_bibtex_file = Rubbr.options[:base_bibtex_file]

  case Rubbr.options[:engine]
  when :pdflatex
    @output_format = :pdf
    preprocessor = Rubbr::Runner::PdfLaTeX
  else
    @output_format = :dvi
    preprocessor = Rubbr::Runner::LaTeX
  end

  build_dir do
    copy_source_files
    copy_vendor_files
    copy_graphic_files

    # first run
    latex = preprocessor.new(base_latex_file)

    if base_bibtex_file && latex.warnings.join =~ /No file .+\.bbl/
      bibtex = Rubbr::Runner::BibTeX.new(base_bibtex_file)
    end

    if latex.warnings.join =~ /No file .+\.(aux|toc)/
      latex = preprocessor.new(base_latex_file)
    end

    if latex.warnings.join =~ /There were undefined citations/
      latex = preprocessor.new(base_latex_file)
    end

    if latex.warnings.join =~ /Label\(s\) may have changed\. Rerun/
      latex = preprocessor.new(base_latex_file)
    end

    # last run needed to get lof to be proper
    latex = preprocessor.new(base_latex_file)

    latex.feedback
    if bibtex
      bibtex.feedback
    end
  end
  distribute_file(base_latex_file)
  notice "Build of #@output_format completed for: #{base_latex_file} " +
         "in #{Rubbr.options[:build_dir]}"
end