Class Guard::Interactor
In: lib/guard/interactor.rb
lib/guard/commands/reload.rb
lib/guard/commands/all.rb
lib/guard/commands/change.rb
lib/guard/commands/show.rb
lib/guard/commands/pause.rb
lib/guard/commands/scope.rb
lib/guard/commands/notification.rb
Parent: Object

The Guard interactor is a Pry REPL with a Guard specific command set.

Methods

Constants

GUARD_RC = '~/.guardrc'   The default Ruby script to configure Guard Pry if the option `:guard_rc` is not defined.
HISTORY_FILE = '~/.guard_history'   The default Guard Pry history file if the option `:history_file` is not defined.
SHORTCUTS = { :help => 'h', :all => 'a', :reload => 'r', :change => 'c', :show => 's', :scope => 'o', :notification => 'n', :pause => 'p', :exit => 'e', :quit => 'q'   List of shortcuts for each interactor command
RELOAD = Pry::CommandSet.new do create_command 'reload' do group 'Guard'
ALL = Pry::CommandSet.new do create_command 'all' do group 'Guard'
CHANGE = Pry::CommandSet.new do create_command 'change' do group 'Guard'
SHOW = Pry::CommandSet.new do create_command 'show' do group 'Guard'
PAUSE = Pry::CommandSet.new do create_command 'pause' do group 'Guard'
SCOPE = Pry::CommandSet.new do create_command 'scope' do group 'Guard'
NOTIFICATION = Pry::CommandSet.new do create_command 'notification' do group 'Guard'

Attributes

thread  [RW] 

Public Class methods

Converts and validates a plain text scope to a valid plugin or group scope.

@param [Array<String>] entries the text scope @return [Hash, Array<String>] the plugin or group scope, the unknown entries

Is the interactor enabled?

@return [Boolean] true if enabled

Set the enabled status for the interactor

@param [Boolean] status true if enabled

Initialize the interactor. This configures Pry and creates some custom commands and aliases for Guard.

Get the interactor options

@return [Hash] the options

Set the interactor options

@param [Hash] options the interactor options @option options [String] :guard_rc the Ruby script to configure Guard Pry @option options [String] :history_file the file to write the Pry history to

Public Instance methods

Add Pry hooks:

  • Load `~/.guardrc` within each new Pry session.
  • Load project‘s `.guardrc` within each new Pry session.
  • Restore prompt after each evaluation.

Configure the pry prompt to see `guard` instead of `pry`.

Creates command aliases for the commands `help`, `reload`, `change`, `scope`, `notification`, `pause`, `exit` and `quit`, which will be the first letter of the command.

Create a shorthand command to run the `:run_all` action on a specific Guard group. For example, when you have a group `frontend`, then a command `frontend` is created that runs `all frontend`.

Create a shorthand command to run the `:run_all` action on a specific Guard plugin. For example, when guard-rspec is available, then a command `rspec` is created that runs `all rspec`.

Creates a command that triggers the `:run_all` action when the command is empty (just pressing enter on the beginning of a line).

Replaces reset defined inside of Pry with a reset that instead restarts guard.

Restore terminal settings

Start the line reader in its own thread and stop Guard on Ctrl-D.

Kill interactor thread if not current

Stores the terminal settings so we can resore them when stopping.

Detects whether or not the stty command exists on the user machine.

@return [Boolean] the status of stty

[Validate]