Class: Guard::Pdflatex

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/pdflatex.rb,
lib/guard/pdflatex/version.rb

Overview

The PDFLatex Guard automatically compiles your latex files with pdflatex.

Constant Summary collapse

OPTIONS =
{
  title: 'PDFLatex'
}
VERSION =
'0.0.3'

Instance Method Summary collapse

Instance Method Details

#run_allObject

Gets called when all files should be regenerated.

Raises:

  • (:task_has_failed)

    when stop has failed



15
16
17
# File 'lib/guard/pdflatex.rb', line 15

def run_all
  run_on_changes(Watcher.match_files(self, Dir.glob('**{,/*/**}/*.tex')))
end

#run_on_changes(paths) ⇒ Object

Parameters:

  • paths (Array<String>)

    of changed paths and files

Raises:

  • (:task_has_failed)

    when stop has failed



21
22
23
24
25
26
27
28
29
30
# File 'lib/guard/pdflatex.rb', line 21

def run_on_changes(paths)
  failed = false
  paths.each do |path|
    unless system *%W[/usr/bin/env pdflatex -halt-on-error -output-directory=#{File.dirname path}], path
      ::Guard::Notifier.notify "PDFLatex halted on an error in #{path}", OPTIONS.merge(:image => :failed)
      failed = true
    end
  end
  throw :task_has_failed if failed
end