Class Guard::Interactor
In: lib/guard/interactor.rb
Parent: Object

The interactor triggers specific action from input read by a interactor implementation.

Currently the following actions are implemented:

  • h, help => Show help
  • e, exit,
    1. quit => Exit Guard
  • r, reload => Reload Guard
  • p, pause => Toggle file modification listener
  • n, notification => Toggle notifications
  • s, show => Show Guard plugin configuration
  • c, change => Trigger a file change
  • <enter> => Run all

It‘s also possible to scope `reload` and `run all` actions to only a specified group or a guard.

@example Reload backend group

  backend reload
  reload backend

@example Reload rspec guard

  spork reload
  reload spork

@example Run all jasmine specs

  jasmine

@abstract

Methods

Constants

ACTIONS = { :help => %w[help h], :reload => %w[reload r], :stop => %w[exit e quit q], :pause => %w[pause p], :notification => %w[notification n], :show => %w[show s], :change => %w[change c]

Public Class methods

Tries to detect an optimal interactor for the current environment.

It returns the Readline implementation when:

  • rb-readline is installed
  • The Ruby implementation is JRuby
  • The current OS is not Mac OS X

Otherwise the plain gets interactor is returned.

@return [Interactor] an interactor implementation

Template method for checking if the Interactor is available in the current environment?

@param [Boolean] silent true if no error messages should be shown @return [Boolean] the availability status

Get an instance of the currently configured interactor implementation.

@return [Interactor] an interactor implementation

Set the interactor implementation

@param [Symbol] interactor the name of the interactor

Public Instance methods

Extract the Guard or group scope and action from the input line. There‘s no strict order for scopes and actions.

@example `spork reload` will only reload rspec @example `jasmine` will only run all jasmine specs

@param [String] line the readline input @return [Array] the group or guard scope, the action and the rest

Show the help.

Process the input from readline.

@param [String] line the input line

Read the user input. This method must be implemented by each interactor implementation.

@abstract

Start the line reader in its own thread.

Kill interactor thread if not current

Toggle the system notifications on/off

[Validate]