Skip to content

Commit a8a4508

Browse files
bdebinskaiStefo
authored andcommitted
update documentation and error message
1 parent 288039b commit a8a4508

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
# ValueFormatters
22

3-
**TODO: Add description**
3+
## Usage
44

5-
## Installation
5+
To use value formatters, the host application needs to set up its own Cldr backend, including the following libraries:
66

7-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
8-
by adding `value_formatters` to your list of dependencies in `mix.exs`:
7+
* Cldr.Number,
8+
* Cldr.Calendar,
9+
* Cldr.DateTime,
10+
* Cldr.Time,
11+
* Cldr.Date
12+
13+
Cldr needs to be passed as an option to the `to_string/3` method under `cldr` key.
914

10-
```elixir
11-
def deps do
12-
[
13-
{:value_formatters, "~> 0.1.0"}
14-
]
15-
end
16-
```
1715

18-
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
19-
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
20-
be found at <https://hexdocs.pm/value_formatters>.
2116

lib/value_formatters.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ defmodule ValueFormatters do
118118
else
119119
:error ->
120120
raise ArgumentError,
121-
message: "The :cldr option is required."
121+
message:
122+
"Attempted to access a Cldr module, but non was specified. Pass the :cldr option to to_string/3 or when instantiating the module."
122123
end
123124
end
124125

test/cldr.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ defmodule ValueFormatters.Cldr do
1010
Cldr.Calendar,
1111
Cldr.DateTime,
1212
Cldr.Time,
13-
Cldr.Date,
14-
Cldr.List
13+
Cldr.Date
1514
]
1615
end

test/value_formatters_test.exs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,11 @@ defmodule ValueFormattersTest do
624624

625625
describe "missing cldr" do
626626
test "returns error when cldr is not available" do
627-
assert_raise ArgumentError, "The :cldr option is required.", fn ->
628-
ValueFormatters.to_string(1.234, %{"format" => "number"}, [])
629-
end
627+
assert_raise ArgumentError,
628+
"Attempted to access a Cldr module, but non was specified. Pass the :cldr option to to_string/3 or when instantiating the module.",
629+
fn ->
630+
ValueFormatters.to_string(1.234, %{"format" => "number"}, [])
631+
end
630632
end
631633
end
632634
end

0 commit comments

Comments
 (0)