class Fontist::ManifestFont
Public Instance Methods
Source
# File lib/fontist/manifest.rb, line 27 def find_font_with_name(font, style) Fontist::SystemFont.find_styles(font, style) end
Source
# File lib/fontist/manifest.rb, line 17 def group_paths(locations: false) style_paths(locations: locations).group_by(&:type) .transform_values { |group| style(group) } end
Source
# File lib/fontist/manifest.rb, line 58 def group_paths_empty? group_paths.compact.empty? end
Source
# File lib/fontist/manifest.rb, line 31 def install(confirmation: "no", hide_licenses: false, no_progress: false) Fontist::Font.install( name, force: true, confirmation: confirmation, hide_licenses: hide_licenses, no_progress: no_progress, ) end
Source
# File lib/fontist/manifest.rb, line 22 def style(styles_ary) { "full_name" => styles_ary.first.full_name, "paths" => styles_ary.filter_map(&:path) } end
Source
# File lib/fontist/manifest.rb, line 8 def style_paths(locations: false) ary = Array(styles) (ary.empty? ? [nil] : ary).flat_map do |style| find_font_with_name(name, style).tap do |x| raise Errors::MissingFontError.new(name, style) if x.nil? && locations end end.compact end
Source
# File lib/fontist/manifest.rb, line 41 def to_response(locations: false) groups = group_paths(locations: locations) return self if groups.empty? ManifestResponseFont.new( name: name, styles: groups.map do |type, details| ManifestResponseFontStyle.new( type: type, full_name: details["full_name"], paths: details["paths"], ) end, ) end