Module: OKF::Bundle::RowFilter
- Defined in:
- lib/okf/bundle/row_filter.rb
Overview
The one catalog-row predicate every narrowing surface shares — the CLI's
filter flags, the MCP shell's catalog filters, and its search narrowing
select rows by these rules and no other copy of them. The seam earned the
module: the predicate was hand-spelled in three shells with only the leaf
folds shared, and the copies diverged three recorded times (a raw status
compare answering the opposite of --status stable, "" meaning no-filter
on one tool and match-nothing on the next, the root's spellings).
Callers hand it normalized wants — nil means "no filter", and dir
arrives as a folded base path ("." for the bundle root) — because
argument spelling is each shell's own: the CLI folds the root alias
against the bundle's real directories, the MCP shell maps ""/"/" onto
".", and neither belongs here. Pure, like everything beside it.
Class Method Summary collapse
- .fold(value) ⇒ Object
- .matches?(row, type: nil, dir: nil, tag: nil, status: nil, trust: nil) ⇒ Boolean
-
.shows_trust?(row) ⇒ Boolean
The row-shaped spelling of Concept.shows_trust? — "is this row's tier one a surface should claim?".
-
.under_dir?(entry_dir, base) ⇒ Boolean
The one rule
--diris built on: a dir names itself and everything beneath it; "." is a prefix of nothing, so the root selects only what lives directly in it.
Class Method Details
.fold(value) ⇒ Object
38 39 40 |
# File 'lib/okf/bundle/row_filter.rb', line 38 def fold(value) value.to_s.downcase end |
.matches?(row, type: nil, dir: nil, tag: nil, status: nil, trust: nil) ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/okf/bundle/row_filter.rb', line 21 def matches?(row, type: nil, dir: nil, tag: nil, status: nil, trust: nil) (type.nil? || fold(row[:type]) == fold(type)) && (dir.nil? || under_dir?(row[:dir], dir)) && (tag.nil? || Array(row[:tags]).any? { |value| fold(value) == fold(tag) }) && (status.nil? || Concept.effective_status(row[:status]) == Concept.fold_status(status)) && (trust.nil? || fold(row[:trust]) == Concept.fold_tier(trust)) end |
.shows_trust?(row) ⇒ Boolean
The row-shaped spelling of Concept.shows_trust? — "is this row's tier one
a surface should claim?". It lives beside #matches? because narrowing is
one of its three consumers: the trust facet's gate, its counts and its
narrowing all read this, so the facet describes exactly the rows wearing a
tier. generated is the catalog's raw declared-key boolean, which is what
tells a concept that opted into §5 from one that said nothing at all.
48 49 50 |
# File 'lib/okf/bundle/row_filter.rb', line 48 def shows_trust?(row) Concept.shows_trust?(row[:trust], row[:generated]) end |
.under_dir?(entry_dir, base) ⇒ Boolean
The one rule --dir is built on: a dir names itself and everything
beneath it; "." is a prefix of nothing, so the root selects only what
lives directly in it.
32 33 34 35 36 |
# File 'lib/okf/bundle/row_filter.rb', line 32 def under_dir?(entry_dir, base) entry = fold(entry_dir) path = fold(base) entry == path || entry.start_with?("#{path}/") end |