From 073c2ef6643ff6381c87e4a24bba03b997c933d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?= Date: Sat, 1 Apr 2023 06:00:18 +0100 Subject: [PATCH 1/2] Update landline numbers in Portugal --- lib/faker/phone/pt_pt.ex | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/faker/phone/pt_pt.ex b/lib/faker/phone/pt_pt.ex index db2884c43..86dc449ea 100644 --- a/lib/faker/phone/pt_pt.ex +++ b/lib/faker/phone/pt_pt.ex @@ -30,8 +30,7 @@ defmodule Faker.Phone.PtPt do end samplerp(:landline_number_format, [ - "2########", - "3########" + "2########" ]) @doc """ @@ -40,13 +39,13 @@ defmodule Faker.Phone.PtPt do ## Examples iex> Faker.Phone.PtPt.landline_number() - "299999999" + "253999999" iex> Faker.Phone.PtPt.landline_number() - "299999998" + "252999998" iex> Faker.Phone.PtPt.landline_number() - "399999999" + "261999997" iex> Faker.Phone.PtPt.landline_number() - "399999998" + "299999996" """ @spec landline_number() :: String.t() From df9d08467d74427decbc6db23854dc30cd56817b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?= Date: Tue, 8 Aug 2023 16:19:21 +0100 Subject: [PATCH 2/2] Update landline numbers in Portugal to correct values --- lib/faker.ex | 2 +- lib/faker/address.ex | 2 +- lib/faker/lorem.ex | 2 +- lib/faker/phone/pt_pt.ex | 55 ++++++++++++++++++++++++++++++++++++++-- lib/faker/util.ex | 6 ++--- 5 files changed, 59 insertions(+), 8 deletions(-) diff --git a/lib/faker.ex b/lib/faker.ex index 337a4ec11..6560d503d 100644 --- a/lib/faker.ex +++ b/lib/faker.ex @@ -47,7 +47,7 @@ defmodule Faker do acc end - @alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + @alphabet ~c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" defp letter do Enum.at(@alphabet, random_between(0, Enum.count(@alphabet) - 1)) end diff --git a/lib/faker/address.ex b/lib/faker/address.ex index 30f276635..5c7dc7c19 100644 --- a/lib/faker/address.ex +++ b/lib/faker/address.ex @@ -3,7 +3,7 @@ defmodule Faker.Address do alias Faker.Person - @geobase32 '0123456789bcdefghjkmnpqrstuvwxyz' + @geobase32 ~c"0123456789bcdefghjkmnpqrstuvwxyz" @moduledoc """ Functions for generating addresses. diff --git a/lib/faker/lorem.ex b/lib/faker/lorem.ex index 1dd90af1c..eb1b1b6a9 100644 --- a/lib/faker/lorem.ex +++ b/lib/faker/lorem.ex @@ -498,7 +498,7 @@ defmodule Faker.Lorem do end defp character do - alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' + alphabet = ~c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" Enum.at(alphabet, Faker.random_between(0, Enum.count(alphabet) - 1)) end end diff --git a/lib/faker/phone/pt_pt.ex b/lib/faker/phone/pt_pt.ex index 86dc449ea..ee4127db2 100644 --- a/lib/faker/phone/pt_pt.ex +++ b/lib/faker/phone/pt_pt.ex @@ -30,7 +30,58 @@ defmodule Faker.Phone.PtPt do end samplerp(:landline_number_format, [ - "2########" + "21#######", + "22#######", + "231######", + "232######", + "233######", + "234######", + "235######", + "236######", + "238######", + "239######", + "241######", + "242######", + "243######", + "244######", + "245######", + "249######", + "251######", + "252######", + "253######", + "254######", + "255######", + "256######", + "257######", + "258######", + "259######", + "261######", + "262######", + "263######", + "265######", + "266######", + "268######", + "269######", + "271######", + "272######", + "273######", + "274######", + "275######", + "276######", + "277######", + "278######", + "279######", + "281######", + "282######", + "283######", + "284######", + "285######", + "286######", + "289######", + "291######", + "292######", + "295######", + "296######" ]) @doc """ @@ -45,7 +96,7 @@ defmodule Faker.Phone.PtPt do iex> Faker.Phone.PtPt.landline_number() "261999997" iex> Faker.Phone.PtPt.landline_number() - "299999996" + "296999996" """ @spec landline_number() :: String.t() diff --git a/lib/faker/util.ex b/lib/faker/util.ex index 34bae38d1..677ec22f6 100644 --- a/lib/faker/util.ex +++ b/lib/faker/util.ex @@ -51,7 +51,7 @@ defmodule Faker.Util do iex> Faker.Util.sample_uniq(0, &Faker.Internet.email/0) ** (FunctionClauseError) no function clause matching in Faker.Util.sample_uniq/3 """ - @spec sample_uniq(pos_integer, (() -> any), MapSet.t()) :: [any] + @spec sample_uniq(pos_integer, (-> any), MapSet.t()) :: [any] def sample_uniq(count, sampler, acc \\ MapSet.new()) when is_integer(count) and count > 0 and is_function(sampler, 0) do case MapSet.size(acc) do @@ -84,7 +84,7 @@ defmodule Faker.Util do Enum.map(0..(n - 1), &fun.(&1)) end - @spec list(integer, (() -> any)) :: [any] + @spec list(integer, (-> any)) :: [any] def list(n, fun) when is_function(fun, 0) do Enum.map(0..(n - 1), fn _ -> fun.() end) end @@ -103,7 +103,7 @@ defmodule Faker.Util do iex> Faker.Util.join(2, " or ", &Faker.Color.name/0) "Purple or White" """ - @spec join(integer, binary, (() -> binary)) :: binary + @spec join(integer, binary, (-> binary)) :: binary def join(n, joiner \\ "", fun) do Enum.join(list(n, fun), joiner) end