# class Listen::Silencer

### Constants

DEFAULT_IGNORED_DIRECTORIES

  The default list of directories that get ignored.

DEFAULT_IGNORED_EXTENSIONS

  The default list of files that get ignored.

### Attributes

ignore_patterns[RW]
only_patterns[RW]
options[R]

### Public Class Methods

new() click to toggle source

    # File lib/listen/silencer.rb, line 57
    def initialize
      configure({})
    end

### Public Instance Methods

configure(options) click to toggle source

    # File lib/listen/silencer.rb, line 61
    def configure(options)
      @only_patterns = options[:only] ? Array(options[:only]) : nil
      @ignore_patterns = _init_ignores(options[:ignore], options[:ignore!])
    end

silenced?(relative_path, type) click to toggle source

TODO: switch type and path places - and verify

    # File lib/listen/silencer.rb, line 70
    def silenced?(relative_path, type)
      path = relative_path.to_s

      if only_patterns && type == :file
        return true unless only_patterns.any? { |pattern| path =~ pattern }
      end

      ignore_patterns.any? { |pattern| path =~ pattern }
    end

### Private Instance Methods

_init_ignores(ignores, overrides) click to toggle source

    # File lib/listen/silencer.rb, line 84
    def _init_ignores(ignores, overrides)
      patterns = []
      unless overrides
        patterns << DEFAULT_IGNORED_DIRECTORIES
        patterns << DEFAULT_IGNORED_EXTENSIONS
      end

      patterns << ignores
      patterns << overrides

      patterns.compact.flatten
    end