Class Listen::DirectoryRecord
In: lib/listen/directory_record.rb
Parent: Object

The directory record stores information about a directory and keeps track of changes to the structure of its childs.

Methods

Constants

DEFAULT_IGNORED_DIRECTORIES = %w[.rbx .bundle .git .svn log tmp vendor]
DEFAULT_IGNORED_EXTENSIONS = %w[.DS_Store]
HIGH_PRECISION_SUPPORTED = File.mtime(__FILE__).to_f.to_s[-2..-1] != '.0'
HIGH_PRECISION_SUPPORTED = false
MetaData = Struct.new(:type, :mtime)   Data structure used to save meta data about a path

Attributes

directory  [R] 
paths  [R] 
sha1_checksums  [R] 

Public Class methods

Creates the ignoring patterns from the default ignored directories and extensions. It memoizes the generated patterns to avoid unnecessary computation.

Initializes a directory record.

@option [String] directory the directory to keep track of

Public Instance methods

Finds the paths that should be stored and adds them to the paths’ hash.

Detects changes in the passed directories, updates the record with the new changes and returns the changes

@param [Array] directories the list of directories scan for changes @param [Hash] options @option options [Boolean] recursive scan all sub-directories recursively @option options [Boolean] relative_paths whether or not to use relative paths for changes

@return [Hash<Array>] the changes

Adds filtering patterns to the listener.

@example Filter some files

  ignore /\.txt$/, /.*\.zip/

@param [Regexp] regexp a pattern for filtering paths

Replaces filtering patterns in the listener.

@example Filter only these files

  ignore /\.txt$/, /.*\.zip/

@param [Regexp] regexp a pattern for filtering paths

Returns whether a path should be filtered or not.

@param [String] path the path to test.

@return [Boolean]

Returns the filtering patterns used in the record to know which paths should be stored.

@return [Array<Regexp>] the filtering patterns

Adds ignoring patterns to the record.

@example Ignore some paths

  ignore %r{^ignored/path/}, /man/

@param [Regexp] regexp a pattern for ignoring paths

Replaces ignoring patterns in the record.

@example Ignore only these paths

  ignore! %r{^ignored/path/}, /man/

@param [Regexp] regexp a pattern for ignoring paths

Returns whether a path should be ignored or not.

@param [String] path the path to test.

@return [Boolean]

Returns the ignoring patterns in the record

@return [Array<Regexp>] the ignoring patterns

Converts an absolute path to a path that‘s relative to the base directory.

@param [String] path the path to convert

@return [String] the relative path

[Validate]