Class: PathRule
- Inherits:
-
Object
- Object
- PathRule
- Defined in:
- lib/path_rule.rb
Overview
path_rule.rb Copyright © Rémi Even 2017
This file is part of Xolti.
Xolti is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Xolti is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Xolti. If not, see <www.gnu.org/licenses/>.
Instance Attribute Summary collapse
-
#effect ⇒ Object
readonly
Returns the value of attribute effect.
Instance Method Summary collapse
- #file_match(path) ⇒ Object
- #folder_match(path) ⇒ Object
-
#initialize(path, pattern) ⇒ PathRule
constructor
A new instance of PathRule.
Constructor Details
#initialize(path, pattern) ⇒ PathRule
Returns a new instance of PathRule.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/path_rule.rb', line 22 def initialize(path, pattern) if pattern.start_with?("!") then @effect = :exclude pattern = pattern[1..-1] else @effect = :include end @file_regexp = pattern_to_file_regexp(path, pattern) @folder_regexp = pattern_to_folder_regexp(path, pattern) end |
Instance Attribute Details
#effect ⇒ Object (readonly)
Returns the value of attribute effect.
20 21 22 |
# File 'lib/path_rule.rb', line 20 def effect @effect end |
Instance Method Details
#file_match(path) ⇒ Object
33 34 35 |
# File 'lib/path_rule.rb', line 33 def file_match(path) @file_regexp =~ path end |
#folder_match(path) ⇒ Object
37 38 39 |
# File 'lib/path_rule.rb', line 37 def folder_match(path) @folder_regexp =~ path end |