fontist 1.8.12 → 1.10.0

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: d1ece96735fa8114f5ce56d56217b20208e8c5dced1c8d0b4092094ebac4ec17
4
- data.tar.gz: 30e6189789d580d5c6bd56aa12d02c91057a05a286ec513469c4897d193a2542
3
+ metadata.gz: d2ed5346597364ad2d6cf6d2ecdc575baee6590f164cd79888a85c7ae0a67ed5
4
+ data.tar.gz: f7378c2d93061211db416dfa4ce7e49450dfd50ec01618f79dedb483d1a258ee
5
5
  SHA512:
6
- metadata.gz: 20044f9435f70398c851eca878a846dad762c065ace4de9efcd6b1c05a3b5c6e9ab1f6bef4aefdf6231db020f3d5cb4454c5a2e4cf4c1f151f19288890449b11
7
- data.tar.gz: d93ca29eedc83eeb4fb60b574ae254b277eb210e2e1e8fbcad68ad6a15d86f3f2fe981f549444fdfb13f559221cd2bc03b73f0a00a89496f7a22482c6493afa3
6
+ metadata.gz: 30e8c3f17d17c275e1942a07c113feda490e426afa762e4a6c93a283a99f97010da04b4bd954c13e8cc2504211ad273b9aeb84b6af12232d46cd1d19b7c8b244
7
+ data.tar.gz: 6d8e216241908538339ecb0a06a92f0b31a590eef0ffe2e81bee78a97b18204f4fc4f2b70113a79ea1d87f6c815b125bfb58e6db500942c5d1019098bb3812a0
@@ -0,0 +1,35 @@
1
+ name: metanorma
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
11
+ runs-on: ${{ matrix.os }}
12
+ continue-on-error: ${{ matrix.experimental }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: [ '2.5', '2.6', '2.7', '3.0' ]
17
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
18
+ experimental: [ true ]
19
+ steps:
20
+ - uses: actions/checkout@master
21
+ with:
22
+ repository: metanorma/metanorma
23
+
24
+ - uses: actions/checkout@master
25
+ with:
26
+ path: "fontist"
27
+
28
+ - run: 'echo ''gem "fontist", path: "./fontist"'' > Gemfile.devel'
29
+
30
+ - uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby }}
33
+ bundler-cache: true
34
+
35
+ - run: bundle exec rake
@@ -2,7 +2,7 @@ name: rspec
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
5
+ branches: [ main ]
6
6
  pull_request:
7
7
 
8
8
  jobs:
@@ -13,19 +13,9 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby: [ '2.4', '2.5', '2.6', '2.7' ]
16
+ ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0' ]
17
17
  os: [ ubuntu-latest, windows-latest, macos-latest ]
18
18
  experimental: [ false ]
19
- include:
20
- - ruby: '3.0'
21
- os: 'ubuntu-latest'
22
- experimental: true
23
- - ruby: '3.0'
24
- os: 'windows-latest'
25
- experimental: true
26
- - ruby: '3.0'
27
- os: 'macos-latest'
28
- experimental: true
29
19
 
30
20
  steps:
31
21
  - uses: actions/checkout@master
data/README.md CHANGED
@@ -34,6 +34,18 @@ After installation please fetch formulas to your system:
34
34
  fontist update
35
35
  ```
36
36
 
37
+ ### Dependencies
38
+
39
+ Depends on
40
+ [ffi-libarchive-binary](https://github.com/fontist/ffi-libarchive-binary) which
41
+ has the following requirements:
42
+
43
+ * zlib
44
+ * Expat
45
+ * OpenSSL (for Linux only)
46
+
47
+ These dependencies are generally present on all systems.
48
+
37
49
  ## Usage
38
50
 
39
51
  ### Font
@@ -387,6 +399,70 @@ bin/rspec
387
399
  All formulas are kept in the [formulas][fontist-formulas] repository. If you'd
388
400
  like to add a new one or change any existing, please refer to its documentation.
389
401
 
402
+ ### Private repos
403
+
404
+ There is an ability to use private fonts via private fontist repo. Fontist repo
405
+ is a git repo which contains YAML formula files. Formulas can be created
406
+ manually (see [examples](https://github.com/fontist/formulas/tree/master/Formulas)),
407
+ or [auto-generated from an archive](#auto-generate-a-formula).
408
+
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.
411
+
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`.
416
+
417
+ ```sh
418
+ fontist repo setup NAME URL
419
+ ```
420
+
421
+ E.g.
422
+
423
+ ```sh
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"
433
+ ```
434
+
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:
437
+
438
+ ```sh
439
+ fontist repo update acme
440
+ ```
441
+
442
+ If there is a need to avoid using private formulas, the repo can be removed with:
443
+
444
+ ```sh
445
+ fontist repo remove acme
446
+ ```
447
+
448
+ ### Private formulas
449
+
450
+ Authorization of private archives in private formulas can be implemented with
451
+ headers. Here is an example which works with Github releases:
452
+
453
+ ```yaml
454
+ resources:
455
+ fonts.zip:
456
+ urls:
457
+ - url: https://example.com/repos/acme/formulas/releases/assets/38777461
458
+ headers:
459
+ Accept: application/octet-stream
460
+ Authorization: token ghp_1234567890abcdefghi
461
+ ```
462
+
463
+ A token can be obtained on [this page](https://github.com/settings/tokens).
464
+ It should have at least the `repo` scope.
465
+
390
466
  ### Auto-generate a formula
391
467
 
392
468
  A formula could be generated from a fonts archive. Just specify a URL to the
@@ -397,20 +473,21 @@ fontist create-formula https://www.latofonts.com/download/lato2ofl-zip/
397
473
  cp lato.yml ~/.fontist/formulas/Formulas/
398
474
  ```
399
475
 
476
+ Though indexes are auto-generated now, maintainers should rebuild indexes
477
+ in the main repo for backward compatibility with fontist prior to 1.9.x versions.
400
478
  A formula index should be rebuild, when a new formula is generated or an
401
479
  existing one changed:
402
480
 
403
481
  ```sh
404
- fontist rebuild-index
482
+ fontist rebuild-index --main-repo
405
483
  ```
406
484
 
407
- Then, both the formula and the updated index should be commited and pushed to
485
+ Then, both the formula and the updated indexes should be commited and pushed to
408
486
  the formula repository:
409
487
 
410
488
  ```sh
411
489
  cd ~/.fontist/formulas
412
- git add Formulas/lato.yml
413
- git add index.yml
490
+ git add Formulas/lato.yml index.yml filename_index.yml
414
491
  git commit -m "Add Lato formula"
415
492
  ```
416
493
 
@@ -429,7 +506,7 @@ repository [formulas][fontist-formulas]:
429
506
 
430
507
  ```
431
508
  cd ~/.fontist/formulas
432
- git add Formulas/google
509
+ git add Formulas/google index.yml filename_index.yml
433
510
  git commit -m "Google Fonts update"
434
511
  git push
435
512
  ```
@@ -442,8 +519,7 @@ can be updated with:
442
519
  ```sh
443
520
  fontist import-sil
444
521
  cd ~/.fontist/formulas
445
- git add Formulas/sil
446
- git add index.yml
522
+ git add Formulas/sil index.yml filename_index.yml
447
523
  git commit -m "SIL fonts update"
448
524
  git push
449
525
  ```
data/fontist.gemspec CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "nokogiri", "~> 1.0"
41
41
  spec.add_development_dependency "rake", "~> 13"
42
42
  spec.add_development_dependency "rspec", "~> 3.0"
43
- spec.add_development_dependency "rubocop", "0.75.0"
43
+ spec.add_development_dependency "rubocop", "1.5.2"
44
44
  spec.add_development_dependency "rubocop-rails"
45
45
  spec.add_development_dependency "rubocop-performance"
46
46
  spec.add_development_dependency "ruby-protocol-buffers", "~> 1.0"
data/lib/fontist.rb CHANGED
@@ -7,10 +7,10 @@ require "singleton"
7
7
  require "fontist/errors"
8
8
  require "fontist/version"
9
9
 
10
+ require "fontist/repo"
10
11
  require "fontist/font"
11
12
  require "fontist/formula"
12
13
  require "fontist/system_font"
13
- require "fontist/fontist_font"
14
14
  require "fontist/manifest"
15
15
  require "fontist/helpers"
16
16
 
@@ -28,7 +28,11 @@ module Fontist
28
28
  end
29
29
 
30
30
  def self.fontist_path
31
- Pathname.new(ENV["FONTIST_PATH"] || File.join(Dir.home, ".fontist"))
31
+ Pathname.new(ENV["FONTIST_PATH"] || default_fontist_path)
32
+ end
33
+
34
+ def self.default_fontist_path
35
+ Pathname.new(File.join(Dir.home, ".fontist"))
32
36
  end
33
37
 
34
38
  def self.fonts_path
@@ -47,6 +51,10 @@ module Fontist
47
51
  Fontist.formulas_repo_path.join("Formulas")
48
52
  end
49
53
 
54
+ def self.private_formulas_path
55
+ Fontist.formulas_path.join("private")
56
+ end
57
+
50
58
  def self.downloads_path
51
59
  Fontist.fontist_path.join("downloads")
52
60
  end
@@ -56,14 +64,52 @@ module Fontist
56
64
  end
57
65
 
58
66
  def self.system_index_path
59
- Fontist.fontist_path.join("system_index.yml")
67
+ Fontist.fontist_path.join("system_index.default_family.yml")
68
+ end
69
+
70
+ def self.system_preferred_family_index_path
71
+ Fontist.fontist_path.join("system_index.preferred_family.yml")
72
+ end
73
+
74
+ def self.fontist_index_path
75
+ Fontist.fontist_path.join("fontist_index.default_family.yml")
76
+ end
77
+
78
+ def self.fontist_preferred_family_index_path
79
+ Fontist.fontist_path.join("fontist_index.preferred_family.yml")
60
80
  end
61
81
 
62
82
  def self.formula_index_path
63
- Fontist.formulas_repo_path.join("index.yml")
83
+ Fontist.formula_index_dir.join("formula_index.default_family.yml")
84
+ end
85
+
86
+ def self.formula_preferred_family_index_path
87
+ @formula_preferred_family_index_path ||
88
+ Fontist.formula_index_dir.join("formula_index.preferred_family.yml")
89
+ end
90
+
91
+ def self.formula_preferred_family_index_path=(path)
92
+ @formula_preferred_family_index_path = path
64
93
  end
65
94
 
66
95
  def self.formula_filename_index_path
67
- Fontist.formulas_repo_path.join("filename_index.yml")
96
+ @formula_filename_index_path ||
97
+ Fontist.formula_index_dir.join("filename_index.yml")
98
+ end
99
+
100
+ def self.formula_filename_index_path=(path)
101
+ @formula_filename_index_path = path
102
+ end
103
+
104
+ def self.formula_index_dir
105
+ Fontist.fontist_path
106
+ end
107
+
108
+ def self.preferred_family?
109
+ !!@preferred_family
110
+ end
111
+
112
+ def self.preferred_family=(bool)
113
+ @preferred_family = bool
68
114
  end
69
115
  end
data/lib/fontist/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "thor"
2
+ require "fontist/repo_cli"
2
3
 
3
4
  module Fontist
4
5
  class CLI < Thor
@@ -10,6 +11,9 @@ module Fontist
10
11
  STATUS_MANIFEST_COULD_NOT_BE_FOUND_ERROR = 5
11
12
  STATUS_MANIFEST_COULD_NOT_BE_READ_ERROR = 6
12
13
  STATUS_FONT_INDEX_CORRUPTED = 7
14
+ STATUS_REPO_NOT_FOUND = 8
15
+ STATUS_MAIN_REPO_NOT_FOUND = 9
16
+ STATUS_REPO_COULD_NOT_BE_UPDATED = 10
13
17
 
14
18
  ERROR_TO_STATUS = {
15
19
  Fontist::Errors::UnsupportedFontError => [STATUS_NON_SUPPORTED_FONT_ERROR],
@@ -20,12 +24,18 @@ module Fontist
20
24
  Fontist::Errors::ManifestCouldNotBeReadError => [STATUS_MANIFEST_COULD_NOT_BE_READ_ERROR,
21
25
  "Manifest could not be read."],
22
26
  Fontist::Errors::FontIndexCorrupted => [STATUS_FONT_INDEX_CORRUPTED],
27
+ Fontist::Errors::RepoNotFoundError => [STATUS_REPO_NOT_FOUND],
28
+ Fontist::Errors::MainRepoNotFoundError => [STATUS_MAIN_REPO_NOT_FOUND],
23
29
  }.freeze
24
30
 
25
31
  def self.exit_on_failure?
26
32
  false
27
33
  end
28
34
 
35
+ class_option :preferred_family,
36
+ type: :boolean,
37
+ desc: "Use Preferred Family when available"
38
+
29
39
  desc "install FONT", "Install font"
30
40
  option :force, type: :boolean, aliases: :f,
31
41
  desc: "Install even if it's already installed in system"
@@ -33,6 +43,7 @@ module Fontist
33
43
  option :hide_licenses, type: :boolean, desc: "Hide license texts"
34
44
  option :no_progress, type: :boolean, desc: "Hide download progress"
35
45
  def install(font)
46
+ handle_class_options(options)
36
47
  Fontist::Font.install(
37
48
  font,
38
49
  force: options[:force],
@@ -47,6 +58,7 @@ module Fontist
47
58
 
48
59
  desc "uninstall/remove FONT", "Uninstall font by font or formula"
49
60
  def uninstall(font)
61
+ handle_class_options(options)
50
62
  fonts_paths = Fontist::Font.uninstall(font)
51
63
  Fontist.ui.success("These fonts are removed:")
52
64
  Fontist.ui.success(fonts_paths.join("\n"))
@@ -58,6 +70,7 @@ module Fontist
58
70
 
59
71
  desc "status [FONT]", "Show paths of FONT or all fonts"
60
72
  def status(font = nil)
73
+ handle_class_options(options)
61
74
  paths = Fontist::Font.status(font)
62
75
  return error("No font is installed.", STATUS_MISSING_FONT_ERROR) if paths.empty?
63
76
 
@@ -68,6 +81,7 @@ module Fontist
68
81
 
69
82
  desc "list [FONT]", "List installation status of FONT or fonts in fontist"
70
83
  def list(font = nil)
84
+ handle_class_options(options)
71
85
  formulas = Fontist::Font.list(font)
72
86
  print_list(formulas)
73
87
  success
@@ -77,14 +91,19 @@ module Fontist
77
91
 
78
92
  desc "update", "Update formulas"
79
93
  def update
94
+ handle_class_options(options)
80
95
  Formula.update_formulas_repo
81
- Fontist.ui.say("Formulas have been successfully updated")
96
+ Fontist.ui.success("Formulas have been successfully updated.")
82
97
  success
98
+ rescue Fontist::Errors::RepoCouldNotBeUpdatedError => e
99
+ Fontist.ui.error(e.message)
100
+ STATUS_REPO_COULD_NOT_BE_UPDATED
83
101
  end
84
102
 
85
103
  desc "manifest-locations MANIFEST",
86
104
  "Get locations of fonts from MANIFEST (yaml)"
87
105
  def manifest_locations(manifest)
106
+ handle_class_options(options)
88
107
  paths = Fontist::Manifest::Locations.from_file(manifest)
89
108
  print_yaml(paths)
90
109
  success
@@ -96,6 +115,7 @@ module Fontist
96
115
  option :accept_all_licenses, type: :boolean, aliases: "--confirm-license", desc: "Accept all license agreements"
97
116
  option :hide_licenses, type: :boolean, desc: "Hide license texts"
98
117
  def manifest_install(manifest)
118
+ handle_class_options(options)
99
119
  paths = Fontist::Manifest::Install.from_file(
100
120
  manifest,
101
121
  confirmation: options[:accept_all_licenses] ? "yes" : "no",
@@ -115,6 +135,7 @@ module Fontist
115
135
  option :subdir, desc: "Subdirectory to take fonts from, starting with the " \
116
136
  "root dir, e.g.: stixfonts-2.10/fonts/static_otf. May include `fnmatch` patterns."
117
137
  def create_formula(url)
138
+ handle_class_options(options)
118
139
  require "fontist/import/create_formula"
119
140
  name = Fontist::Import::CreateFormula.new(url, options).call
120
141
  Fontist.ui.say("#{name} formula has been successfully created")
@@ -123,23 +144,43 @@ module Fontist
123
144
 
124
145
  desc "rebuild-index", "Rebuild formula index (used by formulas maintainers)"
125
146
  long_desc <<-LONGDESC
126
- This index is pre-built and served with formulas, so there is no need
127
- update it unless something changes in the formulas repo.
147
+ Index should be rebuilt when any formula changes.
148
+
149
+ It is done automatically when formulas are updated, or private formulas
150
+ are set up.
128
151
  LONGDESC
152
+ option :main_repo, type: :boolean,
153
+ desc: "Updates indexes in the main repo (for backward " \
154
+ "compatibility with versions prior to 1.9)"
129
155
  def rebuild_index
130
- Fontist::Index.rebuild
156
+ handle_class_options(options)
157
+
158
+ if options[:main_repo]
159
+ Fontist::Index.rebuild_for_main_repo
160
+ else
161
+ Fontist::Index.rebuild
162
+ end
163
+
131
164
  Fontist.ui.say("Formula index has been rebuilt.")
132
165
  STATUS_SUCCESS
133
166
  end
134
167
 
135
168
  desc "import-sil", "Import formulas from SIL"
136
169
  def import_sil
170
+ handle_class_options(options)
137
171
  require "fontist/import/sil_import"
138
172
  Fontist::Import::SilImport.new.call
139
173
  end
140
174
 
175
+ desc "repo SUBCOMMAND ...ARGS", "Manage custom repositories"
176
+ subcommand "repo", Fontist::RepoCLI
177
+
141
178
  private
142
179
 
180
+ def handle_class_options(options)
181
+ Fontist.preferred_family = options[:preferred_family]
182
+ end
183
+
143
184
  def success
144
185
  STATUS_SUCCESS
145
186
  end