Class: Ucode::Audit::LibraryAuditor
- Inherits:
-
Object
- Object
- Ucode::Audit::LibraryAuditor
- Defined in:
- lib/ucode/audit/library_auditor.rb
Overview
Orchestrates a library-wide audit pass.
Owns the file-system side: discovers font files under a root path (recursively or not), audits each via FaceAuditor, and assembles a Models::Audit::LibrarySummary combining the per-face reports with cross-face rollups from LibraryAggregator.
Aggregation logic lives in the pure LibraryAggregator; this
class stays focused on discovery + per-face auditing + summary
assembly. Errors auditing a single file are captured in
#skipped so a corrupt file doesn't abort the whole pass.
ucode delta vs fontisan: delegates per-face work to FaceAuditor instead of fontisan's Commands::AuditCommand. The discovery and rollup logic is otherwise identical.
Constant Summary collapse
- FONT_EXTENSIONS =
%w[.ttf .otf .ttc .otc .dfont .woff .woff2 .pfb .pfa .svg].freeze
Instance Attribute Summary collapse
-
#skipped ⇒ Array<String>
readonly
Source files that could not be audited, formatted as "path: message".
Instance Method Summary collapse
- #audit ⇒ Models::Audit::LibrarySummary
-
#initialize(root_path, recursive:, options:, reference: nil) ⇒ LibraryAuditor
constructor
A new instance of LibraryAuditor.
Constructor Details
#initialize(root_path, recursive:, options:, reference: nil) ⇒ LibraryAuditor
Returns a new instance of LibraryAuditor.
33 34 35 36 37 38 39 40 |
# File 'lib/ucode/audit/library_auditor.rb', line 33 def initialize(root_path, recursive:, options:, reference: nil) @root_path = Pathname.new(root_path) @recursive = recursive @options = @reference = reference @aggregator = LibraryAggregator.new @skipped = [] end |
Instance Attribute Details
#skipped ⇒ Array<String> (readonly)
Returns source files that could not be audited, formatted as "path: message".
65 66 67 |
# File 'lib/ucode/audit/library_auditor.rb', line 65 def skipped @skipped end |
Instance Method Details
#audit ⇒ Models::Audit::LibrarySummary
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ucode/audit/library_auditor.rb', line 43 def audit paths = discover_font_paths reports = paths.flat_map { |p| audit_one(p) } rolled_up = aggregates(reports) Models::Audit::LibrarySummary.new( root_path: @root_path.to_s, total_files: paths.size, total_faces: reports.size, scanned_extensions: scanned_extensions(paths), aggregate_metrics: rolled_up[:aggregate_metrics].merge( total_size_bytes: paths.sum { |p| File.size(p) }, ), script_coverage: rolled_up[:script_coverage], duplicate_groups: rolled_up[:duplicate_groups], license_distribution: rolled_up[:license_distribution], per_face_reports: reports, ) end |