Module: Textus::Manifest::Entry::IgnoreMatcher
- Defined in:
- lib/textus/manifest/entry/ignore_matcher.rb
Overview
Pure glob matcher backing per-entry ignore: patterns (ADR 0042).
rel_path is the slash-joined path of a candidate file relative to the
entry's base directory.
Matching is segment-wise so the ** globstar means "zero or more path
segments" — File.fnmatch alone cannot express this (under
FNM_PATHNAME a trailing ** will not cross a /; without it a leading
**/ will not match zero leading segments). So **/node_modules/**
catches the node_modules subtree at any depth, including the store
root, and the directory entry itself.
Within a single segment, matching delegates to File.fnmatch with
FNM_EXTGLOB, so a single * is anchored to that segment (it does not
cross /) and {a,b} alternation works.
Constant Summary collapse
- SEGMENT_FLAGS =
File::FNM_EXTGLOB
Class Method Summary collapse
Class Method Details
.match?(patterns, rel_path) ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/textus/manifest/entry/ignore_matcher.rb', line 21 def self.match?(patterns, rel_path) path_segs = rel_path.split("/").reject(&:empty?) Array(patterns).any? do |pat| match_segments(pat.split("/").reject(&:empty?), path_segs) end end |