Class: Fontist::MacosFrameworkMetadata
- Inherits:
-
Object
- Object
- Fontist::MacosFrameworkMetadata
- Defined in:
- lib/fontist/macos_framework_metadata.rb
Overview
Loads and provides access to macOS font framework metadata
This class centralizes framework-specific information that was previously stored in individual formulas, enabling proper separation of concerns.
Constant Summary collapse
- METADATA =
{ 3 => { "min_macos_version" => "10.12", "max_macos_version" => "10.12", "asset_path" => "/System/Library/Assets", "parser_class" => "Fontist::Macos::Catalog::Font3Parser", "description" => "Font3 framework (macOS Sierra)", }, 4 => { "min_macos_version" => "10.13", "max_macos_version" => "10.13", "asset_path" => "/System/Library/Assets", "parser_class" => "Fontist::Macos::Catalog::Font4Parser", "description" => "Font4 framework (macOS High Sierra)", }, 5 => { "min_macos_version" => "10.14", "max_macos_version" => "10.15", "asset_path" => "/System/Library/AssetsV2", "parser_class" => "Fontist::Macos::Catalog::Font5Parser", "description" => "Font5 framework (macOS Mojave, Catalina)", }, 6 => { "min_macos_version" => "10.15", "max_macos_version" => "11.99", "asset_path" => "/System/Library/AssetsV2", "parser_class" => "Fontist::Macos::Catalog::Font6Parser", "description" => "Font6 framework (macOS Catalina, Big Sur)", }, 7 => { "min_macos_version" => "12.0", "max_macos_version" => "15.99", "asset_path" => "/System/Library/AssetsV2", "parser_class" => "Fontist::Macos::Catalog::Font7Parser", "description" => "Font7 framework (macOS Monterey, Ventura, Sonoma, Sequoia)", }, 8 => { "min_macos_version" => "26.0", "max_macos_version" => nil, "asset_path" => "/System/Library/AssetsV2", "parser_class" => "Fontist::Macos::Catalog::Font8Parser", "description" => "Font8 framework (macOS Tahoe+)", }, }.freeze
Class Method Summary collapse
-
.asset_path(framework_version) ⇒ String?
Gets the asset path for a given framework.
-
.compatible_with_macos?(framework_version, macos_version) ⇒ Boolean
Checks if a framework version is compatible with a specific macOS version.
-
.description(framework_version) ⇒ String
Gets a description for a framework version.
-
.framework_for_macos(macos_version) ⇒ Integer?
Determines which framework version to use for a given macOS version.
-
.max_macos_version(framework_version) ⇒ String?
Gets the maximum macOS version for a given framework.
-
.metadata ⇒ Hash
Returns the framework metadata.
-
.min_macos_version(framework_version) ⇒ String?
Gets the minimum macOS version for a given framework.
-
.parser_class(framework_version) ⇒ String
Gets the parser class name for a given framework.
-
.system_install_path(framework_version) ⇒ String?
Gets the system installation path for a given framework.
Class Method Details
.asset_path(framework_version) ⇒ String?
Gets the asset path for a given framework
123 124 125 |
# File 'lib/fontist/macos_framework_metadata.rb', line 123 def asset_path(framework_version) .dig(framework_version, "asset_path") end |
.compatible_with_macos?(framework_version, macos_version) ⇒ Boolean
Checks if a framework version is compatible with a specific macOS version
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/fontist/macos_framework_metadata.rb', line 91 def compatible_with_macos?(framework_version, macos_version) min_version = min_macos_version(framework_version) return false unless min_version version = Gem::Version.new(macos_version) min = Gem::Version.new(min_version) return false if version < min max_version = max_macos_version(framework_version) return true unless max_version max = Gem::Version.new(max_version) version <= max rescue StandardError => e Fontist.ui.error("Error checking macOS compatibility: #{e.}") false end |
.description(framework_version) ⇒ String
Gets a description for a framework version
114 115 116 117 |
# File 'lib/fontist/macos_framework_metadata.rb', line 114 def description(framework_version) .dig(framework_version, "description") || "Unknown framework #{framework_version}" end |
.framework_for_macos(macos_version) ⇒ Integer?
Determines which framework version to use for a given macOS version
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/fontist/macos_framework_metadata.rb', line 142 def framework_for_macos(macos_version) return nil unless macos_version Gem::Version.new(macos_version) # Search for compatible framework in reverse order (newest first) .keys.sort.reverse.each do |framework_version| if compatible_with_macos?(framework_version, macos_version) return framework_version end end nil rescue StandardError => e Fontist.ui.error("Error determining framework for macOS #{macos_version}: #{e.}") nil end |
.max_macos_version(framework_version) ⇒ String?
Gets the maximum macOS version for a given framework
74 75 76 |
# File 'lib/fontist/macos_framework_metadata.rb', line 74 def max_macos_version(framework_version) .dig(framework_version, "max_macos_version") end |
.metadata ⇒ Hash
Returns the framework metadata
58 59 60 |
# File 'lib/fontist/macos_framework_metadata.rb', line 58 def METADATA end |
.min_macos_version(framework_version) ⇒ String?
Gets the minimum macOS version for a given framework
66 67 68 |
# File 'lib/fontist/macos_framework_metadata.rb', line 66 def min_macos_version(framework_version) .dig(framework_version, "min_macos_version") end |
.parser_class(framework_version) ⇒ String
Gets the parser class name for a given framework
82 83 84 |
# File 'lib/fontist/macos_framework_metadata.rb', line 82 def parser_class(framework_version) .dig(framework_version, "parser_class") end |
.system_install_path(framework_version) ⇒ String?
Gets the system installation path for a given framework
131 132 133 134 135 136 |
# File 'lib/fontist/macos_framework_metadata.rb', line 131 def system_install_path(framework_version) base = asset_path(framework_version) return nil unless base "#{base}/com_apple_MobileAsset_Font#{framework_version}" end |