Class: Fontist::ManifestFont
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Fontist::ManifestFont
show all
- Defined in:
- lib/fontist/manifest.rb
Instance Method Summary
collapse
Instance Method Details
#find_font_with_name(font, style) ⇒ Object
#group_paths(locations: false) ⇒ Object
17
18
19
20
|
# 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
|
#group_paths_empty? ⇒ Boolean
58
59
60
|
# File 'lib/fontist/manifest.rb', line 58
def group_paths_empty?
group_paths.compact.empty?
end
|
#install(confirmation: "no", hide_licenses: false, no_progress: false) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# 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
|
#style(styles_ary) ⇒ Object
22
23
24
25
|
# 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
|
#style_paths(locations: false) ⇒ Object
8
9
10
11
12
13
14
15
|
# 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
|
#to_response(locations: false) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# 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
|