Class: Guard::ErbLatex

Inherits:
Plugin
  • Object
show all
Defined in:
lib/erb_latex/guard.rb

Overview

The ErbLatex guard that gets notifications about the following Guard events: ‘start`, `run_all` and `run_on_modifications`.

Constant Summary collapse

DEFAULT_OPTIONS =
{
    :layout       => false,
    :data         => {},
    :all_on_start => true,
    :hide_success => false
}

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ErbLatex

Initialize Guard::ErbLates

Parameters:

  • options (Hash) (defaults to: {})

    the options for the Guard

Options Hash (options):

  • :layout, (String)

    the layout to apply to latex files

  • :data, (String)

    for use during the ERB processing

  • :all_on_start (Boolean)

    process all latex files on start

  • :hide_success (Boolean)

    hide success message notification, unless the previous run failed



27
28
29
# File 'lib/erb_latex/guard.rb', line 27

def initialize( options = {} )
    super( DEFAULT_OPTIONS.merge(options) )
end

Instance Method Details

#run_allObject

Gets called when all files should be regenerated.

Raises:

  • (:task_has_failed)

    when stop has failed



43
44
45
# File 'lib/erb_latex/guard.rb', line 43

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

#run_on_modifications(paths) ⇒ Object

Gets called when watched paths and files have changes.

Parameters:

  • paths (Array<String>)

    the changed paths and files

Raises:

  • (:task_has_failed)

    when stop has failed



52
53
54
# File 'lib/erb_latex/guard.rb', line 52

def run_on_modifications(paths)
    throw :task_has_failed unless ::ErbLatex::GuardRunner.run( paths, watchers, options )
end

#startObject

Gets called once when Guard starts.

Raises:

  • (:task_has_failed)

    when stop has failed



35
36
37
# File 'lib/erb_latex/guard.rb', line 35

def start
    run_all if options[:all_on_start]
end