Class Guard::Listener
In: lib/guard/listener.rb
Parent: Object

The Listener is the base class for all listener implementations.

@abstract

Methods

Constants

DEFAULT_IGNORE_PATHS = %w[. .. .bundle .git log tmp vendor]   Default paths that gets ignored by the listener

Attributes

changed_files  [RW] 
directory  [R] 
ignore_paths  [R] 

Public Class methods

Initialize the listener.

@param [String] directory the root directory to listen to @option options [Boolean] relativize_paths use only relative paths @option options [Boolean] watch_all_modifications to enable deleted and moved file listening. @option options [Array<String>] ignore_paths the paths to ignore by the listener

Select the appropriate listener implementation for the current OS and initializes it.

@param [Hash] options the options for the listener @option options [String] watchdir the directory to watch @return [Guard::Listener] the chosen listener

Public Instance methods

Get all files that are in the watched directory.

@return [Array<String>] the list of files

Clear the list of changed files.

Removes the ignored paths from the directory list.

@param [Array<String>] dirs the directory to listen to @param [Array<String>] ignore_paths the paths to ignore @return children of the passed dirs that are not in the ignore_paths list

Get the modified files.

If the `:watch_all_modifications` option is true, then moved and deleted files are also reported, but prefixed by an exclamation point.

@example Deleted or moved file

  !/home/user/dir/file.rb

@param [Array<String>] dirs the watched directories @param [Hash] options the listener options @option options [Symbol] all whether to files in sub directories @return [Array<String>] paths of files that have been modified

Store a listener callback.

@param [Block] callback the callback to store

Pause the listener to ignore change events.

Scopes all given paths to the current directory.

@param [Array<String>] paths the paths to change @return [Array<String>] all paths now relative to the current dir

Use paths relative to the current directory.

@return [Boolean] whether to use relative or absolute paths

Unpause the listener to listen again to change events.

Start watching the root directory.

Start the listener thread.

Stop listening for events.

Populate initial timestamp file hash to watch for deleted or moved files.

Updates the timestamp of the last event.

Register a directory to watch. Must be implemented by the subclasses.

@param [String] directory the directory to watch

test if the listener should also watch for deleted and moved files

@return [Boolean] whether to watch all file modifications or not

[Validate]