Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data
1 change: 1 addition & 0 deletions lib/unitsdb/symbol_presentations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/unitsdb/version.rb
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions spec/unitsdb/currency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Loading