fontist 1.10.1 → 1.11.1

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: 4d84a50748e0877ef76056095c21debe35d0d3c158cdb52288ee179045e3e7bc
4
- data.tar.gz: fd7254ad078c082f72e22098cace2f937afbbc7715b30c830d76db5aef9ad82f
3
+ metadata.gz: 2f06401d4ccf76cfda39bcd4eae443dbfb2f5284876c4f5a9361fcb56bb97f5a
4
+ data.tar.gz: 5730fc169549b7b3dda74f6e9cae5d3fb3b15c27d1f7d107f16ab5b1be9cdeb8
5
5
  SHA512:
6
- metadata.gz: dcc9e36af40e5ec08170151f0c9177e3f21f3e0a6cbdf87b7b0ea8b7f6aa3505c05a31828bbc20953787e50232e9805e4f2506c3f17723521001d0d47877370b
7
- data.tar.gz: '0045179af59b9639c89d05a9c8b21a2bae720df2513f832af5f0006fe16c1d8ff32c524040e3c9ea60046671750594a9d46fc74452487fb23889d4629e38a41f'
6
+ metadata.gz: bcc0837022c84b93e97e07a19494cd2b28bd51a41834809d4833fb1a453a0314fa37f6249ddb171e6b8f12e8f31c56fa660f661376895c7d9f1a417542626a1c
7
+ data.tar.gz: c46f1f7610213bf168f485d724e215bd2fd5f276802481a647eba9580e4dfc8d0307e3b014a3ee29ceda992548f294251d1600a64efc3086ff1b101420ced3a1
@@ -2,8 +2,11 @@ name: metanorma
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ main ]
6
- pull_request:
5
+ # restore the main branch after metanorma upgrade
6
+ # branches: [ main ]
7
+ branches: [ unknown ]
8
+ # restore after metanorma upgrade
9
+ # pull_request:
7
10
 
8
11
  jobs:
9
12
  test:
@@ -11,7 +11,7 @@ module Fontist
11
11
  def initialize(path)
12
12
  @path = path
13
13
  @fonts = read
14
- @extension = "ttc"
14
+ @extension = detect_extension
15
15
  end
16
16
 
17
17
  def filename
@@ -46,6 +46,15 @@ module Fontist
46
46
  File.join(tmp_dir, filename)
47
47
  end
48
48
  end
49
+
50
+ def detect_extension
51
+ base_extension = "ttc"
52
+
53
+ file_extension = File.extname(File.basename(@path)).sub(/^\./, "")
54
+ return file_extension if file_extension.casecmp?(base_extension)
55
+
56
+ base_extension
57
+ end
49
58
  end
50
59
  end
51
60
  end
@@ -1,3 +1,4 @@
1
+ require "shellwords"
1
2
  require_relative "text_helper"
2
3
 
3
4
  module Fontist
@@ -5,7 +6,7 @@ module Fontist
5
6
  class FormulaBuilder
6
7
  FORMULA_ATTRIBUTES = %i[name description homepage resources
7
8
  font_collections fonts extract copyright
8
- license_url open_license].freeze
9
+ license_url open_license command].freeze
9
10
 
10
11
  attr_accessor :archive,
11
12
  :url,
@@ -49,7 +50,7 @@ module Fontist
49
50
  end
50
51
 
51
52
  def homepage
52
- both_fonts.first.homepage
53
+ both_fonts.map(&:homepage).compact.first
53
54
  end
54
55
 
55
56
  def resources
@@ -146,11 +147,11 @@ module Fontist
146
147
  end
147
148
 
148
149
  def copyright
149
- both_fonts.first.copyright
150
+ both_fonts.map(&:copyright).compact.first
150
151
  end
151
152
 
152
153
  def license_url
153
- both_fonts.first.license_url
154
+ both_fonts.map(&:license_url).compact.first
154
155
  end
155
156
 
156
157
  def open_license
@@ -165,6 +166,10 @@ module Fontist
165
166
 
166
167
  TextHelper.cleanup(@license_text)
167
168
  end
169
+
170
+ def command
171
+ Shellwords.shelljoin(ARGV)
172
+ end
168
173
  end
169
174
  end
170
175
  end
@@ -106,7 +106,11 @@ module Fontist
106
106
  end
107
107
 
108
108
  def detect_extension
109
- Files::FontDetector.standard_extension(@path)
109
+ detected = Files::FontDetector.standard_extension(@path)
110
+ file_extension = File.extname(File.basename(@path)).sub(/^\./, "")
111
+ return file_extension if file_extension.casecmp?(detected)
112
+
113
+ detected
110
114
  end
111
115
  end
112
116
  end
@@ -148,6 +148,11 @@ module Fontist
148
148
  else
149
149
  raise Errors::UnknownFontTypeError.new(path)
150
150
  end
151
+ rescue StandardError
152
+ Fontist.ui.error($!.message)
153
+ Fontist.ui.error(
154
+ "Warning: File at #{path} not recognized as a font file.",
155
+ )
151
156
  end
152
157
 
153
158
  def detect_file_font(path)
@@ -155,9 +160,6 @@ module Fontist
155
160
  file = TTFunk::File.new(content)
156
161
 
157
162
  parse_font(file, path)
158
- rescue StandardError
159
- warn $!.message
160
- warn "Warning: File at #{path} not recognized as a font file."
161
163
  end
162
164
 
163
165
  def detect_collection_fonts(path)
@@ -166,9 +168,6 @@ module Fontist
166
168
  parse_font(file, path)
167
169
  end
168
170
  end
169
- rescue StandardError
170
- warn $!.message
171
- warn "Warning: File at #{path} not recognized as a font file."
172
171
  end
173
172
 
174
173
  def parse_font(file, path)
@@ -1,7 +1,13 @@
1
1
  module Fontist
2
2
  class Update
3
+ BRANCH = "v2".freeze
4
+
3
5
  def self.call
4
- new.call
6
+ new(BRANCH).call
7
+ end
8
+
9
+ def initialize(branch = "main")
10
+ @branch = branch
5
11
  end
6
12
 
7
13
  def call
@@ -17,13 +23,21 @@ module Fontist
17
23
  dir = File.dirname(Fontist.formulas_repo_path)
18
24
  FileUtils.mkdir_p(dir) unless File.exist?(dir)
19
25
 
20
- if Dir.exist?(Fontist.formulas_repo_path)
21
- Git.open(Fontist.formulas_repo_path).pull
22
- else
23
- Git.clone(Fontist.formulas_repo_url,
24
- Fontist.formulas_repo_path,
25
- depth: 1)
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)
26
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)
27
41
  end
28
42
 
29
43
  def update_private_repos
@@ -24,12 +24,7 @@ module Fontist
24
24
  download_file
25
25
  end
26
26
 
27
- if !sha.empty? && !sha.include?(Digest::SHA256.file(file).to_s)
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
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.10.1".freeze
2
+ VERSION = "1.11.1".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.10.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-07-27 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down