Module: Ucode::Glyphs::ResolverFactory

Defined in:
lib/ucode/glyphs/resolver_factory.rb

Overview

Single injection point for the 4-tier Resolver.

Both CanonicalBuildCommand and UniversalSet::BuildCommand need the same shape: open a Database, load the SourceConfig, run a SourceBuilder, wrap the resulting tier-1 sources in a Resolver. Extracting it here gives tests one seam to mock (or bypass) and prevents drift between the two call sites.

Class Method Summary collapse

Class Method Details

.build(version:, source_config_path: nil, install: DEFAULT_INSTALL, database: nil) ⇒ Ucode::Glyphs::Resolver

Parameters:

  • version (String)

    UCD version, used to open the Database when one is not supplied.

  • source_config_path (String, Pathname, nil) (defaults to: nil)

    override path to the Tier 1 font config YAML; nil uses the default.

  • install (Boolean) (defaults to: DEFAULT_INSTALL)

    pass through to SourceBuilder#tier1_sources — whether to fontist-install missing fonts eagerly.

  • database (Ucode::Database, nil) (defaults to: nil)

    an already-open Database, to skip re-opening when the caller already has one.

Returns:



27
28
29
30
31
32
33
# File 'lib/ucode/glyphs/resolver_factory.rb', line 27

def self.build(version:, source_config_path: nil,
               install: DEFAULT_INSTALL, database: nil)
  db = database || Ucode::Database.open(version)
  config = SourceConfig.new(path: resolve_config_path(source_config_path))
  builder = SourceBuilder.new(config: config, database: db)
  Resolver.new(sources: builder.tier1_sources(install: install))
end