fontist 1.11.3 → 1.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/README.adoc +2 -2
- data/lib/fontist/font_installer.rb +17 -3
- data/lib/fontist/utils/downloader.rb +26 -13
- data/lib/fontist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ac17862d959106489db89581d1af08b243738f4b894723c10c78495ff739392
|
4
|
+
data.tar.gz: 69573ac254f8391feeba6a060320a709bb674575208b94454f8bf7358e988ae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd59c9ed3333c2ae10ffa8b337f4e42e607057fefccd09d1194db98890e23835e0914a137c86ada8fff15b97930f3159ae5270bfb0ebda98488e262742692f06
|
7
|
+
data.tar.gz: 8c0850e4376f77a90f7040f6c28c8a7a6b7e072e3e3e7fd0e283327482753c88aec075a7dc3f264c5c886f16392e6a4e2354af1f0ccfbfd4c262756d3885510c
|
data/.github/workflows/rspec.yml
CHANGED
data/README.adoc
CHANGED
@@ -685,8 +685,8 @@ one, please refer to its documentation.
|
|
685
685
|
There is an ability to use private fonts via private Fontist repositories.
|
686
686
|
|
687
687
|
A Fontist repository is a Git repo which contains YAML formula files. Formulas can be created
|
688
|
-
manually (see https://github.com/fontist/formulas/tree/master/Formulas
|
689
|
-
or
|
688
|
+
manually (see https://github.com/fontist/formulas/tree/master/Formulas[examples]),
|
689
|
+
or xref:Authoring Fontist formulas[auto-generated from an archive].
|
690
690
|
|
691
691
|
A repository can be either a HTTPS or SSH Git repo. In case of SSH, a
|
692
692
|
corresponding SSH key should be setup with `ssh-agent` in order to access this
|
@@ -54,16 +54,30 @@ module Fontist
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def download_file(source)
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
errors = []
|
58
|
+
source.urls.each do |request|
|
59
|
+
url = request.respond_to?(:url) ? request.url : request
|
60
|
+
Fontist.ui.say(%(Downloading font "#{@formula.key}" from #{url}))
|
60
61
|
|
62
|
+
result = try_download_file(request, source)
|
63
|
+
return result unless result.is_a?(Errors::InvalidResourceError)
|
64
|
+
|
65
|
+
errors << result
|
66
|
+
end
|
67
|
+
|
68
|
+
raise Errors::InvalidResourceError, errors.join(" ")
|
69
|
+
end
|
70
|
+
|
71
|
+
def try_download_file(request, source)
|
61
72
|
Fontist::Utils::Downloader.download(
|
62
73
|
request,
|
63
74
|
sha: source.sha256,
|
64
75
|
file_size: source.file_size,
|
65
76
|
progress_bar: !@no_progress
|
66
77
|
)
|
78
|
+
rescue Errors::InvalidResourceError => e
|
79
|
+
Fontist.ui.say(e.message)
|
80
|
+
e
|
67
81
|
end
|
68
82
|
|
69
83
|
def font_file?(path)
|
@@ -15,7 +15,7 @@ module Fontist
|
|
15
15
|
@file = file
|
16
16
|
@sha = [sha].flatten.compact
|
17
17
|
@file_size = file_size.to_i if file_size
|
18
|
-
@progress_bar =
|
18
|
+
@progress_bar = progress_bar
|
19
19
|
@cache = Cache.new
|
20
20
|
end
|
21
21
|
|
@@ -54,35 +54,48 @@ module Fontist
|
|
54
54
|
options[:download_path] || Fontist.root_path.join("tmp")
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
58
|
-
|
57
|
+
def download_file
|
58
|
+
tries = tries ? tries + 1 : 1
|
59
|
+
do_download_file
|
60
|
+
rescue Down::Error => e
|
61
|
+
retry if tries < 3
|
62
|
+
|
63
|
+
raise Fontist::Errors::InvalidResourceError,
|
64
|
+
"Invalid URL: #{@file}. Error: #{e.inspect}."
|
65
|
+
end
|
66
|
+
|
67
|
+
def do_download_file
|
68
|
+
progress_bar = create_progress_bar
|
69
|
+
file = do_download_file_with_progress_bar(progress_bar)
|
70
|
+
progress_bar.finish
|
71
|
+
file
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_progress_bar
|
75
|
+
if @progress_bar
|
59
76
|
ProgressBar.new(@file_size)
|
60
77
|
else
|
61
78
|
NullProgressBar.new(@file_size)
|
62
79
|
end
|
63
80
|
end
|
64
81
|
|
65
|
-
|
66
|
-
|
82
|
+
# rubocop:disable Metrics/MethodLength
|
83
|
+
def do_download_file_with_progress_bar(progress_bar)
|
84
|
+
Down.download(
|
67
85
|
url,
|
68
86
|
open_timeout: 10,
|
69
87
|
read_timeout: 10,
|
70
88
|
max_redirects: 10,
|
71
89
|
headers: headers,
|
72
90
|
content_length_proc: ->(content_length) {
|
73
|
-
|
91
|
+
progress_bar.total = content_length if content_length
|
74
92
|
},
|
75
93
|
progress_proc: -> (progress) {
|
76
|
-
|
94
|
+
progress_bar.increment(progress)
|
77
95
|
}
|
78
96
|
)
|
79
|
-
|
80
|
-
@progress_bar.finish
|
81
|
-
|
82
|
-
file
|
83
|
-
rescue Down::NotFound
|
84
|
-
raise(Fontist::Errors::InvalidResourceError.new("Invalid URL: #{@file}"))
|
85
97
|
end
|
98
|
+
# rubocop:enable Metrics/MethodLength
|
86
99
|
|
87
100
|
def url
|
88
101
|
@file.respond_to?(:url) ? @file.url : @file
|
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.11.
|
4
|
+
version: 1.11.5
|
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-09-
|
11
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: down
|