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

Update landline numbers in Portugal #505

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion lib/faker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Faker.Address do

alias Faker.Person

@geobase32 '0123456789bcdefghjkmnpqrstuvwxyz'
@geobase32 ~c"0123456789bcdefghjkmnpqrstuvwxyz"

@moduledoc """
Functions for generating addresses.
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/lorem.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
62 changes: 56 additions & 6 deletions lib/faker/phone/pt_pt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,58 @@ defmodule Faker.Phone.PtPt do
end

samplerp(:landline_number_format, [
"2########",
"3########"
"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 """
Expand All @@ -40,13 +90,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"
"296999996"
"""

@spec landline_number() :: String.t()
Expand Down
6 changes: 3 additions & 3 deletions lib/faker/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down