Class: Literally::Configuration
- Inherits:
-
Object
- Object
- Literally::Configuration
- Defined in:
- lib/literally/configuration.rb
Instance Method Summary collapse
-
#exclude(*patterns) ⇒ Object
: (*String) -> void.
-
#include(*patterns) ⇒ Object
: (*String) -> void.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#match?(path) ⇒ Boolean
: (String) -> bool.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
4 5 6 7 8 |
# File 'lib/literally/configuration.rb', line 4 def initialize @mutex = Mutex.new @include = [] @exclude = [] end |
Instance Method Details
#exclude(*patterns) ⇒ Object
: (*String) -> void
18 19 20 21 22 |
# File 'lib/literally/configuration.rb', line 18 def exclude(*patterns) @mutex.synchronize do @exclude.concat(patterns) end end |
#include(*patterns) ⇒ Object
: (*String) -> void
11 12 13 14 15 |
# File 'lib/literally/configuration.rb', line 11 def include(*patterns) @mutex.synchronize do @include.concat(patterns) end end |
#match?(path) ⇒ Boolean
: (String) -> bool
25 26 27 28 29 30 31 |
# File 'lib/literally/configuration.rb', line 25 def match?(path) return false unless String === path path = File.absolute_path(path) return false if @exclude.any? { |pattern| File.fnmatch?(pattern, path) } return true if @include.any? { |pattern| File.fnmatch?(pattern, path) } false end |