Class: Guard::ZeusClient

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

Defined Under Namespace

Classes: Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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
17
18
19
20
21
# File 'lib/guard/zeus-client.rb', line 13

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

  @options = {
    :all_on_start => true
  }.merge(options)

  @runner = Runner.new(@options)
end

Instance Attribute Details

#runnerObject

Returns the value of attribute runner.



8
9
10
# File 'lib/guard/zeus-client.rb', line 8

def runner
  @runner
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



33
34
35
36
37
# File 'lib/guard/zeus-client.rb', line 33

def run_all
  unless runner.run_all
    throw :task_has_failed
  end
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



42
43
44
45
46
# File 'lib/guard/zeus-client.rb', line 42

def run_on_changes(paths)
  unless runner.run(paths)
    throw :task_has_failed
  end
end

#startObject

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

Raises:

  • (:task_has_failed)

    when start has failed



25
26
27
28
# File 'lib/guard/zeus-client.rb', line 25

def start
  UI.info 'Guard::ZeusClient is running'
  run_all if @options[:all_on_start]
end