Class: Guard::Spring

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/spring.rb,
lib/guard/spring/runner.rb

Defined Under Namespace

Classes: Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize a Guard.

Parameters:

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

    the Guard file watchers

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

    the custom Guard options



13
14
15
16
# File 'lib/guard/spring.rb', line 13

def initialize(watchers = [], options = {})
  super
  @runner = Runner.new(options)
end

Instance Attribute Details

#runnerObject

Returns the value of attribute runner.



8
9
10
# File 'lib/guard/spring.rb', line 8

def runner
  @runner
end

Instance Method Details

#reloadObject

Called when ‘reload|r|z + enter` is pressed. This method should be mainly used for “reload” (really!) actions like reloading passenger/spork/bundler/…

Raises:

  • (:task_has_failed)

    when reload has failed



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

def reload
  runner.kill_spring
  runner.launch_spring('Reload')
end

#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



42
43
44
# File 'lib/guard/spring.rb', line 42

def run_all
  runner.run_all
end

#run_on_changes(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



49
50
51
# File 'lib/guard/spring.rb', line 49

def run_on_changes(paths)
  runner.run(paths)
end

#run_on_removals(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



56
57
58
# File 'lib/guard/spring.rb', line 56

def run_on_removals(paths)
  runner.run_all
end

#startObject

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

Raises:

  • (:task_has_failed)

    when start has failed



20
21
22
23
# File 'lib/guard/spring.rb', line 20

def start
  runner.kill_spring
  runner.launch_spring('Start')
end

#stopObject

Called when ‘stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).

Raises:

  • (:task_has_failed)

    when stop has failed



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

def stop
  runner.kill_spring
end