Module: Rubbr::Builder
- Extended by:
- Cli
- Defined in:
- lib/rubbr/builder.rb,
lib/rubbr/builder/ps.rb,
lib/rubbr/builder/dvi.rb,
lib/rubbr/builder/tex.rb
Overview
Handles the business of building latex (and bibtex if needed) source files into binary formats as dvi, ps, and pdf. The latex and bibtex utilites need to be run a certain number of times so that things like table of contents, references, citations, etc become proper. This module tries to solve this issue by running the needed utilities only as many times as needed.
Defined Under Namespace
Class Method Summary collapse
-
.build ⇒ Object
Build to the spesified format.
- .build_in_a_loop ⇒ Object
- .do_build ⇒ Object
Methods included from Cli
color?, disable_stderr, disable_stdinn, disable_stdout, error, executable?, notice, valid_executable, warning
Methods included from OS
Class Method Details
.build ⇒ Object
Build to the spesified format.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rubbr/builder.rb', line 15 def self.build if Rubbr::Change.d? do_build elsif Rubbr.[:force] notice "No changes in #{Rubbr.[:build_dir]} since last build, building anyway (--force)" do_build else notice "No changes in #{Rubbr.[:build_dir]} since last build" true end end |
.build_in_a_loop ⇒ Object
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rubbr/builder.rb', line 27 def self.build_in_a_loop # single interrupt to rebuild, double to break # inspired by autotest interrupted = false wants_to_break = false force_rebuild = false trap 'INT' do if interrupted wants_to_break = true else interrupted = true notice "Press Ctrl-C a second time to break out." Kernel.sleep 1 end raise Interrupt, nil end delay = Rubbr.[:loop_delay] delay = 0.5 if delay == 0.0 notice "Entering build loop. Press Ctrl-C to force rebuild, double Ctrl-C to break out." forced_first_time = Rubbr.[:force] loop do begin if Rubbr::Change.d? || forced_first_time || force_rebuild notice "Building..." forced_first_time = false force_rebuild = false do_build end sleep delay rescue Interrupt if wants_to_break break else interrupted = false wants_to_break = false force_rebuild = true end end end end |
.do_build ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/rubbr/builder.rb', line 75 def self.do_build if Rubbr.[:engine] == :pdflatex Rubbr::Builder::Tex.build else case Rubbr.[:format] when :dvi Rubbr::Builder::Tex.build when :ps Rubbr::Builder::Tex.build Rubbr::Builder::Dvi.build else Rubbr::Builder::Tex.build Rubbr::Builder::Dvi.build Rubbr::Builder::Ps.build end end true rescue Rubbr::Runner::GotErrors notice "There were errors, processing stopped." false end |