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
  • <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

@example Reload rspec guard

  spork reload

@example Run all jasmine specs

  jasmine

@abstract

Methods

Constants

HELP_ENTRIES = %w[help h]
RELOAD_ENTRIES = %w[reload r]
STOP_ENTRIES = %w[exit e quit q]
PAUSE_ENTRIES = %w[pause p]
NOTIFICATION_ENTRIES = %w[notification n]

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

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.

@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 and the action

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

Execute the reload action.

@param [Hash] scopes the reload scopes

Start the line reader in its own thread.

Kill interactor thread if not current

Toggle the system notifications on/off

[Validate]