Skip to content

Commit

Permalink
Fix bug in map_binary!/1 and map_charlist!/1
Browse files Browse the repository at this point in the history
  • Loading branch information
Schultzer committed May 10, 2018
1 parent 6edc7f5 commit 7403880
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Cldr Territories v1.3.1 May 10, 2018

### Bug fix

* Fixed a bug intrudeced in 1.3.0 where function with `!` and `as_option` resulted in `{:ok, result}` instead of `result`

## Cldr Territories v1.3.0 May 8, 2018

### Enhancements
Expand All @@ -9,7 +15,7 @@
* `children/2` and `children!/2`
* `to_currency_code/2` and `to_currency_code!/2`
* `to_currency_codes/2` and `to_currency_codes!/2`
* `country_codes/2`
* `country_codes/1`
* Improved specs
* Relaxed posion and jason dependency

Expand Down
16 changes: 14 additions & 2 deletions lib/cldr/territory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,14 @@ defmodule Cldr.Territory do
iex> Cldr.Territory.to_currency_code!(:US)
:USD
iex> Cldr.Territory.to_currency_code!(:US, as: :charlist)
'USD'
iex> Cldr.Territory.to_currency_code!("PS")
:ILS
iex> Cldr.Territory.to_currency_code!("PS", as: :binary)
"ILS"
"""
@spec to_currency_code!(atom_binary_tag(), as_options()) :: atom_binary_charlist() | no_return()
def to_currency_code!(territory_code, opts \\ [as: :atom])
Expand Down Expand Up @@ -903,8 +909,14 @@ defmodule Cldr.Territory do
iex> Cldr.Territory.to_currency_codes!(:US)
[:USD]
iex> Cldr.Territory.to_currency_codes!(:US, as: :charlist)
['USD']
iex> Cldr.Territory.to_currency_codes!("PS")
[:ILS, :JOD]
iex> Cldr.Territory.to_currency_codes!("PS", as: :binary)
["ILS", "JOD"]
"""
@spec to_currency_codes!(atom_binary_tag(), as_options()) :: [atom_binary_charlist()] | no_return()
def to_currency_codes!(territory_code, opts \\ [as: :atom])
Expand Down Expand Up @@ -972,7 +984,7 @@ defmodule Cldr.Territory do
defp map_binary(result) when is_atom(result), do: to_string(result)

defp map_binary!({:error, {exception, reason}}), do: raise exception, reason
defp map_binary!(result), do: map_binary(result)
defp map_binary!({:ok, result}), do: map_binary(result)

defp map_charlist({:error, reason}), do: {:error, reason}
defp map_charlist({:ok, result}), do: {:ok, map_charlist(result)}
Expand All @@ -982,5 +994,5 @@ defmodule Cldr.Territory do
defp map_charlist(result) when is_atom(result), do: to_charlist(result)

defp map_charlist!({:error, {exception, reason}}), do: raise exception, reason
defp map_charlist!(result), do: map_charlist(result)
defp map_charlist!({:ok, result}), do: map_charlist(result)
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule CldrTerritories.Mixfile do
use Mix.Project

@version "1.3.0"
@version "1.3.1"

def project do
[
Expand Down

0 comments on commit 7403880

Please sign in to comment.