Hwaro::Services::UnusedAssets
Constants
Data and translation sources that can name an asset (logo: /img/a.png
in data/site.yml, an icon path in i18n/en.toml). data/ is loaded
by Phases::Initialize#load_data_files with exactly this extension
set, and i18n locale files are TOML; templates render whatever those
hold, so a path that only ever appears there is still in use.
Files browsers request by a well-known root URL with no markup
reference (/favicon.ico, /apple-touch-icon[-precomposed][-WxH].png),
so the textual scan can never see them used.
Static sources that reference other static files: Sass (@font-face
/ url() in a .scss that compiles to .css), PWA manifests
(site.webmanifest icons), and <image href> inside an SVG.
html/htm belong here too. Hand-written pages under static/ are
copied into the output verbatim by the build, so an <img src=...>
inside one is a fully static, literal reference — yet without the
extension the scan never read the file and reported its images as
unused, which --delete then removed (real data loss).
Template files that may reference an asset. .html alone was not
enough: Builder::TEMPLATE_EXTENSION_REGEX also accepts .j2,
.jinja, .jinja2 and .ecr, and feed/manifest templates are
authored as rss.xml.jinja / site.webmanifest. Anything missing
here is invisible to the reference scan, so its assets are reported
unused — and --delete removes files the build still needs.
Constructors
Class methods
Boundary-anchored literal check backing the safety net above. A class
method so it stays testable on filesystems (APFS) that refuse to
create non-UTF-8 filenames at all. A basename that is not valid UTF-8
cannot become a PCRE2 pattern — Regex.new raises ArgumentError —
so it is reported as not-referenced here without raising; run skips
(and warns about) such assets before this check is reached.