fontist 1.9.0 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/metanorma.yml +5 -2
- data/README.adoc +758 -0
- data/README.md +30 -5
- data/exe/fontist +24 -2
- data/fontist.gemspec +2 -0
- data/lib/fontist.rb +29 -5
- data/lib/fontist/cli.rb +24 -1
- data/lib/fontist/errors.rb +2 -0
- data/lib/fontist/font.rb +8 -3
- data/lib/fontist/formula.rb +2 -12
- data/lib/fontist/import/files/collection_file.rb +10 -1
- data/lib/fontist/import/formula_builder.rb +14 -5
- data/lib/fontist/import/google_import.rb +4 -0
- data/lib/fontist/import/otf/font_file.rb +17 -4
- data/lib/fontist/import/otf_style.rb +10 -2
- data/lib/fontist/import/otfinfo/template.erb +6 -0
- data/lib/fontist/index.rb +7 -4
- data/lib/fontist/indexes/default_family_font_index.rb +21 -0
- data/lib/fontist/indexes/font_index.rb +8 -13
- data/lib/fontist/indexes/preferred_family_font_index.rb +24 -0
- data/lib/fontist/repo.rb +6 -0
- data/lib/fontist/repo_cli.rb +10 -1
- data/lib/fontist/system_font.rb +6 -11
- data/lib/fontist/system_index.rb +108 -29
- data/lib/fontist/update.rb +78 -0
- data/lib/fontist/utils/downloader.rb +15 -6
- data/lib/fontist/version.rb +1 -1
- metadata +20 -3
- data/lib/fontist/fontist_font.rb +0 -24
@@ -0,0 +1,78 @@
|
|
1
|
+
module Fontist
|
2
|
+
class Update
|
3
|
+
BRANCH = "v2".freeze
|
4
|
+
|
5
|
+
def self.call
|
6
|
+
new(BRANCH).call
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(branch = "main")
|
10
|
+
@branch = branch
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
update_main_repo
|
15
|
+
update_private_repos
|
16
|
+
ensure
|
17
|
+
rebuild_index
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def update_main_repo
|
23
|
+
dir = File.dirname(Fontist.formulas_repo_path)
|
24
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
25
|
+
|
26
|
+
unless Dir.exist?(Fontist.formulas_repo_path)
|
27
|
+
return Git.clone(Fontist.formulas_repo_url,
|
28
|
+
Fontist.formulas_repo_path,
|
29
|
+
branch: @branch,
|
30
|
+
depth: 1)
|
31
|
+
end
|
32
|
+
|
33
|
+
git = Git.open(Fontist.formulas_repo_path)
|
34
|
+
return git.pull("origin", @branch) if git.current_branch == @branch
|
35
|
+
|
36
|
+
git.config("remote.origin.fetch",
|
37
|
+
"+refs/heads/#{@branch}:refs/remotes/origin/#{@branch}")
|
38
|
+
git.fetch
|
39
|
+
git.checkout(@branch)
|
40
|
+
git.pull("origin", @branch)
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_private_repos
|
44
|
+
private_repos.each do |path|
|
45
|
+
update_repo(path)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def update_repo(path)
|
50
|
+
Git.open(path).pull
|
51
|
+
rescue Git::GitExecuteError => e
|
52
|
+
name = repo_name(path)
|
53
|
+
raise Errors::RepoCouldNotBeUpdatedError.new(<<~MSG.chomp)
|
54
|
+
Formulas repo '#{name}' could not be updated.
|
55
|
+
Please consider reinitializing it with:
|
56
|
+
fontist remove #{name}
|
57
|
+
fontist setup #{name} REPO_URL
|
58
|
+
|
59
|
+
Git error:
|
60
|
+
#{e.message}
|
61
|
+
MSG
|
62
|
+
end
|
63
|
+
|
64
|
+
def private_repos
|
65
|
+
Dir.glob(Fontist.private_formulas_path.join("*")).select do |path|
|
66
|
+
File.directory?(path)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def repo_name(path)
|
71
|
+
File.basename(path)
|
72
|
+
end
|
73
|
+
|
74
|
+
def rebuild_index
|
75
|
+
Index.rebuild
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -24,12 +24,7 @@ module Fontist
|
|
24
24
|
download_file
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
raise(Fontist::Errors::TamperedFileError.new(
|
29
|
-
"The downloaded file from #{@file} doesn't " \
|
30
|
-
"match with the expected sha256 checksum!"
|
31
|
-
))
|
32
|
-
end
|
27
|
+
raise_if_tampered(file)
|
33
28
|
|
34
29
|
file
|
35
30
|
end
|
@@ -38,6 +33,19 @@ module Fontist
|
|
38
33
|
|
39
34
|
attr_reader :file, :sha, :file_size
|
40
35
|
|
36
|
+
def raise_if_tampered(file)
|
37
|
+
file_checksum = Digest::SHA256.file(file).to_s
|
38
|
+
if !sha.empty? && !sha.include?(file_checksum)
|
39
|
+
raise(
|
40
|
+
Fontist::Errors::TamperedFileError.new(
|
41
|
+
"The downloaded file from #{@file} doesn't " \
|
42
|
+
"match with the expected sha256 checksum (#{file_checksum})!\n" \
|
43
|
+
"Beginning of content: #{File.read(file, 3000)}",
|
44
|
+
),
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
41
49
|
def byte_to_megabyte
|
42
50
|
@byte_to_megabyte ||= 1024 * 1024
|
43
51
|
end
|
@@ -59,6 +67,7 @@ module Fontist
|
|
59
67
|
url,
|
60
68
|
open_timeout: 10,
|
61
69
|
read_timeout: 10,
|
70
|
+
max_redirects: 10,
|
62
71
|
headers: headers,
|
63
72
|
content_length_proc: ->(content_length) {
|
64
73
|
@progress_bar.total = content_length if content_length
|
data/lib/fontist/version.rb
CHANGED
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.
|
4
|
+
version: 1.11.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-
|
11
|
+
date: 2021-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: down
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '1.0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: socksify
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
237
251
|
description: Install openly-licensed fonts on Windows, Linux and Mac!
|
238
252
|
email:
|
239
253
|
- open.source@ribose.com
|
@@ -252,6 +266,7 @@ files:
|
|
252
266
|
- ".rubocop.yml"
|
253
267
|
- Gemfile
|
254
268
|
- LICENSE.txt
|
269
|
+
- README.adoc
|
255
270
|
- README.md
|
256
271
|
- Rakefile
|
257
272
|
- exe/fontist
|
@@ -262,7 +277,6 @@ files:
|
|
262
277
|
- lib/fontist/font.rb
|
263
278
|
- lib/fontist/font_installer.rb
|
264
279
|
- lib/fontist/font_path.rb
|
265
|
-
- lib/fontist/fontist_font.rb
|
266
280
|
- lib/fontist/formula.rb
|
267
281
|
- lib/fontist/formula_paths.rb
|
268
282
|
- lib/fontist/helpers.rb
|
@@ -296,9 +310,11 @@ files:
|
|
296
310
|
- lib/fontist/import/text_helper.rb
|
297
311
|
- lib/fontist/index.rb
|
298
312
|
- lib/fontist/indexes/base_index.rb
|
313
|
+
- lib/fontist/indexes/default_family_font_index.rb
|
299
314
|
- lib/fontist/indexes/filename_index.rb
|
300
315
|
- lib/fontist/indexes/font_index.rb
|
301
316
|
- lib/fontist/indexes/index_formula.rb
|
317
|
+
- lib/fontist/indexes/preferred_family_font_index.rb
|
302
318
|
- lib/fontist/manifest.rb
|
303
319
|
- lib/fontist/manifest/install.rb
|
304
320
|
- lib/fontist/manifest/locations.rb
|
@@ -307,6 +323,7 @@ files:
|
|
307
323
|
- lib/fontist/system.yml
|
308
324
|
- lib/fontist/system_font.rb
|
309
325
|
- lib/fontist/system_index.rb
|
326
|
+
- lib/fontist/update.rb
|
310
327
|
- lib/fontist/utils.rb
|
311
328
|
- lib/fontist/utils/cache.rb
|
312
329
|
- lib/fontist/utils/downloader.rb
|
data/lib/fontist/fontist_font.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Fontist
|
2
|
-
class FontistFont
|
3
|
-
def initialize(font_name:)
|
4
|
-
@font_name = font_name
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.find(name)
|
8
|
-
new(font_name: name).find
|
9
|
-
end
|
10
|
-
|
11
|
-
def find
|
12
|
-
styles = FormulaPaths.new(font_paths).find(@font_name)
|
13
|
-
return unless styles
|
14
|
-
|
15
|
-
styles.map { |x| x[:path] }
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def font_paths
|
21
|
-
Dir.glob(Fontist.fonts_path.join("**"))
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|