Class: Driskell::Listen::Silencer
- Inherits:
-
Object
- Object
- Driskell::Listen::Silencer
- Defined in:
- lib/driskell-listen/silencer.rb,
lib/driskell-listen/silencer/controller.rb
Defined Under Namespace
Classes: Controller
Constant Summary collapse
- DEFAULT_IGNORED_DIRECTORIES =
The default list of directories that get ignored.
%r{^(?: \.git | \.svn | \.hg | \.rbx | \.bundle | bundle | vendor/bundle | log | tmp |vendor/ruby )(/|$)}x
- DEFAULT_IGNORED_EXTENSIONS =
The default list of files that get ignored.
/(?: # 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' | (?:^ 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} ) ) # other files | \.DS_Store | \.tmp | ~ )$/x
Instance Attribute Summary collapse
-
#ignore_patterns ⇒ Object
Returns the value of attribute ignore_patterns.
-
#only_patterns ⇒ Object
Returns the value of attribute only_patterns.
Instance Method Summary collapse
- #configure(options) ⇒ Object
-
#initialize ⇒ Silencer
constructor
A new instance of Silencer.
-
#silenced?(relative_path, type) ⇒ Boolean
TODO: switch type and path places - and verify.
Constructor Details
#initialize ⇒ Silencer
Returns a new instance of Silencer.
57 58 59 |
# File 'lib/driskell-listen/silencer.rb', line 57 def initialize configure({}) end |
Instance Attribute Details
#ignore_patterns ⇒ Object
Returns the value of attribute ignore_patterns.
55 56 57 |
# File 'lib/driskell-listen/silencer.rb', line 55 def ignore_patterns @ignore_patterns end |
#only_patterns ⇒ Object
Returns the value of attribute only_patterns.
55 56 57 |
# File 'lib/driskell-listen/silencer.rb', line 55 def only_patterns @only_patterns end |
Instance Method Details
#configure(options) ⇒ Object
61 62 63 64 |
# File 'lib/driskell-listen/silencer.rb', line 61 def configure() @only_patterns = [:only] ? Array([:only]) : nil @ignore_patterns = _init_ignores([:ignore], [:ignore!]) end |
#silenced?(relative_path, type) ⇒ Boolean
TODO: switch type and path places - and verify
70 71 72 73 74 75 76 77 78 |
# File 'lib/driskell-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 |