Sha256: 80ebf2c36418afe1ef6341774c619932639e37ee6e34a10f400e951259d93469
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module Listen class Silencer # The default list of directories that get ignored. DEFAULT_IGNORED_DIRECTORIES = %w[.rbx .bundle .git .svn .hg bundle log tmp vendor] # The default list of files that get ignored. DEFAULT_IGNORED_EXTENSIONS = %w[.DS_Store] attr_accessor :options, :patterns def initialize(options = {}) @options = options _init_patterns end def silenced?(path) patterns.any? { |pattern| pattern =~ path.to_s } end private def _init_patterns @patterns = [] @patterns << _default_patterns unless options[:ignore!] @patterns << options[:ignore] << options[:ignore!] @patterns.compact @patterns.flatten! end def _default_patterns [_default_ignored_directories_patterns, _default_ignored_extensions_patterns] end def _default_ignored_directories_patterns ignored_directories = DEFAULT_IGNORED_DIRECTORIES.map { |d| Regexp.escape(d) } %r{(?:#{ignored_directories.join('|')})} end def _default_ignored_extensions_patterns ignored_extensions = DEFAULT_IGNORED_EXTENSIONS.map { |e| Regexp.escape(e) } %r{(?:#{ignored_extensions.join('|')})$} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
listen-2.0.0.beta.1 | lib/listen/silencer.rb |