Sha256: 9c7e934f1371a651b3e1e1630aaadafb0979842fa999b6e35de8c2e7669508d8
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module Fontist module Manifest class Locations def initialize(manifest) @manifest = manifest end def self.call(manifest) new(manifest).call end def call font_names.zip(font_paths).to_h end private def font_names fonts.keys end def fonts @fonts ||= begin unless File.exist?(@manifest) raise Fontist::Errors::ManifestCouldNotBeFoundError end fonts = YAML.load_file(@manifest) unless fonts.is_a?(Hash) raise Fontist::Errors::ManifestCouldNotBeReadError end fonts end end def font_paths fonts.map do |font, styles| styles_to_ary = [styles].flatten style_paths_map(font, styles_to_ary) end end def style_paths_map(font, names) paths = style_paths(font, names) names.zip(paths).to_h end def style_paths(font, names) names.map do |style| file_paths(font, style) end end def file_paths(font, style) Fontist::SystemFont.find_with_style(font, style).transform_keys(&:to_s) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fontist-1.7.0 | lib/fontist/manifest/locations.rb |