class Guard::Invoker

Public Class Methods

new(options = {}) click to toggle source

Initializes a Guard plugin. Don't do any work here, especially as Guard plugins get initialized even if they are not in an active group!

@param [Hash] options the custom Guard plugin options @option options [Array<Guard::Watcher>] watchers the Guard plugin file watchers @option options [Symbol] group the group this Guard plugin belongs to @option options [Boolean] any_return allow any object to be returned from a watcher

Calls superclass method
# File lib/guard/invoker.rb, line 14
def initialize(options = {})
  say "Initialize invoker"
  super
end

Public Instance Methods

reload() click to toggle source

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

@raise [:task_has_failed] when reload has failed @return [Object] the task result

# File lib/guard/invoker.rb, line 45
def reload
  stop
  start
end
run_all() click to toggle source

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

@raise [:task_has_failed] when run_all has failed @return [Object] the task result

# File lib/guard/invoker.rb, line 56
def run_all
  start
end
run_on_additions(paths) click to toggle source

Called on file(s) additions that the Guard plugin watches.

@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_additions has failed @return [Object] the task result

# File lib/guard/invoker.rb, line 75
def run_on_additions(paths)
  reload
end
run_on_changes(paths) click to toggle source

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

@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_change has failed

# File lib/guard/invoker.rb, line 65
def run_on_changes(paths)
  reload
end
run_on_modifications(paths) click to toggle source

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

@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_modifications has failed @return [Object] the task result

# File lib/guard/invoker.rb, line 85
def run_on_modifications(paths)
  reload
end
run_on_removals(paths) click to toggle source

Called on file(s) removals that the Guard plugin watches.

@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_removals has failed @return [Object] the task result

# File lib/guard/invoker.rb, line 95
def run_on_removals(paths)
  reload
end
start() click to toggle source

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

@raise [:task_has_failed] when start has failed @return [Object] the task result

# File lib/guard/invoker.rb, line 24
def start
  say "Starting invoker"
  invoker_start
end
stop() click to toggle source

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

@raise [:task_has_failed] when stop has failed @return [Object] the task result

# File lib/guard/invoker.rb, line 34
def stop
  say "Stopping invoker"
  invoker_stop
end

Private Instance Methods

executable() click to toggle source
# File lib/guard/invoker.rb, line 109
def executable
  options.fetch(:executable) {'invoker'}
end
invoker_start() click to toggle source
# File lib/guard/invoker.rb, line 101
def invoker_start
  system("#{executable} start")
end
invoker_stop() click to toggle source
# File lib/guard/invoker.rb, line 105
def invoker_stop
  system("#{executable} stop")
end
say(what) click to toggle source
# File lib/guard/invoker.rb, line 113
def say(what)
  Guard::Compat::UI.info what, reset: true
end