Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test #43

Merged
merged 2 commits into from
Apr 25, 2024
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: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
erlang 26.2.1
elixir 1.16.0-otp-26
4 changes: 2 additions & 2 deletions lib/cldr/backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,8 @@ defmodule Cldr.Territory.Backend do
iex> #{inspect __MODULE__}.to_currency_codes(:US)
{:ok, [:USD]}

iex> #{inspect __MODULE__}.to_currency_codes("cu")
{:ok, [:CUP, :CUC]}
iex> #{inspect __MODULE__}.to_currency_codes("ht")
{:ok, [:USD, :HTG]}

"""
@doc since: "2.0.0"
Expand Down
9 changes: 4 additions & 5 deletions lib/cldr/territory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ defmodule Cldr.Territory do
@territory_containment Cldr.Config.territory_containers()
@territory_info Cldr.Config.territories()
@subdivision_aliases Map.new(Map.fetch!(Cldr.Config.aliases(), :subdivision), fn
{k, <<v::binary>>} -> {:"#{k}", :"#{v}"}
{k, v} when is_atom(v) -> {:"#{k}", v}
{k, v} -> {:"#{k}", Enum.map(v, &:"#{&1}")}
{k, v} when is_list(v) -> {:"#{k}", Enum.map(v, &:"#{&1}")}
{k, v} -> {:"#{k}", :"#{v}"}
end)

@doc """
Expand Down Expand Up @@ -872,8 +871,8 @@ defmodule Cldr.Territory do
iex> Cldr.Territory.to_currency_codes(:US)
{:ok, [:USD]}

iex> Cldr.Territory.to_currency_codes("cu")
{:ok, [:CUP, :CUC]}
iex> Cldr.Territory.to_currency_codes("ht")
{:ok, [:USD, :HTG]}
"""
@doc since: "1.2.0"
@spec to_currency_codes(atom() | String.t() | LanguageTag.t(), Keyword.t()) :: {:ok, [atom() | String.t() | charlist()]} | {:error, {module(), String.t()}}
Expand Down
12 changes: 10 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Cldr.Territories.Mixfile do
[
app: :ex_cldr_territories,
version: @version,
elixir: "~> 1.11",
elixir: "~> 1.12",
name: "Cldr Territories",
source_url: "https://github.com/schultzer/cldr_territories",
description: description(),
Expand Down Expand Up @@ -39,13 +39,21 @@ defmodule Cldr.Territories.Mixfile do

defp deps do
[
{:ex_cldr, "~> 2.37"},
cldr_dep(),
{:ex_doc, "~> 0.18", only: [:release, :dev]},
{:jason, "~> 1.0", optional: true},
{:dialyxir, "~> 1.0", only: [:dev], runtime: false, optional: true},
]
end

defp cldr_dep do
cond do
path = System.get_env("CLDR_PATH") -> {:ex_cldr, path: path}
branch = System.get_env("BRANCH") -> {:ex_cldr, github: "elixir-cldr/cldr", branch: branch}
true -> {:ex_cldr, git: "https://github.com/elixir-cldr/cldr.git"}
end
end

defp package do
[
maintainers: ["Benjamin Schultzer"],
Expand Down
8 changes: 4 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
%{
"abnf2": {:hex, :abnf2, "0.1.2", "6f8792b8ac3288dba5fc889c2bceae9fe78f74e1a7b36bea9726ffaa9d7bef95", [:mix], [], "hexpm"},
"cldr_utils": {:hex, :cldr_utils, "2.23.1", "5c7df90f10b2ffe2519124f3c0cba1bfc0a303d91c34c2e130e86c4f7bf1840c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "42242882f76499fc28e59c80da8b832904cbe68ea50eeb42e65350b0dae7640c"},
"cldr_utils": {:hex, :cldr_utils, "2.25.0", "3cc2ab6e9e4f855ba78a3f3fc4963ccf7b68b731f4e91de3d9b310adddb96b62", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "9041660356ffa1129e0d87d110e188f5da0e0bba94fb915e11275e04ace066e1"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"},
"earmark": {:hex, :earmark, "1.4.5", "62ffd3bd7722fb7a7b1ecd2419ea0b458c356e7168c1f5d65caf09b4fbdd13c8", [:mix], [], "hexpm", "b7d0e6263d83dc27141a523467799a685965bf8b13b6743413f19a7079843f4f"},
"earmark_parser": {:hex, :earmark_parser, "1.4.19", "de0d033d5ff9fc396a24eadc2fcf2afa3d120841eb3f1004d138cbf9273210e8", [:mix], [], "hexpm", "527ab6630b5c75c3a3960b75844c314ec305c76d9899bb30f71cb85952a9dc45"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_cldr": {:hex, :ex_cldr, "2.37.0", "3c2957505efb3b721faa365ff80510342f85ca68fb6ca9602ac17a146cda9ee0", [:mix], [{:cldr_utils, "~> 2.21", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "93debfed83043111801108f87df01550ff814d1d59078ba3bf11bf36d46f9063"},
"ex_cldr": {:git, "https://github.com/elixir-cldr/cldr.git", "801293c10d57fe63388078d51fdd42d4f24b7fa6", []},
"ex_doc": {:hex, :ex_doc, "0.28.1", "34fab7e7201c5a1f275f3b2f837125c940c512e8543d181bd4dd7acb19c8dba0", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "10e564dd59101a5edc4de7009a54baed015a246dee01f7200aab24e8f57fc044"},
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm"},
}
6 changes: 3 additions & 3 deletions test/territory_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ defmodule Cldr.TerritoryTest do
@info %{
currency: [
USD: %{from: ~D[1792-01-01]},
USS: %{tender: false, to: ~D[2014-03-01]},
USN: %{tender: false}
USN: %{tender: false},
USS: %{tender: false, to: ~D[2014-03-01]}
],
gdp: 19490000000000,
language_population: %{
Expand Down Expand Up @@ -112,6 +112,7 @@ defmodule Cldr.TerritoryTest do
assert {:ok, "US"} == Territory.from_territory_code("US", TestBackend.Cldr, [style: :short])
assert {:ok, "Sjedinjene Države"} == Territory.from_territory_code(:US, TestBackend.Cldr, [locale: "bs"])
assert {:ok, "SAD"} == Territory.from_territory_code(:US, TestBackend.Cldr, [locale: "bs", style: :short])
assert {:ok, "Sark"} == Territory.from_territory_code(:CQ, TestBackend.Cldr, [locale: "nl"])
end

test "with invalid params" do
Expand All @@ -120,7 +121,6 @@ defmodule Cldr.TerritoryTest do
assert {:error, {Cldr.InvalidLanguageError, "The language \"zzz\" is invalid"}} == Territory.from_territory_code(:US, TestBackend.Cldr, [locale: :zzz, style: :short])
assert {:error, {Cldr.UnknownStyleError, "The style \"zzz\" is unknown"}} == Territory.from_territory_code(:US, TestBackend.Cldr, [locale: "en", style: "zzz"])
assert {:error, {Cldr.UnknownStyleError, "The style :zzz is unknown"}} == Territory.from_territory_code(:US, TestBackend.Cldr, [locale: "en", style: :zzz])
assert {:error, {Cldr.UnknownTerritoryError, "No territory translation for :CQ could be found in locale :nl"}} == Territory.from_territory_code(:CQ, TestBackend.Cldr, [locale: "nl"])
assert {:error, {Cldr.UnknownTerritoryError, "The territory nil is unknown"}} == Territory.from_territory_code(nil, TestBackend.Cldr, [locale: "bs", style: :short])
end
end
Expand Down
Loading