class Fontist::Macos::Catalog::BaseParser
Base parser for macOS Font catalogs Handles common parsing logic for Font7, Font8, etc.
Attributes
Public Class Methods
Source
# File lib/fontist/macos/catalog/base_parser.rb, line 12 def initialize(xml_path) @xml_path = xml_path @data = nil end
Public Instance Methods
Source
# File lib/fontist/macos/catalog/base_parser.rb, line 17 def assets posted_date_str = posted_date framework_ver = framework_version parse_assets.map do |asset_data| Asset.new(asset_data, posted_date: posted_date_str, framework_version: framework_ver) end end
Source
# File lib/fontist/macos/catalog/base_parser.rb, line 43 def catalog_version # Extract from filename: com_apple_MobileAsset_Font7.xml -> 7 File.basename(@xml_path).match(/Font(\d+)/)[1].to_i end
Source
# File lib/fontist/macos/catalog/base_parser.rb, line 48 def framework_version # Extract from filename: com_apple_MobileAsset_Font7.xml -> 7 File.basename(@xml_path).match(/Font(\d+)/)[1].to_i end
Source
# File lib/fontist/macos/catalog/base_parser.rb, line 26 def posted_date date_obj = data["postedDate"] return nil unless date_obj # Plist parser may return DateTime object directly if date_obj.is_a?(String) Time.parse(date_obj).utc.iso8601 elsif date_obj.respond_to?(:to_time) date_obj.to_time.utc.iso8601 else date_obj.to_s end rescue StandardError => e Fontist.ui.error("Could not parse postedDate: #{e.message}") nil end