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
Build FormatSpec from attributes
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/fontist/manifest.rb', line 22
def format_spec
FormatSpec.new(
format: format,
variable_axes: variable_axes,
prefer_variable: prefer_variable,
transcode_path: transcode_path,
keep_original: keep_original,
collection_index: collection_index,
)
end
|
#group_paths(locations: false) ⇒ Object
42
43
44
45
|
# File 'lib/fontist/manifest.rb', line 42
def group_paths(locations: false)
style_paths(locations: locations).group_by(&:type)
.transform_values { |group| style(group) }
end
|
#group_paths_empty? ⇒ Boolean
93
94
95
|
# File 'lib/fontist/manifest.rb', line 93
def group_paths_empty?
group_paths.compact.empty?
end
|
#install(confirmation: "no", hide_licenses: false, no_progress: false, location: nil) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/fontist/manifest.rb', line 56
def install(confirmation: "no", hide_licenses: false, no_progress: false,
location: nil)
validate_location_parameter!(location)
validate_platform_compatibility!
Fontist::Font.install(
name,
force: true,
confirmation: confirmation,
hide_licenses: hide_licenses,
no_progress: no_progress,
location: location,
format_spec: format_spec,
)
rescue Fontist::Errors::PlatformMismatchError => e
Fontist.ui.error(e.message)
raise
end
|
#style(styles_ary) ⇒ Object
47
48
49
50
|
# File 'lib/fontist/manifest.rb', line 47
def style(styles_ary)
{ "full_name" => styles_ary.first.full_name,
"paths" => styles_ary.filter_map(&:path) }
end
|
#style_paths(locations: false) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/fontist/manifest.rb', line 33
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/fontist/manifest.rb', line 76
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
|