Class: YES::Constraints::FNMatch
- Inherits:
-
NodeConstraint
- Object
- AbstractConstraint
- NodeConstraint
- YES::Constraints::FNMatch
- Defined in:
- lib/yes/constraints/fnmatch.rb
Overview
Validate file glob match. This uess standard unix-style file matching, primarily ‘*` and `?`, to detrmine a mathing node value. All values are converted to strings (using #to_s) for comparison. – TODO: better name then `FNMatch`? ++
Instance Attribute Summary
Attributes inherited from NodeConstraint
Attributes inherited from AbstractConstraint
Class Method Summary collapse
-
.applicable?(spec) ⇒ Boolean
Only applicable if ‘fnmatch` field is in spec.
- .checklist(spec, tree, nodes) ⇒ Array<Constraint>
Instance Method Summary collapse
-
#validate(spec) ⇒ Boolean
Validate file glob match.
Methods inherited from NodeConstraint
Methods inherited from AbstractConstraint
#applicable?, inherited, #initialize, #match_delta, #recurse_valid?, #valid?
Constructor Details
This class inherits a constructor from YES::Constraints::NodeConstraint
Class Method Details
.applicable?(spec) ⇒ Boolean
Only applicable if ‘fnmatch` field is in spec.
23 24 25 |
# File 'lib/yes/constraints/fnmatch.rb', line 23 def self.applicable?(spec) spec['fnmatch'] end |
.checklist(spec, tree, nodes) ⇒ Array<Constraint>
15 16 17 18 19 20 |
# File 'lib/yes/constraints/fnmatch.rb', line 15 def self.checklist(spec, tree, nodes) return [] unless applicable?(spec) nodes.map do |node| new(spec, tree, node) end end |
Instance Method Details
#validate(spec) ⇒ Boolean
Validate file glob match. This uess standard unix-style file matching, primarily ‘*` and `?`, to detrmine a mathing node value. All values are converted to strings (using #to_s) for comparison.
32 33 34 35 36 |
# File 'lib/yes/constraints/fnmatch.rb', line 32 def validate(spec) fnmatch = spec['fnmatch'] File.fnmatch(fnmatch, node.value) end |