Sha256: 180e82c778f2288605a17c2c24f234190622801f5074a975eccd53357844c59c
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 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_name(font, style).transform_keys(&:to_s) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fontist-1.7.2 | lib/fontist/manifest/locations.rb |
fontist-1.7.1 | lib/fontist/manifest/locations.rb |