Class: Guard::Assets

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/assets.rb

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ Assets

Initialize a Guard.

Parameters:

  • watchers (Array<Guard::Watcher>) (defaults to: [])

    the Guard file watchers

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

    the custom Guard options



9
10
11
12
13
14
15
# File 'lib/guard/assets.rb', line 9

def initialize(watchers = [], options = {})
  super

  @coffeescript_compiler = ::TechnoGate::Contao::CoffeescriptCompiler.new
  @javascript_compiler  = ::TechnoGate::Contao::JavascriptCompiler.new
  @stylesheet_compiler  = ::TechnoGate::Contao::StylesheetCompiler.new
end

Instance Method Details

#run_allObject

Called when just ‘enter` is pressed This method should be principally used for long action like running all specs/tests/…

Raises:

  • (:task_has_failed)

    when run_all has failed



26
27
28
29
30
31
32
33
# File 'lib/guard/assets.rb', line 26

def run_all
  @stylesheet_compiler.clean
  @coffeescript_compiler.clean
  @javascript_compiler.clean
  compile_stylesheet
  compile_coffeescript
  compile_javascript
end

#run_on_change(paths) ⇒ Object

Called on file(s) modifications that the Guard watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Raises:

  • (:task_has_failed)

    when run_on_change has failed



38
39
40
# File 'lib/guard/assets.rb', line 38

def run_on_change(paths)
  compile(paths)
end

#run_on_deletion(paths) ⇒ Object

Called on file(s) deletions that the Guard watches.

Parameters:

  • paths (Array<String>)

    the deleted files or paths

Raises:

  • (:task_has_failed)

    when run_on_change has failed



45
46
47
# File 'lib/guard/assets.rb', line 45

def run_on_deletion(paths)
  compile(paths)
end

#startObject

Call once when Guard starts. Please override initialize method to init stuff.

Raises:

  • (:task_has_failed)

    when start has failed



19
20
21
# File 'lib/guard/assets.rb', line 19

def start
  run_all
end