Class: Glyphs::PruneRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/glyphs/prune_runner.rb

Overview

Wires configuration → SourceScanner → IconPruner and (when deleting) verifies every kept icon still resolves on disk. Thin orchestrator so the rake task is a one-liner and the whole flow is unit-testable.

Glyphs::PruneRunner.call(dry_run: false)   # scans Rails.root, prunes, verifies

Defined Under Namespace

Classes: VerificationError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root: default_root, icons_root: default_icons_root, dry_run: true, config: Glyphs.configuration) ⇒ PruneRunner

Returns a new instance of PruneRunner.



18
19
20
21
22
23
# File 'lib/glyphs/prune_runner.rb', line 18

def initialize(root: default_root, icons_root: default_icons_root, dry_run: true, config: Glyphs.configuration)
  @root = root
  @icons_root = icons_root
  @dry_run = dry_run
  @config = config
end

Class Method Details

.callObject



14
15
16
# File 'lib/glyphs/prune_runner.rb', line 14

def self.call(**)
  new(**).call
end

Instance Method Details

#callObject



25
26
27
28
29
# File 'lib/glyphs/prune_runner.rb', line 25

def call
  report = pruner.call
  verify! unless @dry_run
  report
end

#verify!Object

Asserts every kept icon resolves to a file on disk. Raises VerificationError listing the first few misses.

Raises:



33
34
35
36
37
38
39
40
# File 'lib/glyphs/prune_runner.rb', line 33

def verify!
  missing = expected_files.reject { |path| File.exist?(path) }
  return if missing.empty?

  names = missing.first(10).map { |path| relative(path) }
  raise VerificationError,
    "#{missing.size} kept icon(s) missing after prune: #{names.join(', ')}"
end