Module Guard
In: lib/guard/cli.rb
lib/guard/dsl.rb
lib/guard/dsl_describer.rb
lib/guard/group.rb
lib/guard/guard.rb
lib/guard/hook.rb
lib/guard/interactor.rb
lib/guard/interactors/readline.rb
lib/guard/interactors/simple.rb
lib/guard/listener.rb
lib/guard/listeners/darwin.rb
lib/guard/listeners/linux.rb
lib/guard/listeners/polling.rb
lib/guard/listeners/windows.rb
lib/guard/notifier.rb
lib/guard/notifiers/gntp.rb
lib/guard/notifiers/growl.rb
lib/guard/notifiers/growl_notify.rb
lib/guard/notifiers/libnotify.rb
lib/guard/notifiers/notifysend.rb
lib/guard/notifiers/rb_notifu.rb
lib/guard/ui.rb
lib/guard/version.rb
lib/guard/watcher.rb
lib/guard.rb

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

Methods

Classes and Modules

Module Guard::Hook
Module Guard::Notifier
Module Guard::UI
Class Guard::CLI
Class Guard::Darwin
Class Guard::Dsl
Class Guard::DslDescriber
Class Guard::Group
Class Guard::Guard
Class Guard::Interactor
Class Guard::Linux
Class Guard::Listener
Class Guard::Polling
Class Guard::ReadlineInteractor
Class Guard::SimpleInteractor
Class Guard::Watcher
Class Guard::Windows

Constants

VERSION = '1.0.1'   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

Attributes

interactor  [RW] 
listener  [RW] 
lock  [RW] 
options  [RW] 

Public Class methods

Add a Guard group.

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

  should be halted for all Guards 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 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 Guard options (see the given Guard documentation) @return [Guard::Guard] the guard added

Detects the paths that have changed.

Deleted paths are prefixed by an exclamation point. @see Guard::Listener#modified_files

@param [Array<String>] paths the watched paths @return [Array<String>] the changed paths

Creates the initial Guardfile template when it does not already exist.

@see Guard::CLI.init

@param [Hash] options The options for creating a Guardfile @option options [Boolean] :abort_on_existence Whether to abort or not when a Guardfile already exists

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

Detects the paths that have been deleted.

Deleted paths are prefixed by an exclamation point. @see Guard::Listener#modified_files

@param [Array<String>] paths the watched paths @return [Array<String>] the deleted paths

Tries to load the Guard main class. This transforms the supplied Guard 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 group or several 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 Gem names installed locally.

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

Get the symbol we have to catch when running a supervised task. If we are within a Guard group that has the `:halt_on_fail` option set, we do NOT catch it here, it will be catched at the group level.

@see .run_on_guards

@param [Guard::Guard] guard the Guard to execute @return [Symbol] the symbol to catch

Smart accessor for retrieving a specific guard or several guards at once.

@see Guard.groups

@example Filter Guards by String or Symbol

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

@example Filter Guards by Regexp

  Guard.guards(/rsp.+/)

@example Filter Guards by Hash

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

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

Adds the templates of all installed Guard implementations to an existing Guardfile.

@see Guard::CLI.init

Adds the Guardfile template of a Guard implementation to an existing Guardfile.

@see Guard::CLI.init

@param [String] guard_name the name of the Guard or template to initialize

Locate a path to a Guard gem.

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

Pause Guard listening to file changes.

Reload all Guards currently enabled.

@param [Hash] scopes an hash with a guard or a group scope

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

@see Guard.groups

Run a block where the listener and the interactor is blocked.

@yield the block to run

Trigger `run_all` on all Guards currently enabled.

@param [Hash] scopes an hash with a guard or a group scope

Trigger `run_on_change` on all Guards currently enabled.

Run the `:run_on_change` task. When the option `:watch_all_modifications` is set, the task is split to run changed paths on {Guard::Guard#run_on_change}, whereas deleted paths run on {Guard::Guard#run_on_deletion}.

@param [Array<String>] files the list of files to pass to the task @param [Guard::Guard] guard the guard to run @raise [:task_has_failed] when task has failed

Loop through all groups and run the given task for each Guard.

Stop the task run for the all Guards within a group if one Guard throws `:task_has_failed`.

@param [Hash] scopes an hash with a guard or a group scope @yield the task to run

Run a Guard task, but remove the Guard when his work leads to a system failure.

When the Group has `:halt_on_fail` disabled, we‘ve to catch `:task_has_failed` here in order to avoid an uncaught throw error.

@param [Guard::Guard] guard the Guard to execute @param [Symbol] task the task to run @param [Array] args the arguments for the task @raise [:task_has_failed] when task has failed

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] verbose if verbose 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 @option options [Boolean] watch_all_modifications watches all file modifications if true

Start Guard by evaluate the `Guardfile`, initialize the declared Guards and start 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 Guards
  • 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

[Validate]