From 3f008f29daabc1846b7022b6315ee99a7bf72331 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 11 Nov 2026 22:06:21 +0800 Subject: [PATCH] Release 2.2.14: ambiguous currency symbols on data v2.2.1 SymbolPresentations carries the optional ambiguous flag of the new currency symbol data (bare dollar, yen signs, franc Fr.), the data submodule pins v2.2.1, and VERSION/UNITS_DATA_VERSION track it. --- data | 2 +- lib/unitsdb/symbol_presentations.rb | 1 + lib/unitsdb/version.rb | 4 ++-- spec/unitsdb/currency_spec.rb | 27 +++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/data b/data index c2c7d18..fcc9e41 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit c2c7d181f07f414520d91fafa831922e56db6469 +Subproject commit fcc9e41e0555b003cb17b20958dbbf966ac825e6 diff --git a/lib/unitsdb/symbol_presentations.rb b/lib/unitsdb/symbol_presentations.rb index 8b8e803..38a96ab 100644 --- a/lib/unitsdb/symbol_presentations.rb +++ b/lib/unitsdb/symbol_presentations.rb @@ -8,6 +8,7 @@ class SymbolPresentations < Lutaml::Model::Serializable attribute :latex, :string attribute :mathml, :string attribute :unicode, :string + attribute :ambiguous, :boolean end Config.register_model(SymbolPresentations, id: :symbol_presentations) diff --git a/lib/unitsdb/version.rb b/lib/unitsdb/version.rb index 37f1ada..9a6fd37 100644 --- a/lib/unitsdb/version.rb +++ b/lib/unitsdb/version.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true module Unitsdb - VERSION = "2.2.13" + VERSION = "2.2.14" # The version of the bundled UnitsDB data (from the data/ submodule). # This version corresponds to a tag/commit in https://github.com/unitsml/unitsdb. - UNITS_DATA_VERSION = "2.2.0" + UNITS_DATA_VERSION = "2.2.1" end diff --git a/spec/unitsdb/currency_spec.rb b/spec/unitsdb/currency_spec.rb index ca90c3e..a53474b 100644 --- a/spec/unitsdb/currency_spec.rb +++ b/spec/unitsdb/currency_spec.rb @@ -42,6 +42,33 @@ .to contain_exactly("iso4217", "iso4217_numeric", "unitsml") end + it "carries ambiguous symbol presentations for shared symbols" do + usd = database.currencies.find do |currency| + currency.identifiers.any? { |identifier| identifier.type == "iso4217" && identifier.id == "USD" } + end + jpy = database.currencies.find do |currency| + currency.identifiers.any? { |identifier| identifier.type == "iso4217" && identifier.id == "JPY" } + end + cny = database.currencies.find do |currency| + currency.identifiers.any? { |identifier| identifier.type == "iso4217" && identifier.id == "CNY" } + end + chf = database.currencies.find do |currency| + currency.identifiers.any? { |identifier| identifier.type == "iso4217" && identifier.id == "CHF" } + end + + bare_dollar = usd.symbols.find { |symbol| symbol.unicode == "$" } + expect(bare_dollar.ambiguous).to be(true) + expect(usd.symbols.find { |symbol| symbol.unicode == "US$" }.ambiguous).to be_nil + + expect(jpy.symbols.first.ambiguous).to be(true) + + expect(cny.symbols.map(&:unicode)).to contain_exactly("CN\u00a5", "\u00a5") + expect(cny.symbols.map(&:ambiguous)).to contain_exactly(nil, true) + + expect(chf.symbols.map(&:unicode)).to eq(["Fr."]) + expect(chf.symbols.first.ambiguous).to be(true) + end + it "carries provenance notes on special codes" do xag = database.currencies.find do |currency| currency.identifiers.any? { |identifier| identifier.type == "iso4217" && identifier.id == "XAG" }