class Listen::Silencer
Constants
- DEFAULT_IGNORED_EXTENSIONS
-
The default list of files that get ignored.
- DEFAULT_IGNORED_FILES
-
The default list of directories that get ignored.
Attributes
TODO: deprecate these mutators; use attr_reader instead
TODO: deprecate these mutators; use attr_reader instead
Public Class Methods
Source
# File lib/listen/silencer.rb, line 67 def initialize(**options) configure(options) end
Public Instance Methods
Source
# File lib/listen/silencer.rb, line 72 def configure(options) @only_patterns = options[:only] ? Array(options[:only]) : nil @ignore_patterns = _init_ignores(options[:ignore], options[:ignore!]) end
TODO: deprecate this mutator
Source
# File lib/listen/silencer.rb, line 77 def silenced?(relative_path, type) path = relative_path.to_s # in case it is a Pathname _ignore?(path) || (only_patterns && type == :file && !_only?(path)) end
Private Instance Methods
Source
# File lib/listen/silencer.rb, line 85 def _ignore?(path) ignore_patterns.any? { |pattern| path =~ pattern } end
Source
# File lib/listen/silencer.rb, line 93 def _init_ignores(ignores, overrides) patterns = [] unless overrides patterns << DEFAULT_IGNORED_FILES patterns << DEFAULT_IGNORED_EXTENSIONS end patterns << ignores patterns << overrides patterns.compact.flatten end
Source
# File lib/listen/silencer.rb, line 89 def _only?(path) only_patterns.any? { |pattern| path =~ pattern } end