Module Guard
In: lib/guard/notifier.rb
lib/guard/ui.rb
lib/guard/guard.rb
lib/guard/group.rb
lib/guard/commands/show.rb
lib/guard/commands/scope.rb
lib/guard/commands/notification.rb
lib/guard/commands/all.rb
lib/guard/commands/pause.rb
lib/guard/commands/reload.rb
lib/guard/commands/change.rb
lib/guard/version.rb
lib/guard/hook.rb
lib/guard/guardfile.rb
lib/guard/runner.rb
lib/guard/notifiers/terminal_title.rb
lib/guard/notifiers/tmux.rb
lib/guard/notifiers/emacs.rb
lib/guard/notifiers/growl_notify.rb
lib/guard/notifiers/growl.rb
lib/guard/notifiers/rb_notifu.rb
lib/guard/notifiers/libnotify.rb
lib/guard/notifiers/notifysend.rb
lib/guard/notifiers/gntp.rb
lib/guard/notifiers/terminal_notifier.rb
lib/guard/watcher.rb
lib/guard/cli.rb
lib/guard/interactor.rb
lib/guard/dsl.rb
lib/guard/dsl_describer.rb
lib/guard.rb

Guard is the main module for all Guard related modules and classes. Also Guard plugins should use this namespace.

Methods

Classes and Modules

Module Guard::Hook
Module Guard::Notifier
Module Guard::UI
Class Guard::CLI
Class Guard::Dsl
Class Guard::DslDescriber
Class Guard::Group
Class Guard::Guard
Class Guard::Guardfile
Class Guard::Interactor
Class Guard::Runner
Class Guard::Watcher

Constants

VERSION = '1.6.2'   The current gem version of Guard
GUARDFILE_TEMPLATE = File.expand_path('../guard/templates/Guardfile', __FILE__)   The Guardfile template for `guard init`
HOME_TEMPLATES = File.expand_path('~/.guard/templates')   The location of user defined templates
WINDOWS = RbConfig::CONFIG['host_os'] =~ %r!(msdos|mswin|djgpp|mingw)!
DEV_NULL = WINDOWS ? 'NUL' : '/dev/null'
WATCH_ALL_MODIFICATIONS_DEPRECATION = <<-EOS.gsub(/^\s*/, '') Starting with Guard v1.1 the 'watch_all_modifications' option is removed and is now always on. EOS .gsub(/^\s*/, '')   Deprecation message for the `watch_all_modifications` start option
NO_VENDOR_DEPRECATION = <<-EOS.gsub(/^\s*/, '') Starting with Guard v1.1 the 'no_vendor' option is removed because the monitoring gems are now part of a new gem called Listen. (https://github.com/guard/listen) You can specify a custom version of any monitoring gem directly in your Gemfile if you want to overwrite Listen's default monitoring gems. EOS .gsub(/^\s*/, '')   Deprecation message for the `no_vendor` start option

Attributes

interactor  [RW] 
listener  [RW] 
lock  [RW] 
options  [RW] 
runner  [RW] 
running  [RW] 
scope  [RW] 

Public Class methods

Add a Guard plugin group.

@param [String] name the group name @option options [Boolean] halt_on_fail if a task execution

  should be halted for all Guard plugins in this group if one Guard throws `:task_has_failed`

@return [Guard::Group] the group added (or retrieved from the `@groups` variable if already present)

Add a Guard plugin to use.

@param [String] name the Guard name @param [Array<Watcher>] watchers the list of declared watchers @param [Array<Hash>] callbacks the list of callbacks @param [Hash] options the plugin options (see the given Guard documentation) @return [Guard::Guard] the added Guard plugin

Convert the old scope format to the new scope format.

@example Convert old scopes

  convert_scopes({ :guard => :rspec, :group => :backend })
  => { :plugins => [:rspec], :groups => [:backend] }

Adds a command logger in debug mode. This wraps common command execution functions and logs the executed command before execution.

Displays a warning for each deprecated options used.

Tries to load the Guard plugin main class. This transforms the supplied Guard plugin name into a class name:

  • `guardname` will become `Guard::Guardname`
  • `dashed-guard-name` will become `Guard::DashedGuardName`
  • `underscore_guard_name` will become `Guard::UnderscoreGuardName`

When no class is found with the strict case sensitive rules, another try is made to locate the class without matching case:

  • `rspec` will find a class `Guard::RSpec`

@param [String] name the name of the Guard @param [Boolean] fail_gracefully whether error messages should not be printed @return [Class, nil] the loaded class

Smart accessor for retrieving a specific plugin group or several plugin groups at once.

@see Guard.guards

@example Filter groups by String or Symbol

  Guard.groups('backend')
  Guard.groups(:backend)

@example Filter groups by Regexp

  Guard.groups(/(back|front)end/)

@param [String, Symbol, Regexp] filter the filter to apply to the Groups @return [Array<Group>] the filtered groups

Returns a list of Guard plugin Gem names installed locally.

@return [Array<String>] a list of Guard plugin gem names

Smart accessor for retrieving a specific Guard plugin or several Guard plugins at once.

@see Guard.groups

@example Filter Guard plugins by String or Symbol

  Guard.guards('rspec')
  Guard.guards(:rspec)

@example Filter Guard plugins by Regexp

  Guard.guards(/rsp.+/)

@example Filter Guard plugins by Hash

  Guard.guards({ :name => 'rspec', :group => 'backend' })

@param [String, Symbol, Regexp, Hash] filter the filter to apply to the Guard plugins @return [Array<Guard>] the filtered Guard plugins

Locate a path to a Guard plugin gem.

@param [String] name the name of the Guard plugin without the prefix `guard-` @return [String] the full path to the Guard gem

Pause Guard listening to file changes.

Determine if Guard needs to quit. This checks for Ctrl-D pressed.

@return [Boolean] whether to quit or not

Reload Guardfile and all Guard plugins currently enabled. If no scope is given, then the Guardfile will be re-evaluated, which results in a stop/start, which makes the reload obsolete.

@param [Hash] scopes hash with a Guard plugin or a group scope

Trigger `run_all` on all Guard plugins currently enabled.

@param [Hash] scopes hash with a Guard plugin or a group scope

Initialize the Guard singleton:

  • Initialize the internal Guard state.
  • Create the interactor when necessary for user interaction.
  • Select and initialize the file change listener.

@option options [Boolean] clear if auto clear the UI should be done @option options [Boolean] notify if system notifications should be shown @option options [Boolean] debug if debug output should be shown @option options [Array<String>] group the list of groups to start @option options [String] watchdir the director to watch @option options [String] guardfile the path to the Guardfile @deprecated @option options [Boolean] watch_all_modifications watches all file modifications if true @deprecated @option options [Boolean] no_vendor ignore vendored dependencies

Initialize the groups array with the `:default` group.

@see Guard.groups

Initialize the guards array to an empty array.

@see Guard.guards

Initializes the interactor unless the user has specified not to.

Initializes the listener and registers a callback for changes.

Enables or disables the notifier based on user‘s configurations.

Sets up traps to catch signals used to control Guard.

Currently two signals are caught:

  • `USR1` which pauses listening to changes.
  • `USR2` which resumes listening to changes.
  • ‘INT’ which is delegated to Pry if active, otherwise stops Guard.

Start Guard by evaluating the `Guardfile`, initializing declared Guard plugins and starting the available file change listener. Main method for Guard that is called from the CLI when Guard starts.

  • Setup Guard internals
  • Evaluate the `Guardfile`
  • Configure Notifiers
  • Initialize the declared Guard plugins
  • Start the available file change listener

@option options [Boolean] clear if auto clear the UI should be done @option options [Boolean] notify if system notifications should be shown @option options [Boolean] debug if debug output should be shown @option options [Array<String>] group the list of groups to start @option options [String] watchdir the director to watch @option options [String] guardfile the path to the Guardfile

Stop Guard listening to file changes

Runs a block where the interactor is blocked and execution is synchronized to avoid state inconsistency.

@param [Boolean] restart_interactor whether to restart the interactor or not @yield the block to run

[Validate]