From 725cd4c56361520bfc37b834e722f89ab0d7646b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Je=C5=BC?= <35540+szymon-jez@users.noreply.github.com> Date: Sat, 9 Mar 2024 10:18:29 +0100 Subject: [PATCH 1/5] Update copyright year in README.md --- LICENSE.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 9e5804c..839a398 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 ExPhoneNumber +Copyright (c) 2023-2024 ExPhoneNumber Copyright (c) 2016-2022 NLCollect B.V. diff --git a/README.md b/README.md index 8a06799..35e5a23 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ There is a `mix update_metadata` task that downloads the latest `libphonenumber` ## Copyright and License -Copyright (c) 2023 ExPhoneNumber +Copyright (c) 2023-2024 ExPhoneNumber Copyright (c) 2016-2022 NLCollect B.V. From 6dcc827463f02007b3bc49c6ba65096eed86fa05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Je=C5=BC?= <35540+szymon-jez@users.noreply.github.com> Date: Sat, 9 Mar 2024 10:53:29 +0100 Subject: [PATCH 2/5] Include LICENSE.md in docs --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index d98044c..c310b0e 100644 --- a/mix.exs +++ b/mix.exs @@ -54,7 +54,7 @@ defmodule ExPhoneNumber.Mixfile do defp docs do [ - extras: ["README.md"], + extras: ["README.md", "LICENSE.md"], main: "readme", source_url: @source_url, source_ref: "v#{@version}", From 95e0367c021c3a39b9f66ff56ad43c34a748f3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Je=C5=BC?= <35540+szymon-jez@users.noreply.github.com> Date: Sat, 9 Mar 2024 11:17:24 +0100 Subject: [PATCH 3/5] Include CHANGELOG.md in docs --- mix.exs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index c310b0e..4fa6b23 100644 --- a/mix.exs +++ b/mix.exs @@ -54,11 +54,12 @@ defmodule ExPhoneNumber.Mixfile do defp docs do [ - extras: ["README.md", "LICENSE.md"], + extras: ["README.md", "LICENSE.md", "CHANGELOG.md"], main: "readme", source_url: @source_url, source_ref: "v#{@version}", - homepage_url: @source_url + homepage_url: @source_url, + skip_undefined_reference_warnings_on: ["CHANGELOG.md"] ] end end From b0024462887c2505dfc05e370e5d03a8a5a1c83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Je=C5=BC?= <35540+szymon-jez@users.noreply.github.com> Date: Sat, 9 Mar 2024 12:11:15 +0100 Subject: [PATCH 4/5] Make ExPhoneNumber module appear in documentation --- lib/ex_phone_number.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ex_phone_number.ex b/lib/ex_phone_number.ex index 183e039..800e709 100644 --- a/lib/ex_phone_number.ex +++ b/lib/ex_phone_number.ex @@ -1,5 +1,7 @@ defmodule ExPhoneNumber do - @moduledoc false + @moduledoc """ + Parsing, formatting, and validating international phone numbers. + """ alias ExPhoneNumber.Formatting alias ExPhoneNumber.Parsing From 1410e503873c0a32e47d96a76d954735dc0ee1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Je=C5=BC?= <35540+szymon-jez@users.noreply.github.com> Date: Sat, 9 Mar 2024 12:12:23 +0100 Subject: [PATCH 5/5] Add ExPhoneNumber module example usage and test it --- lib/ex_phone_number.ex | 27 +++++++++++++++++++++++++++ test/ex_phone_number_test.exs | 5 +++++ 2 files changed, 32 insertions(+) create mode 100644 test/ex_phone_number_test.exs diff --git a/lib/ex_phone_number.ex b/lib/ex_phone_number.ex index 800e709..eaabc7a 100644 --- a/lib/ex_phone_number.ex +++ b/lib/ex_phone_number.ex @@ -1,6 +1,33 @@ defmodule ExPhoneNumber do @moduledoc """ Parsing, formatting, and validating international phone numbers. + + ## Example Usage + + iex> ExPhoneNumber.parse("202-456-1111", "US") + { + :ok, + %ExPhoneNumber.Model.PhoneNumber{ + country_code: 1, + country_code_source: nil, + extension: nil, + italian_leading_zero: nil, + national_number: 2024561111, + number_of_leading_zeros: nil, + preferred_domestic_carrier_code: nil, + raw_input: nil + } + } + + iex> {:ok, phone_number} = ExPhoneNumber.parse("202-456-1111", "US") + iex> ExPhoneNumber.format(phone_number, :e164) + "+12024561111" + iex> ExPhoneNumber.is_valid_number?(phone_number) + true + iex> ExPhoneNumber.is_possible_number?(phone_number) + true + iex> ExPhoneNumber.get_number_type(phone_number) + :fixed_line_or_mobile """ alias ExPhoneNumber.Formatting diff --git a/test/ex_phone_number_test.exs b/test/ex_phone_number_test.exs new file mode 100644 index 0000000..0c9c94e --- /dev/null +++ b/test/ex_phone_number_test.exs @@ -0,0 +1,5 @@ +defmodule ExPhoneNumberTest do + use ExSpec, async: true + + doctest ExPhoneNumber +end