ucode 0.5.2 → 0.5.3

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: 2d93808cc35d75099bb2028677c0ece5bcac1985cf93b20dbb3ba83d6161bd7a
4
- data.tar.gz: 230980b63347f44f11b0cf5238836c0328aa0d46711baca05fec78830e5f67f3
3
+ metadata.gz: 17cbcd20288991b0c1392fb75f7190f0e4b5eaf56f71806f497eec24444caeaa
4
+ data.tar.gz: 9a901ccc82d0da5e54888fddb9e2af66fc70ab3ed0a4f6904bd98dfe62d17ab5
5
5
  SHA512:
6
- metadata.gz: b1e56059471ba2fe204f018c41811f19f20f1cf1569ac9da91004031561f8826c64faba4d7ecd07963d273ca51631ec71589c74860e54521e6e1d30b4ec321f7
7
- data.tar.gz: 2f30cd92e0ac72619250363c4b71321241042b3ade8a7eaaf20c8bfffa2c3d79be42414e1b872d1f0375c470a4c9b82825e8a518ec328022d6c6a8096b8211a6
6
+ metadata.gz: a896530701e78f713caaa9bfb2408dbc00157dab0aca51ead1c587120aa3c6d1e0fed3a8fa6383b0c9de724cb8a90dc0e7b5f945f051ee66eded449624c5be6d
7
+ data.tar.gz: 060601504647de557b1f1fa6bad4d2154c2687331e46463b27f54d6a9883076684397319f722e678fdbed46d6098002abc621bdab86892f3b75d996c0973a0ff
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  unicode_version: 17.0.0
3
- ucode_version: 0.5.1
3
+ ucode_version: 0.5.2
4
4
  generated_at: '2026-06-28T00:00:00Z'
5
5
  default_sources:
6
6
  - kind: fontist
@@ -22,10 +22,20 @@ module Ucode
22
22
  # generated_at / source_sha256 / source_file (per-report identity),
23
23
  # codepoints / codepoint_ranges (handled via CodepointSetDiff),
24
24
  # and nested models (surfaced via structural add/remove lists).
25
- COMPARED_FIELDS = %i[
26
- family_name subfamily_name full_name postscript_name version
27
- font_revision weight_class width_class italic bold panose
28
- total_codepoints total_glyphs
25
+ COMPARED_FIELDS = [
26
+ [:family_name, lambda(&:family_name)],
27
+ [:subfamily_name, lambda(&:subfamily_name)],
28
+ [:full_name, lambda(&:full_name)],
29
+ [:postscript_name, lambda(&:postscript_name)],
30
+ [:version, lambda(&:version)],
31
+ [:font_revision, lambda(&:font_revision)],
32
+ [:weight_class, lambda(&:weight_class)],
33
+ [:width_class, lambda(&:width_class)],
34
+ [:italic, lambda(&:italic)],
35
+ [:bold, lambda(&:bold)],
36
+ [:panose, lambda(&:panose)],
37
+ [:total_codepoints, lambda(&:total_codepoints)],
38
+ [:total_glyphs, lambda(&:total_glyphs)],
29
39
  ].freeze
30
40
 
31
41
  # @param left_report [Models::Audit::AuditReport]
@@ -54,9 +64,9 @@ module Ucode
54
64
  private
55
65
 
56
66
  def field_changes
57
- COMPARED_FIELDS.filter_map do |field|
58
- left_val = @left.public_send(field)
59
- right_val = @right.public_send(field)
67
+ COMPARED_FIELDS.filter_map do |field, reader|
68
+ left_val = reader.call(@left)
69
+ right_val = reader.call(@right)
60
70
  next if left_val == right_val
61
71
 
62
72
  Models::Audit::FieldChange.new(
@@ -60,25 +60,25 @@ module Ucode
60
60
  end
61
61
 
62
62
  # OS/2 table fields exposed on Metrics, as
63
- # `Metrics attribute name` => `OS/2 reader method`.
63
+ # `Metrics attribute name` => `OS/2 reader lambda`.
64
64
  OS2_FIELDS = {
65
- typo_ascender: :s_typo_ascender,
66
- typo_descender: :s_typo_descender,
67
- typo_line_gap: :s_typo_line_gap,
68
- win_ascent: :us_win_ascent,
69
- win_descent: :us_win_descent,
70
- x_height: :sx_height,
71
- cap_height: :s_cap_height,
72
- subscript_x_size: :y_subscript_x_size,
73
- subscript_y_size: :y_subscript_y_size,
74
- subscript_x_offset: :y_subscript_x_offset,
75
- subscript_y_offset: :y_subscript_y_offset,
76
- superscript_x_size: :y_superscript_x_size,
77
- superscript_y_size: :y_superscript_y_size,
78
- superscript_x_offset: :y_superscript_x_offset,
79
- superscript_y_offset: :y_superscript_y_offset,
80
- strikeout_size: :y_strikeout_size,
81
- strikeout_position: :y_strikeout_position,
65
+ typo_ascender: lambda(&:s_typo_ascender),
66
+ typo_descender: lambda(&:s_typo_descender),
67
+ typo_line_gap: lambda(&:s_typo_line_gap),
68
+ win_ascent: lambda(&:us_win_ascent),
69
+ win_descent: lambda(&:us_win_descent),
70
+ x_height: lambda(&:sx_height),
71
+ cap_height: lambda(&:s_cap_height),
72
+ subscript_x_size: lambda(&:y_subscript_x_size),
73
+ subscript_y_size: lambda(&:y_subscript_y_size),
74
+ subscript_x_offset: lambda(&:y_subscript_x_offset),
75
+ subscript_y_offset: lambda(&:y_subscript_y_offset),
76
+ superscript_x_size: lambda(&:y_superscript_x_size),
77
+ superscript_y_size: lambda(&:y_superscript_y_size),
78
+ superscript_x_offset: lambda(&:y_superscript_x_offset),
79
+ superscript_y_offset: lambda(&:y_superscript_y_offset),
80
+ strikeout_size: lambda(&:y_strikeout_size),
81
+ strikeout_position: lambda(&:y_strikeout_position),
82
82
  }.freeze
83
83
  private_constant :OS2_FIELDS
84
84
 
@@ -86,7 +86,7 @@ module Ucode
86
86
  os2 = table(font, "OS/2")
87
87
  return {} unless os2
88
88
 
89
- OS2_FIELDS.transform_values { |reader| os2.public_send(reader)&.to_i }
89
+ OS2_FIELDS.transform_values { |reader| reader.call(os2)&.to_i }
90
90
  end
91
91
 
92
92
  def post_fields(font)
@@ -67,8 +67,8 @@ module Ucode
67
67
  private
68
68
 
69
69
  def discover_font_paths
70
- method = @recursive ? :find : :children
71
- @root_path.public_send(method).select do |entry|
70
+ entries = @recursive ? @root_path.find : @root_path.children
71
+ entries.select do |entry|
72
72
  next false unless entry.file?
73
73
  next false if entry.symlink?
74
74
 
data/lib/ucode/cli.rb CHANGED
@@ -629,8 +629,8 @@ module Ucode
629
629
 
630
630
  desc "compare LEFT RIGHT", "Diff two audits"
631
631
  option :unicode_version, type: :string, default: nil
632
- option :output, type: :string, default: nil,
633
- desc: "Write text diff to file (default: stdout)"
632
+ option :output, type: :string, default: nil,
633
+ desc: "Write text diff to file (default: stdout)"
634
634
  def compare(left, right)
635
635
  result = Commands::Audit::CompareCommand.new.call(
636
636
  left, right,
@@ -8,13 +8,13 @@ module Ucode
8
8
  # `Indices#each_relationship` instead of reaching into the Struct by
9
9
  # field name (see Candidate 1 of the 2026-06-29 architecture review).
10
10
  RELATIONSHIPS = [
11
- ["special_casing", :special_casing],
12
- ["case_folding", :case_folding],
13
- ["bidi_mirroring", :bidi_mirroring],
14
- ["bidi_brackets", :bidi_brackets],
15
- ["cjk_radicals", :cjk_radicals],
16
- ["standardized_variants", :standardized_variants],
17
- ["name_aliases", :name_aliases],
11
+ ["special_casing", lambda(&:special_casing)],
12
+ ["case_folding", lambda(&:case_folding)],
13
+ ["bidi_mirroring", lambda(&:bidi_mirroring)],
14
+ ["bidi_brackets", lambda(&:bidi_brackets)],
15
+ ["cjk_radicals", lambda(&:cjk_radicals)],
16
+ ["standardized_variants", lambda(&:standardized_variants)],
17
+ ["name_aliases", lambda(&:name_aliases)],
18
18
  ].freeze
19
19
  private_constant :RELATIONSHIPS
20
20
 
@@ -72,8 +72,8 @@ module Ucode
72
72
  def each_relationship(&)
73
73
  return enum_for(:each_relationship) unless block_given?
74
74
 
75
- RELATIONSHIPS.each do |slug, field|
76
- yield(slug, public_send(field))
75
+ RELATIONSHIPS.each do |slug, reader|
76
+ yield(slug, reader.call(self))
77
77
  end
78
78
  end
79
79
  end
@@ -99,31 +99,31 @@ module Ucode
99
99
  blocks: range_index(ucd_dir, "Blocks.txt", Parsers::Blocks),
100
100
  scripts: scripts_index(ucd_dir, property_value_aliases),
101
101
  property_value_aliases: property_value_aliases,
102
- derived_age: cp_index(ucd_dir, "DerivedAge.txt", Parsers::DerivedAge, :cp),
102
+ derived_age: cp_index(ucd_dir, "DerivedAge.txt", Parsers::DerivedAge, &:cp),
103
103
  binary_properties: multi_cp_index(ucd_dir, "DerivedCoreProperties.txt",
104
104
  Parsers::DerivedCoreProperties),
105
105
  script_extensions: multi_cp_index(ucd_dir, "ScriptExtensions.txt",
106
- Parsers::ScriptExtensions, :cp),
106
+ Parsers::ScriptExtensions, &:cp),
107
107
  bidi_mirroring: cp_index(ucd_dir, "BidiMirroring.txt",
108
- Parsers::BidiMirroring, :codepoint),
108
+ Parsers::BidiMirroring, &:codepoint),
109
109
  bidi_brackets: cp_index(ucd_dir, "BidiBrackets.txt",
110
- Parsers::BidiBrackets, :codepoint),
110
+ Parsers::BidiBrackets, &:codepoint),
111
111
  special_casing: multi_cp_index(ucd_dir, "SpecialCasing.txt",
112
112
  Parsers::SpecialCasing),
113
113
  # CaseFolding: one cp can carry C, F, S, and T statuses; the
114
114
  # Coordinator buckets each row into CodePoint::CaseFolding by
115
115
  # status, so the index holds an Array per cp.
116
116
  case_folding: multi_cp_index(ucd_dir, "CaseFolding.txt",
117
- Parsers::CaseFolding, :codepoint),
117
+ Parsers::CaseFolding, &:codepoint),
118
118
  name_aliases: multi_cp_index(ucd_dir, "NameAliases.txt",
119
119
  Parsers::NameAliases),
120
120
  # CJKRadicals maps a canonical ideograph (e.g. U+4E00) to its
121
121
  # KangXi radical; the lookup key is the ideograph_id ("U+XXXX"),
122
122
  # not the radical_number or the cjk_radical_id.
123
123
  cjk_radicals: multi_cp_index_by_id(ucd_dir, "CJKRadicals.txt",
124
- Parsers::CjkRadicals, :ideograph_id),
124
+ Parsers::CjkRadicals, &:ideograph_id),
125
125
  standardized_variants: multi_cp_index_by_id(ucd_dir, "StandardizedVariants.txt",
126
- Parsers::StandardizedVariants, :base_id),
126
+ Parsers::StandardizedVariants, &:base_id),
127
127
  names_list: names_list_index(ucd_dir),
128
128
  unihan: unihan_index(unihan_dir),
129
129
  line_break: range_value_index(ucd_dir, "LineBreak.txt"),
@@ -180,37 +180,37 @@ module Ucode
180
180
  end.sort_by(&:range_first)
181
181
  end
182
182
 
183
- # Indexes by integer codepoint for parsers whose record exposes a
184
- # `codepoint` integer accessor (or any method returning Integer).
185
- def cp_index(ucd_dir, filename, parser, key_method)
183
+ # Indexes by the codepoint the given block extracts from each record.
184
+ def cp_index(ucd_dir, filename, parser, &)
186
185
  path = Pathname.new(ucd_dir).join(filename)
187
186
  return {} unless path.exist?
188
187
 
189
188
  parser.each_record(path).each_with_object({}) do |record, h|
190
- h[record.public_send(key_method)] = record
189
+ h[yield(record)] = record
191
190
  end
192
191
  end
193
192
 
194
193
  # Multi-valued index by integer codepoint. Each cp maps to an array
195
194
  # of records (e.g. one cp can have several binary properties, several
196
195
  # script extensions, several SpecialCasing rules).
197
- def multi_cp_index(ucd_dir, filename, parser, key_method = :codepoint)
196
+ def multi_cp_index(ucd_dir, filename, parser, &key)
197
+ key ||= lambda(&:codepoint)
198
198
  path = Pathname.new(ucd_dir).join(filename)
199
199
  return {} unless path.exist?
200
200
 
201
201
  parser.each_record(path).each_with_object(Hash.new { |h, k| h[k] = [] }) do |record, h|
202
- h[record.public_send(key_method)] << record
202
+ h[key.call(record)] << record
203
203
  end
204
204
  end
205
205
 
206
206
  # Multi-valued index keyed by a "U+XXXX" string id (e.g. standardized
207
207
  # variants are keyed by base_id).
208
- def multi_cp_index_by_id(ucd_dir, filename, parser, key_method)
208
+ def multi_cp_index_by_id(ucd_dir, filename, parser, &)
209
209
  path = Pathname.new(ucd_dir).join(filename)
210
210
  return {} unless path.exist?
211
211
 
212
212
  parser.each_record(path).each_with_object(Hash.new { |h, k| h[k] = [] }) do |record, h|
213
- h[record.public_send(key_method)] << record
213
+ h[yield(record)] << record
214
214
  end
215
215
  end
216
216
 
@@ -39,8 +39,8 @@ module Ucode
39
39
  attribute :svg_document_count, :integer
40
40
 
41
41
  # CBDT/CBLC (color bitmaps — paired tables).
42
- attribute :has_cbdt, Lutaml::Model::Type::Boolean
43
- attribute :has_cblc, Lutaml::Model::Type::Boolean
42
+ attribute :has_cbdt, Lutaml::Model::Type::Boolean
43
+ attribute :has_cblc, Lutaml::Model::Type::Boolean
44
44
  # Strike count comes from the paired CBLC locator table.
45
45
  attribute :cbdt_strike_count, :integer
46
46
 
@@ -58,6 +58,19 @@ module Ucode
58
58
  attribute :variants, UnihanField, collection: true, default: -> { [] }
59
59
  attribute :other_mappings, UnihanField, collection: true, default: -> { [] }
60
60
 
61
+ # Collection accessors per category, mirroring CATEGORIES. Explicit
62
+ # lambdas instead of dynamic dispatch so the buckets stay greppable.
63
+ BUCKETS = {
64
+ dictionary_indices: lambda(&:dictionary_indices),
65
+ dictionary_like_data: lambda(&:dictionary_like_data),
66
+ irg_sources: lambda(&:irg_sources),
67
+ numeric_values: lambda(&:numeric_values),
68
+ radical_stroke_counts: lambda(&:radical_stroke_counts),
69
+ readings: lambda(&:readings),
70
+ variants: lambda(&:variants),
71
+ other_mappings: lambda(&:other_mappings),
72
+ }.freeze
73
+
61
74
  # Pushes a field into the right category bucket. Used by the
62
75
  # Coordinator when streaming records from the parser.
63
76
  #
@@ -65,13 +78,13 @@ module Ucode
65
78
  # @param name [String] e.g. "kMandarin"
66
79
  # @param values [Array<String>] space-split values from Unihan
67
80
  def add(category, name, values)
68
- attr_name = CATEGORIES.fetch(category) { return }
69
- public_send(attr_name) << UnihanField.new(name: name, values: values)
81
+ bucket = BUCKETS.fetch(category) { return }
82
+ bucket.call(self) << UnihanField.new(name: name, values: values)
70
83
  end
71
84
 
72
85
  # True if any category has data.
73
86
  def any?
74
- CATEGORIES.keys.any? { |sym| !public_send(sym).empty? }
87
+ BUCKETS.each_value.any? { |bucket| !bucket.call(self).empty? }
75
88
  end
76
89
 
77
90
  # All fields across every category, flattened to {name => values}.
@@ -80,8 +93,8 @@ module Ucode
80
93
  #
81
94
  # @return [Hash{String => Array<String>}]
82
95
  def all_fields
83
- CATEGORIES.keys.each_with_object({}) do |sym, h|
84
- public_send(sym).each { |f| h[f.name] = f.values }
96
+ BUCKETS.each_value.with_object({}) do |bucket, h|
97
+ bucket.call(self).each { |f| h[f.name] = f.values }
85
98
  end
86
99
  end
87
100
 
@@ -240,9 +240,21 @@ module Ucode
240
240
  end
241
241
  end
242
242
 
243
+ # Container accessor for each annotation kind `parse_annotation`
244
+ # can return. Kept beside the marker dispatch so adding a marker
245
+ # is one case branch plus one entry here.
246
+ ENTRY_CONTAINERS = {
247
+ cross_references: lambda(&:cross_references),
248
+ sample_sequences: lambda(&:sample_sequences),
249
+ compatibility_equivalents: lambda(&:compatibility_equivalents),
250
+ informal_aliases: lambda(&:informal_aliases),
251
+ footnotes: lambda(&:footnotes),
252
+ }.freeze
253
+ private_constant :ENTRY_CONTAINERS
254
+
243
255
  def attach_annotation(entry, parsed)
244
256
  attr_name, instance = parsed
245
- entry.public_send(attr_name) << instance
257
+ ENTRY_CONTAINERS.fetch(attr_name).call(entry) << instance
246
258
  end
247
259
  end
248
260
  end
data/lib/ucode/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ucode
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
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-07-21 00:00:00.000000000 Z
11
+ date: 2026-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -104,16 +104,22 @@ dependencies:
104
104
  name: rubyzip
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '2.3'
110
+ - - "<"
111
+ - !ruby/object:Gem::Version
112
+ version: '4'
110
113
  type: :runtime
111
114
  prerelease: false
112
115
  version_requirements: !ruby/object:Gem::Requirement
113
116
  requirements:
114
- - - "~>"
117
+ - - ">="
115
118
  - !ruby/object:Gem::Version
116
119
  version: '2.3'
120
+ - - "<"
121
+ - !ruby/object:Gem::Version
122
+ version: '4'
117
123
  - !ruby/object:Gem::Dependency
118
124
  name: sqlite3
119
125
  requirement: !ruby/object:Gem::Requirement
@@ -518,7 +524,6 @@ files:
518
524
  - lib/ucode/version.rb
519
525
  - lib/ucode/version_resolver.rb
520
526
  - schema/block-feed.output.schema.yml
521
- - ucode.gemspec
522
527
  homepage: https://github.com/fontist/ucode
523
528
  licenses:
524
529
  - BSD-2-Clause
data/ucode.gemspec DELETED
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/ucode/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "ucode"
7
- spec.version = Ucode::VERSION
8
- spec.authors = ["Ribose Inc."]
9
- spec.email = ["open.source@ribose.com"]
10
-
11
- spec.summary = "Unicode Character Database toolkit — lookup, dataset, glyphs, site"
12
- spec.description = <<~DESC
13
- ucode turns the Unicode Character Database (UCD) text files and the official
14
- Unicode Code Charts into a structured, browsable dataset. For every assigned
15
- codepoint it produces a JSON document with full UCD properties, the
16
- human-curated relationships from NamesList.txt, Unihan readings, and
17
- machine-computed references; an SVG of the official glyph vector-extracted
18
- from the Code Charts; and a Vitepress site for browsing Plane, Block,
19
- and Character.
20
- DESC
21
-
22
- spec.homepage = "https://github.com/fontist/ucode"
23
- spec.license = "BSD-2-Clause"
24
- spec.required_ruby_version = ">= 3.2.0"
25
-
26
- spec.metadata["homepage_uri"] = spec.homepage
27
- spec.metadata["source_code_uri"] = "https://github.com/fontist/ucode"
28
- spec.metadata["changelog_uri"] = "https://github.com/fontist/ucode/blob/main/CHANGELOG.md"
29
- spec.metadata["rubygems_mfa_required"] = "true"
30
-
31
- spec.files = Dir.chdir(__dir__) do
32
- `git ls-files -z`.split("\x0").reject do |f|
33
- f == __FILE__ ||
34
- f.start_with?(".") ||
35
- f.start_with?("spec/") ||
36
- f.start_with?("benchmark/") ||
37
- f.start_with?("TODO.impl/") ||
38
- f.start_with?("docs/") ||
39
- f.start_with?("site/")
40
- end
41
- end
42
-
43
- spec.bindir = "exe"
44
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
45
- spec.require_paths = ["lib"]
46
-
47
- spec.add_dependency "base64"
48
- spec.add_dependency "fontisan", "~> 0.4", ">= 0.4.9"
49
- spec.add_dependency "fontist", "~> 3.0"
50
- spec.add_dependency "logger"
51
- spec.add_dependency "lutaml-model", "~> 0.8"
52
- spec.add_dependency "nokogiri", "~> 1.16"
53
- spec.add_dependency "rubyzip", "~> 2.3"
54
- spec.add_dependency "sqlite3", "~> 2.0"
55
- spec.add_dependency "thor", "~> 1.3"
56
- end