fontist 1.15.1 → 1.16.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: b05f079e527eb6128f6525bd4923886e5181d266a4cf88151a4131551694de15
4
- data.tar.gz: 1b8ab3e7b58c1c96aa9565d0b244475e047d48823ae9deec6fb194ed95201de0
3
+ metadata.gz: 14a836d048cc0ce0d74885f256e3d7cb48466efcadd75008207e1568927ca8cc
4
+ data.tar.gz: 468355d3c50412aef7642ad44abf204edbf827a81d3ccfe327f274a90cddedcd
5
5
  SHA512:
6
- metadata.gz: 5aa9bbfcf8b155bd876c5f9d28f37fcbe13d1cb6729ecf7056e298457834370973d0898e80af6515a96e904255fe1da027545a0f3c6d601dc41cc26cd211c060
7
- data.tar.gz: 6bae05a6ee7445abb41ee724fb01f07ebf2d7a7222ffc09744bb8b5acd4e2119949b35860f7b21d6bbdc2f8e81545a8115ccd7f2846beab1397842c5ae6b3e76
6
+ metadata.gz: 62e88a6ac1766b61ffe5db70b36f9b0bb8316d80c048d8df8de57e39e3387de1fd60c3cff1094f0b235d7bfab0979d2b4e4ed01eba12125852f745327e8641b1
7
+ data.tar.gz: 97338d5eee1a8df78555281d9bc765499f30c86b98913bae5b21729745e5e983ed257e8ee51d543802e69dc734eee64f464dd8b319c534c3b06c768a65267817
@@ -82,7 +82,7 @@ jobs:
82
82
  needs: prepare
83
83
  if: needs.prepare.outputs.push-for-tag != 'true'
84
84
 
85
- continue-on-error: ${{ matrix.ruby.experimental }}
85
+ continue-on-error: ${{ matrix.ruby.experimental || matrix.os == 'windows-latest' }} # workaround https://github.com/metanorma/metanorma/issues/288
86
86
  strategy:
87
87
  fail-fast: false
88
88
  max-parallel: 5
data/README.adoc CHANGED
@@ -123,7 +123,7 @@ for the newest version of the font among formulas with size below a limit
123
123
  (300 MB). This behavior can be changed with options.
124
124
 
125
125
  NOTE: If styles of a font are spread among several formulas, then all
126
- available formulas would be installed.
126
+ available styles from all formulas would be installed.
127
127
 
128
128
  Supported options:
129
129
 
@@ -936,6 +936,33 @@ its font location was only obtainable using the full "`Courier New`" font name.
936
936
  From v1.10 onwards the behavior has been made consistent -- only the proper
937
937
  "`Courier New`" name should be used.
938
938
 
939
+ [[install-font-change]]
940
+ ==== To v1.16+
941
+
942
+ Fontist versions beyond v1.16 treats the `font` argument of the `install`
943
+ command differently.
944
+ After the upgrade, please ensure all required fonts are specified when using
945
+ `fontist install`, `fontist manifest-install` (and their corresponding Ruby
946
+ interface `Font.install` and `Manifest::Install`), or use the `-F, --formula`
947
+ option.
948
+
949
+ Starting from v1.16, Fontist installs only requested fonts instead of a whole
950
+ formula, unless specified explicitly.
951
+ changed now.
952
+
953
+ For example, an installation request for the "`Arial`" font prior to v1.16 will
954
+ setup all fonts found in the "`ms_truetype`" formula: "`Arial`", "`Trebuchet
955
+ MS`", "`Verdana`" and "`Times New Roman`".
956
+
957
+ From v1.16 onwards, Fontist will install _only_ the requested "`Arial`" font.
958
+
959
+ To install all fonts from a formula, the `-F, --formula` option can be used:
960
+
961
+ [source,sh]
962
+ ----
963
+ $ fontist install --formula ms_truetype
964
+ ----
965
+
939
966
 
940
967
 
941
968
  == Maintenance (for Fontist maintainers only!)
data/fontist.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency "nokogiri", "~> 1.0"
35
35
  spec.add_runtime_dependency "mime-types", "~> 3.0"
36
36
  spec.add_runtime_dependency "sys-uname", "~> 1.2"
37
- spec.add_runtime_dependency "thor", "~> 1.0.1"
37
+ spec.add_runtime_dependency "thor", "~> 1.2.1"
38
38
  spec.add_runtime_dependency "git", "~> 1.0"
39
39
  spec.add_runtime_dependency "ttfunk", "~> 1.6"
40
40
  spec.add_runtime_dependency "plist", "~> 3.0"
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency "rake", "~> 13"
47
47
  spec.add_development_dependency "rspec", "~> 3.0"
48
48
  spec.add_development_dependency "rspec-benchmark", "~> 0.6"
49
- spec.add_development_dependency "rubocop", "~> 1.5"
49
+ spec.add_development_dependency "rubocop", "~> 1.22.1"
50
50
  spec.add_development_dependency "rubocop-rails", "~> 2.9"
51
51
  spec.add_development_dependency "rubocop-performance", "~> 1.10"
52
52
  end
data/lib/fontist/font.rb CHANGED
@@ -125,7 +125,10 @@ module Fontist
125
125
  end
126
126
 
127
127
  def font_installer(formula)
128
- FontInstaller.new(formula, no_progress: @no_progress)
128
+ options = { no_progress: @no_progress }
129
+ return FontInstaller.new(formula, **options) if @by_formula
130
+
131
+ FontInstaller.new(formula, font_name: @name, **options)
129
132
  end
130
133
 
131
134
  def sufficient_formulas
@@ -3,8 +3,9 @@ require "excavate"
3
3
 
4
4
  module Fontist
5
5
  class FontInstaller
6
- def initialize(formula, no_progress: false)
6
+ def initialize(formula, font_name: nil, no_progress: false)
7
7
  @formula = formula
8
+ @font_name = font_name
8
9
  @no_progress = no_progress
9
10
  end
10
11
 
@@ -90,9 +91,15 @@ module Fontist
90
91
 
91
92
  def source_files
92
93
  @source_files ||= @formula.fonts.flat_map do |font|
93
- font.styles.map do |style|
94
- style.source_font || style.font
95
- end
94
+ next [] if @font_name && !font.name.casecmp?(@font_name)
95
+
96
+ font_files(font)
97
+ end
98
+ end
99
+
100
+ def font_files(font)
101
+ font.styles.map do |style|
102
+ style.source_font || style.font
96
103
  end
97
104
  end
98
105
 
@@ -11,7 +11,7 @@ module Fontist
11
11
  end
12
12
 
13
13
  def call(formulas)
14
- return [] if formulas.size.zero?
14
+ return [] if formulas.empty?
15
15
  return formulas if contain_different_styles?(formulas)
16
16
  return by_version(formulas) if version_is_passed?
17
17
  return newest(formulas) if newest_is_passed?
@@ -82,7 +82,8 @@ module Fontist
82
82
 
83
83
  def filter_by_size_limit(formulas)
84
84
  formulas.select do |formula|
85
- formula.file_size.nil? || formula.file_size < size_limit_in_bytes
85
+ formula.file_size.nil? || resources_cached?(formula) ||
86
+ formula.file_size < size_limit_in_bytes
86
87
  end
87
88
  end
88
89
 
@@ -122,5 +123,11 @@ module Fontist
122
123
  formula.file_size || 0
123
124
  end
124
125
  end
126
+
127
+ def resources_cached?(formula)
128
+ Utils::Cache.new.already_fetched?(
129
+ formula.resources.flat_map(&:urls),
130
+ )
131
+ end
125
132
  end
126
133
  end
data/lib/fontist/repo.rb CHANGED
@@ -1,6 +1,62 @@
1
1
  require "git"
2
2
 
3
3
  module Fontist
4
+ class Info
5
+ attr_reader :name, :metadata, :formulas
6
+
7
+ def initialize(name, path)
8
+ @name = name
9
+ @metadata = build_metadata(path)
10
+ @formulas = build_formulas(path)
11
+ end
12
+
13
+ def to_s
14
+ <<~MSG.chomp
15
+ Repository info for '#{@name}':
16
+ #{@metadata.map { |k, v| " #{k}: #{v}" }.join("\n")}
17
+ Found #{formulas.count} formulas:
18
+ #{@formulas.map { |info| "- #{info.description} (#{info.name})" }.join("\n")}
19
+ MSG
20
+ end
21
+
22
+ private
23
+
24
+ def build_metadata(path)
25
+ repo = Git.open(path)
26
+
27
+ {
28
+ url: repo.config["remote.origin.url"],
29
+ revision: revision(repo),
30
+ created: created(repo),
31
+ updated: updated(repo),
32
+ dirty: dirty?(repo),
33
+ }
34
+ end
35
+
36
+ def build_formulas(path)
37
+ path.glob("*.yml").map do |formula_path|
38
+ formula = Formula.new_from_file(formula_path)
39
+ Struct.new(:name, :description).new(formula.key, formula.description)
40
+ end
41
+ end
42
+
43
+ def revision(repo)
44
+ repo.log.first.sha[0..6]
45
+ end
46
+
47
+ def created(repo)
48
+ repo.gcommit(repo.log.last.sha).date
49
+ end
50
+
51
+ def updated(repo)
52
+ repo.gcommit(repo.log.first.sha).date
53
+ end
54
+
55
+ def dirty?(repo)
56
+ !repo.status.changed.empty?
57
+ end
58
+ end
59
+
4
60
  class Repo
5
61
  class << self
6
62
  def setup(name, url)
@@ -47,11 +103,20 @@ module Fontist
47
103
  .map { |path| File.basename(path) }
48
104
  end
49
105
 
106
+ def info(name)
107
+ path = Pathname.new repo_path(name)
108
+ unless path.exist?
109
+ raise(Errors::RepoNotFoundError, "No such repo '#{name}'.")
110
+ end
111
+
112
+ Info.new(name, path)
113
+ end
114
+
50
115
  private
51
116
 
52
117
  def ensure_private_formulas_path_exists
53
118
  Fontist.private_formulas_path.tap do |path|
54
- FileUtils.mkdir_p(path) unless Dir.exist?(path)
119
+ FileUtils.mkdir_p(path)
55
120
  end
56
121
  end
57
122
 
@@ -47,6 +47,16 @@ module Fontist
47
47
  CLI::STATUS_SUCCESS
48
48
  end
49
49
 
50
+ desc "info NAME", "Information about repos"
51
+ def info(name)
52
+ handle_class_options(options)
53
+ info = Repo.info(name)
54
+ Fontist.ui.say(info.to_s)
55
+ CLI::STATUS_SUCCESS
56
+ rescue Errors::RepoNotFoundError
57
+ handle_repo_not_found(name)
58
+ end
59
+
50
60
  private
51
61
 
52
62
  def handle_repo_not_found(name)
@@ -21,6 +21,11 @@ module Fontist
21
21
  downloaded_file(path)
22
22
  end
23
23
 
24
+ def already_fetched?(keys)
25
+ map = load_cache
26
+ keys.find { |k| cache_exist?(map[k]) }
27
+ end
28
+
24
29
  def delete(key)
25
30
  lock(lock_path) do
26
31
  map = load_cache
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.15.1".freeze
2
+ VERSION = "1.16.0".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.15.1
4
+ version: 1.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.1
89
+ version: 1.2.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.1
96
+ version: 1.2.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: git
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -240,14 +240,14 @@ dependencies:
240
240
  requirements:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: '1.5'
243
+ version: 1.22.1
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
- version: '1.5'
250
+ version: 1.22.1
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: rubocop-rails
253
253
  requirement: !ruby/object:Gem::Requirement