fontist 3.0.18 → 3.0.20
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 +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +2 -1
- data/fontist.gemspec +1 -1
- data/lib/fontist/repo.rb +14 -7
- data/lib/fontist/system_index.rb +37 -8
- data/lib/fontist/update.rb +3 -3
- data/lib/fontist/version.rb +1 -1
- data/lib/fontist/yaml_backend.rb +11 -10
- 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: 439f0978a5d10a8e48403d57e994b299bb143f851f76144373431ab570734c0d
|
|
4
|
+
data.tar.gz: 142da201af7fcfb87516b2923087066503427d9109a666895c06ba619ad8e07f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b14c5130d4e6b6b9fb6e4c385860763a83fd357f4aa1e78b9268eb4194b9de83c17551d51cdb0f4a4c9d6a1925c91892e712c1255806ad5db4507b8862f095a
|
|
7
|
+
data.tar.gz: 25d0691a0263605ac7de8d65865619cca478ce2085667de0d06275e49415acad4ba8b484727757d5b0303c71c12c879fba01727acee202db5aeb2de2e736793b
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -20,7 +20,8 @@ gem "webmock"
|
|
|
20
20
|
|
|
21
21
|
# Optional YAML engine (consumer-side dependency; needs Ruby >= 3.0,
|
|
22
22
|
# which is above fontist's gemspec floor, so it stays out of the
|
|
23
|
-
# gemspec).
|
|
23
|
+
# gemspec). Activated with FONTIST_YAML=yeptris; off by default
|
|
24
|
+
# pending leptris/yeptris#863 (linux scalar-parity fix).
|
|
24
25
|
gem "yeptris", require: false
|
|
25
26
|
|
|
26
27
|
# Profiling tools (development only)
|
data/fontist.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
|
|
16
16
|
spec.post_install_message = "Please run `fontist update` to fetch formulas."
|
|
17
17
|
|
|
18
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
|
19
19
|
|
|
20
20
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
21
21
|
spec.metadata["source_code_uri"] = "https://github.com/fontist/fontist"
|
data/lib/fontist/repo.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "git"
|
|
2
|
+
require "open3"
|
|
2
3
|
require "paint"
|
|
3
4
|
|
|
4
5
|
module Fontist
|
|
@@ -26,7 +27,7 @@ module Fontist
|
|
|
26
27
|
repo = Git.open(path)
|
|
27
28
|
|
|
28
29
|
{
|
|
29
|
-
url: repo.
|
|
30
|
+
url: repo.config_get("remote.origin.url")&.value,
|
|
30
31
|
revision: revision(repo),
|
|
31
32
|
created: created(repo),
|
|
32
33
|
updated: updated(repo),
|
|
@@ -42,19 +43,24 @@ module Fontist
|
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def revision(repo)
|
|
45
|
-
repo.
|
|
46
|
+
repo.gcommit("HEAD").sha[0..6]
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
def created(repo)
|
|
49
|
-
|
|
50
|
+
# git 6.0's Commands::Log clobbers the public Git::Log, breaking
|
|
51
|
+
# log#first/#last (ruby-git regression); ask the git binary for
|
|
52
|
+
# the root commit instead
|
|
53
|
+
root, _err = Open3.capture2("git", "-C", repo.dir.to_s,
|
|
54
|
+
"rev-list", "--max-parents=0", "HEAD")
|
|
55
|
+
repo.gcommit(root.lines.first.strip).date
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
def updated(repo)
|
|
53
|
-
repo.gcommit(
|
|
59
|
+
repo.gcommit("HEAD").date
|
|
54
60
|
end
|
|
55
61
|
|
|
56
62
|
def dirty?(repo)
|
|
57
|
-
!repo.
|
|
63
|
+
!repo.status_info.changed.empty?
|
|
58
64
|
end
|
|
59
65
|
end
|
|
60
66
|
|
|
@@ -122,7 +128,8 @@ module Fontist
|
|
|
122
128
|
rescue StandardError => e
|
|
123
129
|
# Catch all git-related errors
|
|
124
130
|
if e.class.name.include?("Git") || e.message.match?(/git|pull|repository/i)
|
|
125
|
-
|
|
131
|
+
url = git.config_get("remote.origin.url")&.value
|
|
132
|
+
handle_git_error(name, url, e, :update)
|
|
126
133
|
else
|
|
127
134
|
raise
|
|
128
135
|
end
|
|
@@ -164,7 +171,7 @@ module Fontist
|
|
|
164
171
|
|
|
165
172
|
begin
|
|
166
173
|
git = Git.open(repo_path_obj)
|
|
167
|
-
existing_url = git.
|
|
174
|
+
existing_url = git.config_get("remote.origin.url")&.value
|
|
168
175
|
return repo_name if normalize_git_url(existing_url) == normalized_target
|
|
169
176
|
rescue StandardError
|
|
170
177
|
# Skip repos that can't be opened
|
data/lib/fontist/system_index.rb
CHANGED
|
@@ -559,19 +559,48 @@ stats:)
|
|
|
559
559
|
verbose: verbose, stats: stats,
|
|
560
560
|
num_workers: num_cores)
|
|
561
561
|
else
|
|
562
|
-
#
|
|
563
|
-
#
|
|
564
|
-
#
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
562
|
+
# Threads, not forked processes: a silent scan runs from inside
|
|
563
|
+
# long-lived host processes (e.g. metanorma, whose heap reaches
|
|
564
|
+
# hundreds of MB by the time fonts are looked up). Each fork
|
|
565
|
+
# inherits that heap, and its RSS is charged to the process group
|
|
566
|
+
# while it lives, so an 8-process scan transiently multiplies the
|
|
567
|
+
# host's footprint by up to 9x — measured 3.6GB against a 0.9GB
|
|
568
|
+
# parent during a metanorma compile (OOMs under cgroup caps).
|
|
569
|
+
# The ~1s-per-600-fonts scan penalty is bounded and paid only on
|
|
570
|
+
# cache-miss rebuilds. split_paths_by_reuse keeps cached entries
|
|
571
|
+
# in the parent: see its comment for the marshal constraint.
|
|
572
|
+
to_scan, cached_results = split_paths_by_reuse(
|
|
573
|
+
sorted_paths,
|
|
574
|
+
existing_fonts_by_path)
|
|
575
|
+
|
|
576
|
+
results = Parallel.map(to_scan, in_threads: num_cores) do |path|
|
|
577
|
+
detect_fonts(path, stats: nil)
|
|
568
578
|
end.flatten.compact
|
|
569
579
|
|
|
570
|
-
stats&.total_fonts = results.size
|
|
571
|
-
results
|
|
580
|
+
stats&.total_fonts = cached_results.size + results.size
|
|
581
|
+
cached_results + results
|
|
572
582
|
end
|
|
573
583
|
end
|
|
574
584
|
|
|
585
|
+
# The stat-only reuse check runs in the parent: cached entries can
|
|
586
|
+
# carry backrefs to their SystemIndexFontCollection (whose
|
|
587
|
+
# paths_loader is a Proc), and worker results are Marshal.dump'ed
|
|
588
|
+
# back across the fork boundary — crossing it with cached
|
|
589
|
+
# collections raises "no _dump_data is defined for class Proc".
|
|
590
|
+
# Workers therefore receive only to-scan paths, and the block
|
|
591
|
+
# handed to Parallel closes over nothing but its argument.
|
|
592
|
+
def split_paths_by_reuse(sorted_paths, existing_fonts_by_path)
|
|
593
|
+
unchanged, to_scan = sorted_paths.partition do |path|
|
|
594
|
+
cached = existing_fonts_by_path[path]
|
|
595
|
+
cached&.any? && file_unchanged?(path, cached.first)
|
|
596
|
+
end
|
|
597
|
+
cached_results = unchanged.flat_map do |path|
|
|
598
|
+
existing_fonts_by_path[path].to_a
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
[to_scan, cached_results]
|
|
602
|
+
end
|
|
603
|
+
|
|
575
604
|
def process_paths_in_threads(sorted_paths, existing_fonts_by_path,
|
|
576
605
|
verbose:, stats:, num_workers:)
|
|
577
606
|
progress = ScanProgress.new(sorted_paths.size, verbose: verbose) do |count, path|
|
data/lib/fontist/update.rb
CHANGED
|
@@ -32,14 +32,14 @@ module Fontist
|
|
|
32
32
|
Git.open(Fontist.formulas_repo_path)
|
|
33
33
|
else
|
|
34
34
|
Git.init(Fontist.formulas_repo_path.to_s).tap do |g|
|
|
35
|
-
g.
|
|
35
|
+
g.remote_add("origin", Fontist.formulas_repo_url)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
return git.pull("origin", @branch) if git.current_branch == @branch
|
|
40
40
|
|
|
41
|
-
git.
|
|
42
|
-
|
|
41
|
+
git.config_set("remote.origin.fetch",
|
|
42
|
+
"+refs/heads/#{@branch}:refs/remotes/origin/#{@branch}")
|
|
43
43
|
git.fetch
|
|
44
44
|
git.checkout(@branch)
|
|
45
45
|
git.pull("origin", @branch)
|
data/lib/fontist/version.rb
CHANGED
data/lib/fontist/yaml_backend.rb
CHANGED
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
module Fontist
|
|
4
4
|
# Model YAML engine selection.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
# documents
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
6
|
+
# The yeptris engine (native loader, measured 4x faster than Psych on
|
|
7
|
+
# large documents) activates only when explicitly enabled with
|
|
8
|
+
# FONTIST_YAML=yeptris. It is off by default because the yeptris
|
|
9
|
+
# x86_64-linux and Windows builds currently mis-parse some plain
|
|
10
|
+
# scalars as single-element Arrays (leptris/yeptris#863); flip the
|
|
11
|
+
# default once that parity fix lands.
|
|
12
12
|
module YamlBackend
|
|
13
13
|
ENV_KEY = "FONTIST_YAML"
|
|
14
|
+
ENABLED_VALUE = "yeptris"
|
|
14
15
|
|
|
15
16
|
class << self
|
|
16
17
|
# Returns the activated adapter class, or nil when the standard
|
|
17
|
-
# engine stays in place (flag
|
|
18
|
+
# engine stays in place (flag unset, or yeptris unavailable)
|
|
18
19
|
def activate!
|
|
19
|
-
return nil
|
|
20
|
+
return nil unless enabled?
|
|
20
21
|
return nil unless yeptris_available?
|
|
21
22
|
|
|
22
23
|
adapter = Yaml::YeptrisAdapter
|
|
@@ -25,8 +26,8 @@ module Fontist
|
|
|
25
26
|
adapter
|
|
26
27
|
end
|
|
27
28
|
|
|
28
|
-
def
|
|
29
|
-
ENV[ENV_KEY] ==
|
|
29
|
+
def enabled?
|
|
30
|
+
ENV[ENV_KEY] == ENABLED_VALUE
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def yeptris_available?
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fontist
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -536,7 +536,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
536
536
|
requirements:
|
|
537
537
|
- - ">="
|
|
538
538
|
- !ruby/object:Gem::Version
|
|
539
|
-
version:
|
|
539
|
+
version: 3.0.0
|
|
540
540
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
541
541
|
requirements:
|
|
542
542
|
- - ">="
|