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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0461da7c09c672b443f4a0bad5443f3bf48294cb3e0aee5ea7082838825519ca
4
- data.tar.gz: 0e5931e6617e4484074b7d740fbe9f593dc3a31d9b524859167d90cdfc060498
3
+ metadata.gz: 0ac17862d959106489db89581d1af08b243738f4b894723c10c78495ff739392
4
+ data.tar.gz: 69573ac254f8391feeba6a060320a709bb674575208b94454f8bf7358e988ae2
5
5
  SHA512:
6
- metadata.gz: c0b30b8bfc0f01507d436dea54d5b122751c852a63d2309a5236a5a5f698c140892e54c2f665dbbce4bf0c6f6276c9a7cd1910f212aa7a27937ceca1b8ba510d
7
- data.tar.gz: de92e684e1368ee2a5c10d1789962181316590b87ea5b806d8fd0a959329c54dd0d95723d99334038f75e2865d277b12dbc2c17aeed39b5b57436506273e7be4
6
+ metadata.gz: dd59c9ed3333c2ae10ffa8b337f4e42e607057fefccd09d1194db98890e23835e0914a137c86ada8fff15b97930f3159ae5270bfb0ebda98488e262742692f06
7
+ data.tar.gz: 8c0850e4376f77a90f7040f6c28c8a7a6b7e072e3e3e7fd0e283327482753c88aec075a7dc3f264c5c886f16392e6a4e2354af1f0ccfbfd4c262756d3885510c
@@ -14,7 +14,7 @@ jobs:
14
14
  fail-fast: false
15
15
  matrix:
16
16
  ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0' ]
17
- os: [ ubuntu-latest, windows-latest, macos-latest ]
17
+ os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
18
18
  experimental: [ false ]
19
19
 
20
20
  steps:
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)[examples],
689
- or #auto-generate-a-formula[auto-generated from an archive].
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
- request = source.urls.first
58
- url = request.respond_to?(:url) ? request.url : request
59
- Fontist.ui.say(%(Downloading font "#{@formula.key}" from #{url}))
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 = set_progress_bar(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 set_progress_bar(progress_bar)
58
- if progress_bar
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
- def download_file
66
- file = Down.download(
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
- @progress_bar.total = content_length if content_length
91
+ progress_bar.total = content_length if content_length
74
92
  },
75
93
  progress_proc: -> (progress) {
76
- @progress_bar.increment(progress)
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
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.11.3".freeze
2
+ VERSION = "1.11.5".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.11.3
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-17 00:00:00.000000000 Z
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down