fontist 1.7.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -10
- data/lib/fontist/cli.rb +2 -2
- data/lib/fontist/manifest/install.rb +0 -4
- data/lib/fontist/manifest/locations.rb +19 -19
- data/lib/fontist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfbc7b0d13e8084d44fe41d69ff1719a203a375cd75970cf8efa0abd2cd711af
|
4
|
+
data.tar.gz: 1a259f0e45ea264ca55c1e112cb25bd672f41532ae82c58989cf368f058d2374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82a25bf83f43b02f1e8a77717d9d240ebd55910bc0c529ce0ff09d434cad829c862c8db9564597159a3214b6cffa9dce2ee8f64a6f841f5dc589e10571a94c44
|
7
|
+
data.tar.gz: 91771cd423b516b6db27db7ef5e55cd24f01bea9fb368aa4331e0bc75a887e3df35d84a4fa08748e98bc41a16d8f80861cf584ff9cc6a61e938c3b7392ee94ee
|
data/README.md
CHANGED
@@ -136,20 +136,18 @@ operation you would do in any ruby object.
|
|
136
136
|
|
137
137
|
#### Locations
|
138
138
|
|
139
|
-
Fontist lets find font locations from a
|
139
|
+
Fontist lets find font locations from a manifest of the following format:
|
140
140
|
|
141
|
-
```
|
142
|
-
Segoe UI
|
143
|
-
|
144
|
-
- Bold
|
145
|
-
Roboto Mono:
|
146
|
-
- Regular
|
141
|
+
```ruby
|
142
|
+
{"Segoe UI"=>["Regular", "Bold"],
|
143
|
+
"Roboto Mono"=>["Regular"]}
|
147
144
|
```
|
148
145
|
|
149
|
-
Calling the following code returns a nested hash with font paths.
|
146
|
+
Calling the following code returns a nested hash with font paths and names.
|
147
|
+
Font name is useful to choose a specific font in a font collection file (TTC).
|
150
148
|
|
151
149
|
```ruby
|
152
|
-
Fontist::Manifest::Locations.
|
150
|
+
Fontist::Manifest::Locations.from_hash(manifest)
|
153
151
|
```
|
154
152
|
|
155
153
|
```ruby
|
@@ -169,7 +167,7 @@ Fontist lets not only to get font locations but also to install fonts from the
|
|
169
167
|
manifest:
|
170
168
|
|
171
169
|
```ruby
|
172
|
-
Fontist::Manifest::Install.
|
170
|
+
Fontist::Manifest::Install.from_hash(manifest, confirmation: "yes")
|
173
171
|
```
|
174
172
|
|
175
173
|
It will install fonts and return their locations:
|
@@ -185,6 +183,27 @@ It will install fonts and return their locations:
|
|
185
183
|
"paths"=>["/Users/user/.fontist/fonts/RobotoMono-VariableFont_wght.ttf"]}}}
|
186
184
|
```
|
187
185
|
|
186
|
+
#### Support of YAML format
|
187
|
+
|
188
|
+
Both commands support a YAML file as an input with a `from_file` method. For
|
189
|
+
example, if there is a `manifest.yml` file containing:
|
190
|
+
|
191
|
+
```yaml
|
192
|
+
Segoe UI:
|
193
|
+
- Regular
|
194
|
+
- Bold
|
195
|
+
Roboto Mono:
|
196
|
+
- Regular
|
197
|
+
```
|
198
|
+
|
199
|
+
Then the following calls would return font names and paths, as from the
|
200
|
+
`from_hash` method (see [Locations](#locations) and [Install](#install)).
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
Fontist::Manifest::Locations.from_file("manifest.yml")
|
204
|
+
Fontist::Manifest::Install.from_file("manifest.yml", confirmation: "yes")
|
205
|
+
```
|
206
|
+
|
188
207
|
### CLI
|
189
208
|
|
190
209
|
These commands makes possible to operate with fonts via command line. The CLI
|
data/lib/fontist/cli.rb
CHANGED
@@ -70,7 +70,7 @@ module Fontist
|
|
70
70
|
desc "manifest-locations MANIFEST",
|
71
71
|
"Get locations of fonts from MANIFEST (yaml)"
|
72
72
|
def manifest_locations(manifest)
|
73
|
-
paths = Fontist::Manifest::Locations.
|
73
|
+
paths = Fontist::Manifest::Locations.from_file(manifest)
|
74
74
|
print_yaml(paths)
|
75
75
|
success
|
76
76
|
rescue Fontist::Errors::ManifestCouldNotBeFoundError
|
@@ -82,7 +82,7 @@ module Fontist
|
|
82
82
|
desc "manifest-install MANIFEST", "Install fonts from MANIFEST (yaml)"
|
83
83
|
option :confirm_license, type: :boolean, desc: "Confirm license agreement"
|
84
84
|
def manifest_install(manifest)
|
85
|
-
paths = Fontist::Manifest::Install.
|
85
|
+
paths = Fontist::Manifest::Install.from_file(
|
86
86
|
manifest,
|
87
87
|
confirmation: options[:confirm_license] ? "yes" : "no"
|
88
88
|
)
|
@@ -5,8 +5,21 @@ module Fontist
|
|
5
5
|
@manifest = manifest
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
8
|
+
def self.from_file(file, **keywords)
|
9
|
+
raise Fontist::Errors::ManifestCouldNotBeFoundError unless File.exist?(file)
|
10
|
+
|
11
|
+
manifest = YAML.load_file(file)
|
12
|
+
raise Fontist::Errors::ManifestCouldNotBeReadError unless manifest.is_a?(Hash)
|
13
|
+
|
14
|
+
from_hash(manifest, **keywords)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.from_hash(manifest, **keywords)
|
18
|
+
if keywords.empty?
|
19
|
+
new(manifest).call
|
20
|
+
else
|
21
|
+
new(manifest, **keywords).call
|
22
|
+
end
|
10
23
|
end
|
11
24
|
|
12
25
|
def call
|
@@ -15,27 +28,14 @@ module Fontist
|
|
15
28
|
|
16
29
|
private
|
17
30
|
|
18
|
-
|
19
|
-
fonts.keys
|
20
|
-
end
|
21
|
-
|
22
|
-
def fonts
|
23
|
-
@fonts ||= begin
|
24
|
-
unless File.exist?(@manifest)
|
25
|
-
raise Fontist::Errors::ManifestCouldNotBeFoundError
|
26
|
-
end
|
27
|
-
|
28
|
-
fonts = YAML.load_file(@manifest)
|
29
|
-
unless fonts.is_a?(Hash)
|
30
|
-
raise Fontist::Errors::ManifestCouldNotBeReadError
|
31
|
-
end
|
31
|
+
attr_reader :manifest
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
def font_names
|
34
|
+
manifest.keys
|
35
35
|
end
|
36
36
|
|
37
37
|
def font_paths
|
38
|
-
|
38
|
+
manifest.map do |font, styles|
|
39
39
|
styles_to_ary = [styles].flatten
|
40
40
|
style_paths_map(font, styles_to_ary)
|
41
41
|
end
|
data/lib/fontist/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-12-
|
12
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: down
|