Class: Fontisan::Audit::LibraryAuditor
- Inherits:
-
Object
- Object
- Fontisan::Audit::LibraryAuditor
- Defined in:
- lib/fontisan/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 Commands::AuditCommand, 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 logged and skipped so a corrupt file doesn't abort the whole pass.
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.
Instance Method Summary collapse
- #audit ⇒ Models::Audit::LibrarySummary
-
#initialize(root_path, recursive:, options:) ⇒ LibraryAuditor
constructor
A new instance of LibraryAuditor.
Constructor Details
#initialize(root_path, recursive:, options:) ⇒ LibraryAuditor
Returns a new instance of LibraryAuditor.
25 26 27 28 29 30 31 |
# File 'lib/fontisan/audit/library_auditor.rb', line 25 def initialize(root_path, recursive:, options:) @root_path = Pathname.new(root_path) @recursive = recursive @options = @aggregator = LibraryAggregator.new @skipped = [] end |
Instance Attribute Details
#skipped ⇒ Array<String> (readonly)
Returns source files that could not be audited.
55 56 57 |
# File 'lib/fontisan/audit/library_auditor.rb', line 55 def skipped @skipped end |
Instance Method Details
#audit ⇒ Models::Audit::LibrarySummary
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fontisan/audit/library_auditor.rb', line 34 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 |