Class: Fontist::ManifestRequestFont

Inherits:
ManifestFont
  • Object
show all
Defined in:
lib/fontist/manifest_request.rb

Instance Method Summary collapse

Methods inherited from ManifestFont

#find_font_with_name, #group_paths, #group_paths_empty?, #install, #style, #style_paths

Instance Method Details

#to_responseObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fontist/manifest_request.rb', line 6

def to_response
  font_styles = locate_styles.map do |style, detailed_styles|
    # puts "Detailed styles for #{name}: #{detailed_styles.inspect}"

    if detailed_styles.nil? || detailed_styles.empty?
      Fontist.ui.error("Font #{name} with style #{style} not found, skipping")
      ManifestResponseFontStyle.new(
        type: style,
      )
    else
      ManifestResponseFontStyle.new(
        full_name: detailed_styles.first.full_name,
        type: detailed_styles.first.type,
        paths: detailed_styles.map(&:path),
      )
    end
  end

  ManifestResponseFont.new(
    name: name,
    styles: font_styles,
  )
end