fontist 3.0.42 → 3.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a064dbb6e34647ec61e1d0026cf081ee336e8f840aafc8c0d776d368f1b73cd0
4
- data.tar.gz: 9d08023fe33c17842e4217233f36f0b18398e994ee456f3b1b6835da171f4d19
3
+ metadata.gz: 65303ef28ac7968cf6e993382cd56ed455f40b181c8b945fef3b43d54b622c14
4
+ data.tar.gz: 1a721dbd1f32c8b0ec4c23eecf191605d4ef793041fe677f2a90e3d0c1ca19ad
5
5
  SHA512:
6
- metadata.gz: 15a22d4fafed929dff512fa5e672a853c9306eebf389612aea07326acd8542eb683c26e80a6c04cd1bffacde479e48b0dfaf67186b7c76d22298791db7d214d7
7
- data.tar.gz: 07cc3aea73bbe3bbe907c8085694c84be78b9a0e1f6f0694db3ffe23e9e72395360c4e5ea55a9da57802fd02a80144e4039d25ad016a469db7ca502ee6855af7
6
+ metadata.gz: 7ca4056f32db8e78d403352bd3695ed86447b70a050d3291e1a6637cb90f7ca21a211968e6bf960cafec861c102167966e61885e64e6c15442b5dd569abdd5a1
7
+ data.tar.gz: 44858ffc6ddb5629b3b86cf47704cfe8f620928d9549f6c1f72077c9d79c1d505d8668b4cb215d826a57157c6a1397a5b2328c78f6c3a1851fd41ffd10d02c74
@@ -19,7 +19,8 @@ jobs:
19
19
  runs-on: macos-${{ matrix.version }}
20
20
  strategy:
21
21
  matrix:
22
- version: [14, 15, 26]
22
+ # macos-14 is not offered to this repo; restore it if a runner becomes available.
23
+ version: [15, 26]
23
24
  fail-fast: false
24
25
  steps:
25
26
  - name: List ALL Core System Fonts
@@ -0,0 +1,275 @@
1
+ name: Scan path performance gate
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ report-engine-availability:
13
+ name: Report published engine availability
14
+ if: github.event_name == 'pull_request'
15
+ runs-on: ubuntu-24.04
16
+ concurrency:
17
+ group: scan-path-publication-${{ github.event.pull_request.number }}
18
+ cancel-in-progress: false
19
+ permissions:
20
+ contents: read
21
+ pull-requests: write
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: "3.3"
28
+
29
+ - name: Resolve bundle without installing gems
30
+ run: bundle lock
31
+
32
+ - name: Report published engines on the PR
33
+ if: github.event.pull_request.head.repo.full_name == github.repository
34
+ env:
35
+ GH_TOKEN: ${{ github.token }}
36
+ FONTIST_PERF_COMMENT_AUTHOR: github-actions[bot]
37
+ FONTIST_PERF_HEAD: ${{ github.event.pull_request.head.sha }}
38
+ PERF_REPOSITORY: ${{ github.repository }}
39
+ PERF_PR_NUMBER: ${{ github.event.pull_request.number }}
40
+ run: ruby spec/support/performance.rb --report "$PERF_REPOSITORY" "$PERF_PR_NUMBER" --publish
41
+
42
+ - name: Report published engines in the log
43
+ if: github.event.pull_request.head.repo.full_name != github.repository
44
+ env:
45
+ GH_TOKEN: ${{ github.token }}
46
+ FONTIST_PERF_HEAD: ${{ github.event.pull_request.head.sha }}
47
+ PERF_REPOSITORY: ${{ github.repository }}
48
+ PERF_PR_NUMBER: ${{ github.event.pull_request.number }}
49
+ run: ruby spec/support/performance.rb --report "$PERF_REPOSITORY" "$PERF_PR_NUMBER"
50
+
51
+ scan-path-base:
52
+ name: Ruby scan path PR vs base
53
+ runs-on: ubuntu-24.04
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+
57
+ - name: Check out pull request base
58
+ id: base_checkout
59
+ if: github.event_name == 'pull_request'
60
+ continue-on-error: true
61
+ uses: actions/checkout@v4
62
+ with:
63
+ ref: ${{ github.event.pull_request.base.sha }}
64
+ path: .perf-base
65
+
66
+ - name: Require pull request base checkout
67
+ if: github.event_name == 'pull_request'
68
+ env:
69
+ BASE_CHECKOUT_OUTCOME: ${{ steps.base_checkout.outcome }}
70
+ run: |
71
+ if [ "$BASE_CHECKOUT_OUTCOME" != "success" ]; then
72
+ echo "ERROR: pull request base checkout failed; PR-vs-base comparison cannot run."
73
+ exit 2
74
+ fi
75
+
76
+ - uses: ruby/setup-ruby@v1
77
+ with:
78
+ ruby-version: "3.3"
79
+
80
+ - name: Exclude Rust toolchains from the job
81
+ run: |
82
+ ruby -e '
83
+ paths = ENV.fetch("PATH").split(File::PATH_SEPARATOR)
84
+ extensions = [""] + ENV.fetch("PATHEXT", "").split(";")
85
+ tools = %w[cargo rustc rustup].product(extensions).map(&:join)
86
+ paths.reject! do |directory|
87
+ tools.any? { |tool| File.executable?(File.join(directory, tool)) }
88
+ end
89
+ clean_path = paths.join(File::PATH_SEPARATOR)
90
+
91
+ %w[ruby bundle].each do |tool|
92
+ available = paths.any? do |directory|
93
+ extensions.any? do |extension|
94
+ File.executable?(File.join(directory, "#{tool}#{extension}"))
95
+ end
96
+ end
97
+ next if available
98
+
99
+ warn "ERROR: removing Rust from PATH also removed #{tool}."
100
+ exit 2
101
+ end
102
+
103
+ File.open(ENV.fetch("GITHUB_ENV"), "a") do |output|
104
+ output.puts "PATH=#{clean_path}"
105
+ end
106
+ puts "Rust excluded from PATH for bundle installation and performance checks."
107
+ '
108
+
109
+ - name: Install bundle from RubyGems
110
+ run: |
111
+ if ! bundle install --jobs 4 --retry 3; then
112
+ echo "ERROR: current branch bundle install failed."
113
+ exit 2
114
+ fi
115
+
116
+ - name: Install pull request base bundle
117
+ if: github.event_name == 'pull_request'
118
+ env:
119
+ BUNDLE_GEMFILE: ${{ github.workspace }}/.perf-base/Gemfile
120
+ run: |
121
+ cd .perf-base || exit 2
122
+ if ! bundle install --jobs 4 --retry 3; then
123
+ echo "ERROR: pull request base bundle install failed."
124
+ exit 2
125
+ fi
126
+
127
+ - name: Skip PR-vs-base check on push
128
+ if: github.event_name != 'pull_request'
129
+ run: echo "PR-vs-base comparison skipped for push event."
130
+
131
+ - name: Run Ruby scan path performance gate
132
+ env:
133
+ FONTIST_PERF_INTEGRATION: "1"
134
+ FONTISAN_ENGINE: ruby
135
+ FONTISAN_ENGINE_STRICT: "1"
136
+ FONTIST_PERF_BASE: ${{ github.event_name == 'pull_request' && format('{0}/.perf-base', github.workspace) || '' }}
137
+ run: bundle exec rspec spec/performance/scan_path_perf_spec.rb
138
+
139
+ scan-path-performance:
140
+ name: ${{ matrix.platform }} / ${{ matrix.tier }}
141
+ runs-on: ${{ matrix.runner }}
142
+ strategy:
143
+ fail-fast: false
144
+ matrix:
145
+ include:
146
+ - platform: Linux x86_64
147
+ runner: ubuntu-24.04
148
+ target_os: linux
149
+ target_cpu: x86_64
150
+ tier: native
151
+ - platform: Linux x86_64
152
+ runner: ubuntu-24.04
153
+ target_os: linux
154
+ target_cpu: x86_64
155
+ tier: ffi
156
+ - platform: macOS arm64
157
+ runner: macos-latest
158
+ target_os: darwin
159
+ target_cpu: arm64
160
+ tier: native
161
+ - platform: macOS arm64
162
+ runner: macos-latest
163
+ target_os: darwin
164
+ target_cpu: arm64
165
+ tier: ffi
166
+ - platform: macOS x86_64
167
+ runner: macos-15-intel
168
+ target_os: darwin
169
+ target_cpu: x86_64
170
+ tier: native
171
+ - platform: macOS x86_64
172
+ runner: macos-15-intel
173
+ target_os: darwin
174
+ target_cpu: x86_64
175
+ tier: ffi
176
+
177
+ steps:
178
+ - uses: actions/checkout@v4
179
+
180
+ - uses: ruby/setup-ruby@v1
181
+ with:
182
+ ruby-version: "3.3"
183
+
184
+ - name: Exclude Rust toolchains from the job
185
+ run: |
186
+ ruby -e '
187
+ paths = ENV.fetch("PATH").split(File::PATH_SEPARATOR)
188
+ extensions = [""] + ENV.fetch("PATHEXT", "").split(";")
189
+ tools = %w[cargo rustc rustup].product(extensions).map(&:join)
190
+ paths.reject! do |directory|
191
+ tools.any? { |tool| File.executable?(File.join(directory, tool)) }
192
+ end
193
+ clean_path = paths.join(File::PATH_SEPARATOR)
194
+
195
+ %w[ruby bundle].each do |tool|
196
+ available = paths.any? do |directory|
197
+ extensions.any? do |extension|
198
+ File.executable?(File.join(directory, "#{tool}#{extension}"))
199
+ end
200
+ end
201
+ next if available
202
+
203
+ warn "ERROR: removing Rust from PATH also removed #{tool}."
204
+ exit 2
205
+ end
206
+
207
+ File.open(ENV.fetch("GITHUB_ENV"), "a") do |output|
208
+ output.puts "PATH=#{clean_path}"
209
+ end
210
+ puts "Rust excluded from PATH for bundle installation and performance checks."
211
+ '
212
+
213
+ - name: Resolve bundle without installing gems
214
+ run: bundle lock
215
+
216
+ - name: Verify published Fontisan binary is available
217
+ id: fontisan_platform
218
+ env:
219
+ TARGET_OS: ${{ matrix.target_os }}
220
+ TARGET_CPU: ${{ matrix.target_cpu }}
221
+ run: |
222
+ ruby -rbundler -rjson -rnet/http -ruri -rrubygems/platform -e '
223
+ lock = File.read("Gemfile.lock")
224
+ fontisan = Bundler::LockfileParser.new(lock).specs.find { |spec| spec.name == "fontisan" }
225
+ abort "fontisan version missing from Gemfile.lock" unless fontisan
226
+ version = fontisan.version.to_s
227
+
228
+ uri = URI("https://rubygems.org/api/v1/versions/fontisan.json")
229
+ response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.get(uri.request_uri) }
230
+ abort "RubyGems fontisan metadata request failed: HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
231
+
232
+ versions = JSON.parse(response.body)
233
+ published = versions.select { |entry| entry["number"] == version }
234
+ platforms = published.map { |entry| entry["platform"] }.uniq.sort
235
+ target_os = ENV.fetch("TARGET_OS")
236
+ target_cpu = ENV.fetch("TARGET_CPU")
237
+ usable = platforms.select do |platform|
238
+ next false if platform == "ruby"
239
+
240
+ candidate = Gem::Platform.new(platform)
241
+ next false unless candidate.os == target_os && candidate.cpu == target_cpu
242
+
243
+ target_os != "linux" || candidate.version.nil? || candidate.version.start_with?("gnu")
244
+ end
245
+ unless usable.any?
246
+ warn "ERROR: fontisan #{version} has no published #{target_cpu}-#{target_os} binary gem on RubyGems.org (published platforms: #{platforms.empty? ? "none" : platforms.join(", ")})"
247
+ exit 2
248
+ end
249
+ platform = usable.first
250
+ puts "RubyGems.org publishes fontisan #{version} for #{platform}."
251
+ File.open(ENV.fetch("GITHUB_OUTPUT"), "a") { |output| output.puts("platform=#{platform}") }
252
+ '
253
+
254
+ - name: Install bundle from RubyGems
255
+ run: bundle install --jobs 4 --retry 3
256
+
257
+ - name: Verify installed Fontisan is the published platform gem
258
+ env:
259
+ FONTISAN_PLATFORM: ${{ steps.fontisan_platform.outputs.platform }}
260
+ run: |
261
+ bundle exec ruby -e '
262
+ spec = Gem.loaded_specs.fetch("fontisan")
263
+ puts "Installed fontisan #{spec.version} (#{spec.platform}) for #{RUBY_PLATFORM}."
264
+ unless spec.platform.to_s == ENV.fetch("FONTISAN_PLATFORM")
265
+ warn "ERROR: installed fontisan #{spec.version} platform #{spec.platform} does not match required prebuilt #{ENV.fetch("FONTISAN_PLATFORM")}."
266
+ exit 2
267
+ end
268
+ '
269
+
270
+ - name: Run scan path performance gate
271
+ env:
272
+ FONTIST_PERF_INTEGRATION: "1"
273
+ FONTIST_PERF_TIER: ${{ matrix.tier }}
274
+ FONTISAN_ENGINE_STRICT: "1"
275
+ run: bundle exec rspec spec/performance/scan_path_perf_spec.rb
@@ -0,0 +1,80 @@
1
+ require "open3"
2
+ require "tempfile"
3
+
4
+ module Fontist
5
+ module Utils
6
+ class CurlDownloader
7
+ CURL = "curl.exe".freeze
8
+
9
+ def self.fallback?(error)
10
+ available? && enotsock?(error)
11
+ end
12
+
13
+ def self.available?
14
+ Gem.win_platform?
15
+ end
16
+
17
+ def self.enotsock?(error)
18
+ node = error
19
+ while node
20
+ return true if node.is_a?(Errno::ENOTSOCK)
21
+
22
+ node = node.cause
23
+ end
24
+
25
+ # Down flattens the MinGW OpenSSL errno into a message-only
26
+ # Down::ConnectionError (no typed #cause), so match the text as a
27
+ # last resort.
28
+ msg = error.message.to_s
29
+ msg.include?("not a socket") || msg.include?("ENOTSOCK")
30
+ end
31
+
32
+ def initialize(url, headers: {})
33
+ @url = url
34
+ @headers = headers
35
+ end
36
+
37
+ # Returns a Tempfile that satisfies the cache duck type:
38
+ # #original_filename, #content_type, #path, #close.
39
+ def download
40
+ tempfile = Tempfile.new("fontist-curl", binmode: true)
41
+ content_type = run(argv(tempfile.path))
42
+ decorate(tempfile, content_type)
43
+ end
44
+
45
+ def argv(output_path)
46
+ # rubocop:disable-next Style/FormatStringToken
47
+ [CURL, "-fSL", "--retry", "3", *header_args,
48
+ "-w", "%{content_type}", "-o", output_path, "--", @url]
49
+ end
50
+
51
+ private
52
+
53
+ # Forward every header Down would have sent (User-Agent plus any
54
+ # formula-specific Authorization/Referer/cookies), not just the UA.
55
+ def header_args
56
+ @headers.flat_map { |key, value| ["-H", "#{key}: #{value}"] }
57
+ end
58
+
59
+ # The body goes to -o; stdout carries only curl's -w content_type.
60
+ def run(argv)
61
+ out, err, status = Open3.capture3(*argv)
62
+ return out.strip if status.success?
63
+
64
+ raise Fontist::Errors::InvalidResourceError,
65
+ "curl failed for #{@url}: #{err.strip}"
66
+ end
67
+
68
+ def decorate(tempfile, content_type)
69
+ filename = File.basename(URI(@url).path)
70
+ tempfile.define_singleton_method(:original_filename) { filename }
71
+ # Cache derives an extension from content_type only when the URL has
72
+ # no extname; curl's -w reports it so extensionless URLs still resolve,
73
+ # matching the Down path.
74
+ type = content_type unless content_type.to_s.empty?
75
+ tempfile.define_singleton_method(:content_type) { type }
76
+ tempfile
77
+ end
78
+ end
79
+ end
80
+ end
@@ -106,15 +106,20 @@ module Fontist
106
106
  options[:download_path] || Fontist.root_path.join("tmp")
107
107
  end
108
108
 
109
+ # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
109
110
  def download_file
110
111
  print_download_start if @verbose
111
112
  do_download_file
112
- rescue Down::Error => e
113
+ rescue StandardError => e
114
+ return curl_download if CurlDownloader.fallback?(e)
115
+ raise unless e.is_a?(Down::Error)
116
+
113
117
  retry if retry_download?(e)
114
118
 
115
119
  raise Fontist::Errors::InvalidResourceError,
116
120
  "Invalid URL: #{@file}. Error: #{e.inspect}."
117
121
  end
122
+ # rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
118
123
 
119
124
  def retry_download?(error)
120
125
  response = http_response(error)
@@ -256,11 +261,19 @@ module Fontist
256
261
 
257
262
  def github_aware_url(raw_url)
258
263
  parsed = GitHubUrl.parse(raw_url)
259
- if parsed.matched?
260
- GitHubClient.authenticated_download_url(parsed)
261
- else
262
- raw_url
263
- end
264
+ return raw_url unless parsed.matched?
265
+
266
+ GitHubClient.authenticated_download_url(parsed)
267
+ rescue StandardError => e
268
+ raise unless CurlDownloader.fallback?(e)
269
+
270
+ # raw_url is the releases/download/... form; curl's -L resolves the
271
+ # redirect itself, so we skip the API-based asset resolution.
272
+ raw_url
273
+ end
274
+
275
+ def curl_download
276
+ CurlDownloader.new(url, headers: headers).download
264
277
  end
265
278
  end
266
279
 
data/lib/fontist/utils.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Fontist
2
2
  module Utils
3
3
  autoload :Cache, "#{__dir__}/utils/cache"
4
+ autoload :CurlDownloader, "#{__dir__}/utils/curl_downloader"
4
5
  autoload :Downloader, "#{__dir__}/utils/downloader"
5
6
  autoload :FileMagic, "#{__dir__}/utils/file_magic"
6
7
  autoload :FileOps, "#{__dir__}/utils/file_ops"
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "3.0.42".freeze
2
+ VERSION = "3.0.43".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: 3.0.42
4
+ version: 3.0.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-25 00:00:00.000000000 Z
11
+ date: 2026-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -258,6 +258,7 @@ files:
258
258
  - ".github/workflows/docs.yml"
259
259
  - ".github/workflows/formulas-auto-update-test.yml"
260
260
  - ".github/workflows/links.yml"
261
+ - ".github/workflows/perf-gate.yml"
261
262
  - ".github/workflows/post-rake.yml"
262
263
  - ".github/workflows/rake-metanorma.yaml"
263
264
  - ".github/workflows/rake.yml"
@@ -508,6 +509,7 @@ files:
508
509
  - lib/fontist/update.rb
509
510
  - lib/fontist/utils.rb
510
511
  - lib/fontist/utils/cache.rb
512
+ - lib/fontist/utils/curl_downloader.rb
511
513
  - lib/fontist/utils/downloader.rb
512
514
  - lib/fontist/utils/file_magic.rb
513
515
  - lib/fontist/utils/file_ops.rb