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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 035a1318895900d90f27d2b5db8f08b86c64e6eb5e172ef81038c55305258756
4
- data.tar.gz: 5a748c9632995e504b448508d56d0e292a7429b1eaa86d08978bf6e54d67f9e7
3
+ metadata.gz: bfbc7b0d13e8084d44fe41d69ff1719a203a375cd75970cf8efa0abd2cd711af
4
+ data.tar.gz: 1a259f0e45ea264ca55c1e112cb25bd672f41532ae82c58989cf368f058d2374
5
5
  SHA512:
6
- metadata.gz: 1558eb54750ed4efaabe694b79e23a00ce3a51d6c026641ab58796737ff609cce23b92dd141524e90c8d7e55f11cc0537fe405ca849b9d0309e65e47d1b672fe
7
- data.tar.gz: 371d9283fa520c1dd036e22f600a5804a75af10b3a2d90bfe775432036ab51c12466696bb33a6614954c4de974889087255cdf2705b91731b6a0afa7ce9bef88
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 YAML manifest of the following format:
139
+ Fontist lets find font locations from a manifest of the following format:
140
140
 
141
- ```yml
142
- Segoe UI:
143
- - Regular
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.call(manifest_path)
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.call(manifest, confirmation: "yes")
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
@@ -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.call(manifest)
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.call(
85
+ paths = Fontist::Manifest::Install.from_file(
86
86
  manifest,
87
87
  confirmation: options[:confirm_license] ? "yes" : "no"
88
88
  )
@@ -8,10 +8,6 @@ module Fontist
8
8
  @confirmation = confirmation
9
9
  end
10
10
 
11
- def self.call(manifest, confirmation: "no")
12
- new(manifest, confirmation: confirmation).call
13
- end
14
-
15
11
  private
16
12
 
17
13
  def file_paths(font, style)
@@ -5,8 +5,21 @@ module Fontist
5
5
  @manifest = manifest
6
6
  end
7
7
 
8
- def self.call(manifest)
9
- new(manifest).call
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
- def font_names
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
- fonts
34
- end
33
+ def font_names
34
+ manifest.keys
35
35
  end
36
36
 
37
37
  def font_paths
38
- fonts.map do |font, styles|
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
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.7.2".freeze
2
+ VERSION = "1.7.3".freeze
3
3
  end
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.2
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-09 00:00:00.000000000 Z
12
+ date: 2020-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: down