fontist 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46371ff826db31f7fc1c4e5fefca2d6f237f0a874a896dbca6c4c2dbcb937255
4
- data.tar.gz: dc6a20cb42ce6649791e256a4d6cb8376c29d196c795e2e1869279caa1df8b5a
3
+ metadata.gz: 06c95de209b578a95a9b0d2bf19d196164ece01155a61685060c638af668743c
4
+ data.tar.gz: a2d621f546be67a09e94c4cad68f432642ec6c47d745c688e919652e3049ec7a
5
5
  SHA512:
6
- metadata.gz: 7ac9af8e04948c40b1b1fc488f6eeffebd7e598050d59224557f271b1deb328c639a67d153bad08b1a82e3869dda13525647db87e1b04269c0cf5e0b8c0ae295
7
- data.tar.gz: 680fbde53bf5482ae3e36a720b6e6482cac5a62c29efa1b9962b18c1d51d7e7cafd2ce154c2c484cdfd6211002b413f1df45b909341df1d6ac864585aa590450
6
+ metadata.gz: 938f320740216d01c7dc7e48b7a4a6070bba45d437be0e3b2c5846b3d1c28321967653b4b1ad13a6f112cab3e7ae72e74f708bd027022e875b2e4268693200bb
7
+ data.tar.gz: 602c750adddfc95ed2b7d83257a085b69c464c563ccbd314dc120f86c074d1e0aec243aacafba5bf4e73969ade9bc953b360764209db78fce7362102d1bff8fc
data/README.md CHANGED
@@ -399,16 +399,20 @@ bin/rspec
399
399
  All formulas are kept in the [formulas][fontist-formulas] repository. If you'd
400
400
  like to add a new one or change any existing, please refer to its documentation.
401
401
 
402
- ### Privare repos
402
+ ### Private repos
403
403
 
404
404
  There is an ability to use private fonts via private fontist repo. Fontist repo
405
405
  is a git repo which contains YAML formula files. Formulas can be created
406
406
  manually (see [examples](https://github.com/fontist/formulas/tree/master/Formulas)),
407
407
  or [auto-generated from an archive](#auto-generate-a-formula).
408
408
 
409
- A corresponding SSH key should be setup with ssh-agent in order to access this private repo.
409
+ A repo can be either HTTPS or SSH Git repo. In case of SSH, a corresponding SSH key
410
+ should be setup with ssh-agent in order to access this private repo.
410
411
 
411
- Private fontist repo can be set up with:
412
+ The `repo setup` command fetches a repo's formulas, and saves repo's name and url
413
+ for later use.
414
+
415
+ Internally all repos are stored at `~/.fontist/formulas/Formulas/private`.
412
416
 
413
417
  ```sh
414
418
  fontist repo setup NAME URL
@@ -418,15 +422,24 @@ E.g.
418
422
 
419
423
  ```sh
420
424
  fontist repo setup acme https://example.com/acme/formulas.git
425
+ # or
426
+ fontist repo setup acme git@example.com:acme/formulas.git
427
+ ```
428
+
429
+ Then you can just install fonts from this repo:
430
+
431
+ ```sh
432
+ fontist install "private font"
421
433
  ```
422
434
 
423
- Later, to fetch changes the following command can be used:
435
+ There is no need in any additional command to be run, but if you add new
436
+ formulas to your repo, you can fetch them with the `repo update` command:
424
437
 
425
438
  ```sh
426
439
  fontist repo update acme
427
440
  ```
428
441
 
429
- If there is a need to avoid using these formulas, the repo can be removed with:
442
+ If there is a need to avoid using private formulas, the repo can be removed with:
430
443
 
431
444
  ```sh
432
445
  fontist repo remove acme
data/lib/fontist/cli.rb CHANGED
@@ -13,6 +13,7 @@ module Fontist
13
13
  STATUS_FONT_INDEX_CORRUPTED = 7
14
14
  STATUS_REPO_NOT_FOUND = 8
15
15
  STATUS_MAIN_REPO_NOT_FOUND = 9
16
+ STATUS_REPO_COULD_NOT_BE_UPDATED = 10
16
17
 
17
18
  ERROR_TO_STATUS = {
18
19
  Fontist::Errors::UnsupportedFontError => [STATUS_NON_SUPPORTED_FONT_ERROR],
@@ -83,8 +84,11 @@ module Fontist
83
84
  desc "update", "Update formulas"
84
85
  def update
85
86
  Formula.update_formulas_repo
86
- Fontist.ui.say("Formulas have been successfully updated")
87
+ Fontist.ui.success("Formulas have been successfully updated.")
87
88
  success
89
+ rescue Fontist::Errors::RepoCouldNotBeUpdatedError => e
90
+ Fontist.ui.error(e.message)
91
+ STATUS_REPO_COULD_NOT_BE_UPDATED
88
92
  end
89
93
 
90
94
  desc "manifest-locations MANIFEST",
@@ -26,6 +26,8 @@ module Fontist
26
26
 
27
27
  class RepoNotFoundError < GeneralError; end
28
28
 
29
+ class RepoCouldNotBeUpdatedError < GeneralError; end
30
+
29
31
  class TamperedFileError < GeneralError; end
30
32
 
31
33
  class TimeoutError < GeneralError; end
@@ -1,22 +1,12 @@
1
1
  require "fontist/index"
2
2
  require "fontist/helpers"
3
+ require "fontist/update"
3
4
  require "git"
4
5
 
5
6
  module Fontist
6
7
  class Formula
7
8
  def self.update_formulas_repo
8
- dir = File.dirname(Fontist.formulas_repo_path)
9
- FileUtils.mkdir_p(dir) unless File.exist?(dir)
10
-
11
- if Dir.exist?(Fontist.formulas_repo_path)
12
- Git.open(Fontist.formulas_repo_path).pull
13
- else
14
- Git.clone(Fontist.formulas_repo_url,
15
- Fontist.formulas_repo_path,
16
- depth: 1)
17
- end
18
-
19
- Index.rebuild
9
+ Update.call
20
10
  end
21
11
 
22
12
  def self.all
data/lib/fontist/repo.rb CHANGED
@@ -29,6 +29,12 @@ module Fontist
29
29
  Index.rebuild
30
30
  end
31
31
 
32
+ def list
33
+ Dir.glob(Fontist.private_formulas_path.join("*"))
34
+ .select { |path| File.directory?(path) }
35
+ .map { |path| File.basename(path) }
36
+ end
37
+
32
38
  private
33
39
 
34
40
  def ensure_private_formulas_path_exists
@@ -1,7 +1,8 @@
1
1
  module Fontist
2
2
  class RepoCLI < Thor
3
3
  desc "setup NAME URL",
4
- "Setup a custom fontist repo named NAME for the repository at URL"
4
+ "Setup a custom fontist repo named NAME for the repository at URL " \
5
+ "and fetches its formulas"
5
6
  def setup(name, url)
6
7
  Repo.setup(name, url)
7
8
  Fontist.ui.success(
@@ -32,6 +33,14 @@ module Fontist
32
33
  handle_repo_not_found(name)
33
34
  end
34
35
 
36
+ desc "list", "List fontist repos"
37
+ def list
38
+ Repo.list.each do |name|
39
+ Fontist.ui.say(name)
40
+ end
41
+ CLI::STATUS_SUCCESS
42
+ end
43
+
35
44
  private
36
45
 
37
46
  def handle_repo_not_found(name)
@@ -0,0 +1,64 @@
1
+ module Fontist
2
+ class Update
3
+ def self.call
4
+ new.call
5
+ end
6
+
7
+ def call
8
+ update_main_repo
9
+ update_private_repos
10
+ ensure
11
+ rebuild_index
12
+ end
13
+
14
+ private
15
+
16
+ def update_main_repo
17
+ dir = File.dirname(Fontist.formulas_repo_path)
18
+ FileUtils.mkdir_p(dir) unless File.exist?(dir)
19
+
20
+ if Dir.exist?(Fontist.formulas_repo_path)
21
+ Git.open(Fontist.formulas_repo_path).pull
22
+ else
23
+ Git.clone(Fontist.formulas_repo_url,
24
+ Fontist.formulas_repo_path,
25
+ depth: 1)
26
+ end
27
+ end
28
+
29
+ def update_private_repos
30
+ private_repos.each do |path|
31
+ update_repo(path)
32
+ end
33
+ end
34
+
35
+ def update_repo(path)
36
+ Git.open(path).pull
37
+ rescue Git::GitExecuteError => e
38
+ name = repo_name(path)
39
+ raise Errors::RepoCouldNotBeUpdatedError.new(<<~MSG.chomp)
40
+ Formulas repo '#{name}' could not be updated.
41
+ Please consider reinitializing it with:
42
+ fontist remove #{name}
43
+ fontist setup #{name} REPO_URL
44
+
45
+ Git error:
46
+ #{e.message}
47
+ MSG
48
+ end
49
+
50
+ def private_repos
51
+ Dir.glob(Fontist.private_formulas_path.join("*")).select do |path|
52
+ File.directory?(path)
53
+ end
54
+ end
55
+
56
+ def repo_name(path)
57
+ File.basename(path)
58
+ end
59
+
60
+ def rebuild_index
61
+ Index.rebuild
62
+ end
63
+ end
64
+ end
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.9.0".freeze
2
+ VERSION = "1.9.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-22 00:00:00.000000000 Z
11
+ date: 2021-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -307,6 +307,7 @@ files:
307
307
  - lib/fontist/system.yml
308
308
  - lib/fontist/system_font.rb
309
309
  - lib/fontist/system_index.rb
310
+ - lib/fontist/update.rb
310
311
  - lib/fontist/utils.rb
311
312
  - lib/fontist/utils/cache.rb
312
313
  - lib/fontist/utils/downloader.rb