Class: LocoMotion::Icons::Verifier
- Inherits:
-
Object
- Object
- LocoMotion::Icons::Verifier
- Defined in:
- lib/loco_motion/icons/verifier.rb
Overview
Checks that every icon reference resolves from the given icon roots —
typically the application's vendored app/assets/svg/icons plus the
engine's bundled set, deliberately excluding the development-only local
cache the Renderer may fall back to. That makes it
the treeshake's audit step: loco_motion:icons:verify uses it to fail
loudly when a referenced icon has not been vendored, no matter which
environment the app happens to be running in.
Like Vendorer, it is pure file I/O and mirrors the
renderer's path resolution — <library>/<variant>/<name>.svg, with a
nil variant (flat library) collapsing to <library>/<name>.svg.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#initialize(roots:, default_variant:) ⇒ Verifier
constructor
A new instance of Verifier.
-
#verify(references) ⇒ Result
The count of references that resolved and the references that resolved from none of the roots.
Constructor Details
#initialize(roots:, default_variant:) ⇒ Verifier
Returns a new instance of Verifier.
31 32 33 34 |
# File 'lib/loco_motion/icons/verifier.rb', line 31 def initialize(roots:, default_variant:) @roots = Array(roots).map(&:to_s) @default_variant = default_variant end |
Instance Method Details
#verify(references) ⇒ Result
Returns The count of references that resolved and the references that resolved from none of the roots.
44 45 46 47 48 |
# File 'lib/loco_motion/icons/verifier.rb', line 44 def verify(references) missing = references.reject { |ref| resolves?(ref) } Result.new(verified: references.size - missing.size, missing: missing) end |