Class: Listen::Silencer

Inherits:
Object show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen/silencer.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen/silencer/controller.rb

Defined Under Namespace

Classes: Controller

Constant Summary collapse

DEFAULT_IGNORED_FILES =

The default list of directories that get ignored.

%r{\A(?:
    \.git
| \.svn
| \.hg
| \.rbx
| \.bundle
| bundle
| vendor/bundle
| log
| tmp
| vendor/ruby

# emacs temp files
| \#.+\#
| \.\#.+
)(/|\z)}x.freeze
DEFAULT_IGNORED_EXTENSIONS =

The default list of files that get ignored.

%r{(?:
  # Kate's tmp\/swp files
  \..*\d+\.new
  | \.kate-swp

  # Gedit tmp files
  | \.goutputstream-.{6}

  # Intellij files
  | ___jb_bak___
  | ___jb_old___

  # Vim swap files and write test
  | \.sw[px]
  | \.swpx
  | ^4913

  # Sed temporary files - but without actual words, like 'sedatives'
  | (?:\A
     sed

     (?:
      [a-zA-Z0-9]{0}[A-Z]{1}[a-zA-Z0-9]{5} |
      [a-zA-Z0-9]{1}[A-Z]{1}[a-zA-Z0-9]{4} |
      [a-zA-Z0-9]{2}[A-Z]{1}[a-zA-Z0-9]{3} |
      [a-zA-Z0-9]{3}[A-Z]{1}[a-zA-Z0-9]{2} |
      [a-zA-Z0-9]{4}[A-Z]{1}[a-zA-Z0-9]{1} |
      [a-zA-Z0-9]{5}[A-Z]{1}[a-zA-Z0-9]{0}
     )
    )

  # Mutagen sync temporary files
  | \.mutagen-temporary.*

  # other files
  | \.DS_Store
  | \.tmp
  | ~
)\z}x.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Silencer

Returns a new instance of Silencer.



67
68
69
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen/silencer.rb', line 67

def initialize(**options)
  configure(options)
end

Instance Attribute Details

#ignore_patternsObject

TODO: deprecate these mutators; use attr_reader instead



65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen/silencer.rb', line 65

def ignore_patterns
  @ignore_patterns
end

#only_patternsObject

TODO: deprecate these mutators; use attr_reader instead



65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen/silencer.rb', line 65

def only_patterns
  @only_patterns
end

Instance Method Details

#configure(options) ⇒ Object

TODO: deprecate this mutator



72
73
74
75
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/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

#silenced?(relative_path, type) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
80
81
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/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