Skip to content

Commit

Permalink
Merge pull request #90 from fcevado/0_3_10
Browse files Browse the repository at this point in the history
v0.3.10
  • Loading branch information
fcevado authored Jan 15, 2017
2 parents c346f3f + 800a128 commit f40c47b
Show file tree
Hide file tree
Showing 95 changed files with 122 additions and 118 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: elixir
elixir:
- 1.2.6
- 1.3.2
- 1.4.0

otp_release:
- 18.3
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#Changelog

##v0.3.10:
* Correct number validation for Norway.
* Correct Ireland area codes validation.

##v0.3.9:
* Add and correct various area codes for NANP.
* Better test coverage for NANP numbers.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Phone
[![Build Status](https://travis-ci.org/fcevado/phone.svg?branch=master)](https://travis-ci.org/fcevado/phone)
[![Coverage Status](https://coveralls.io/repos/github/fcevado/phone/badge.svg?branch=master)](https://coveralls.io/github/fcevado/phone?branch=master)
[![Ebert](https://ebertapp.io/github/fcevado/phone.svg)](https://ebertapp.io/github/fcevado/phone.svg)
[![Phone version](https://img.shields.io/hexpm/v/phone.svg)](https://hex.pm/packages/phone)
[![Inline docs](http://inch-ci.org/github/fcevado/phone.svg?branch=master)](http://inch-ci.org/github/fcevado/phone)
[![Hex.pm](https://img.shields.io/hexpm/dt/phone.svg)](https://hex.pm/packages/phone)
Expand Down
16 changes: 8 additions & 8 deletions lib/helpers/area.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule Helper.Area do
defmacro builder do
quote do
def match?(number) do
Regex.match?(regex, number)
Regex.match?(regex(), number)
end

def builder(number) do
Expand All @@ -29,18 +29,18 @@ defmodule Helper.Area do
|> Enum.reverse
|> Module.concat

[[_, code, area, number]] = Regex.scan(regex, number)
[[_, code, area, number]] = Regex.scan(regex(), number)

%{
country: country.country,
a2: country.a2,
a3: country.a3,
country: country.country(),
a2: country.a2(),
a3: country.a3(),
international_code: code,
number: number,
area_code: area,
area_name: area_name,
area_type: area_type,
area_abbreviation: area_abbreviation
area_name: area_name(),
area_type: area_type(),
area_abbreviation: area_abbreviation()
}
end

Expand Down
20 changes: 10 additions & 10 deletions lib/helpers/country.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ defmodule Helper.Country do
defp regex_matcher do
quote do
def match?(number) do
Regex.match?(regex, number)
Regex.match?(regex(), number)
end

def builder(number) do
[[_, code, area, number]] = Regex.scan(regex,number)
[[_, code, area, number]] = Regex.scan(regex(), number)

%{
country: country,
a2: a2,
a3: a3,
country: country(),
a2: a2(),
a3: a3(),
international_code: code,
area_code: area,
number: number
Expand Down Expand Up @@ -53,13 +53,13 @@ defmodule Helper.Country do
defp modules_matcher do
quote do
def match?(number) do
ms = Enum.filter(modules, fn m -> m.match?(number) end)
ms = Enum.filter(modules(), fn m -> m.match?(number) end)
length(ms) > 0
end

def build(number) do
if match?(number) do
[module] = Enum.filter(modules, fn m -> m.match?(number) end)
[module] = Enum.filter(modules(), fn m -> m.match?(number) end)
module.build(number)
else
{:error, "Not a valid phone number."}
Expand All @@ -68,7 +68,7 @@ defmodule Helper.Country do

def build!(number) do
if match?(number) do
[module] = Enum.filter(modules, fn m -> m.match?(number) end)
[module] = Enum.filter(modules(), fn m -> m.match?(number) end)
module.build!(number)
else
raise ArgumentError, message: "Not a valid phone number."
Expand All @@ -79,8 +79,8 @@ defmodule Helper.Country do

defmacro match(matcher) do
case matcher do
:regex -> regex_matcher
:modules -> modules_matcher
:regex -> regex_matcher()
:modules -> modules_matcher()
true ->
raise ArgumentError, "You can only match against :regex or :modules, passed #{inspect matcher}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/phone.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ defmodule Phone do
@spec parse(pos_integer, Atom.t) :: {:ok, Map.t}
@spec parse!(String.t, Atom.t) :: Map.t
@spec parse!(pos_integer, Atom.t) :: Map.t
country_parser
country_parser()

end
2 changes: 1 addition & 1 deletion lib/phone/br/ac.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.AC do
field :area_name, "Acre"
field :area_type, "state"
field :area_abbreviation, "AC"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/al.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.AL do
field :area_name, "Alagoas"
field :area_type, "state"
field :area_abbreviation, "AL"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/am.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.AM do
field :area_name, "Amazonas"
field :area_type, "state"
field :area_abbreviation, "AM"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/ap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.AP do
field :area_name, "Amapá"
field :area_type, "state"
field :area_abbreviation, "AP"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/ba.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.BA do
field :area_name, "Bahia"
field :area_type, "state"
field :area_abbreviation, "BA"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/ce.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.CE do
field :area_name, "Ceará"
field :area_type, "state"
field :area_abbreviation, "CE"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/df.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.DF do
field :area_name, "Distrito Federal"
field :area_type, "district"
field :area_abbreviation, "DF"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/es.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.ES do
field :area_name, "Espírito Santo"
field :area_type, "state"
field :area_abbreviation, "ES"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/go.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.GO do
field :area_name, "Goiás"
field :area_type, "state"
field :area_abbreviation, "GO"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/ma.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.MA do
field :area_name, "Maranhão"
field :area_type, "state"
field :area_abbreviation, "MA"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/mg.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.MG do
field :area_name, "Minas Gerais"
field :area_type, "state"
field :area_abbreviation, "MG"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/ms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.MS do
field :area_name, "Mato Grosso do Sul"
field :area_type, "state"
field :area_abbreviation, "MS"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/mt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.MT do
field :area_name, "Mato Grosso"
field :area_type, "state"
field :area_abbreviation, "MT"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/pa.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.PA do
field :area_name, "Pará"
field :area_type, "state"
field :area_abbreviation, "PA"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/pb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.PB do
field :area_name, "Paraíba"
field :area_type, "state"
field :area_abbreviation, "PB"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/pe.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.PE do
field :area_name, "Pernambuco"
field :area_type, "state"
field :area_abbreviation, "PE"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/pi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.PI do
field :area_name, "Piauí"
field :area_type, "state"
field :area_abbreviation, "PI"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/pr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.PR do
field :area_name, "Paraná"
field :area_type, "state"
field :area_abbreviation, "PR"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/rj.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.RJ do
field :area_name, "Rio de Janeiro"
field :area_type, "state"
field :area_abbreviation, "RJ"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/rn.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.RN do
field :area_name, "Rio Grande do Norte"
field :area_type, "state"
field :area_abbreviation, "RN"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/ro.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.RO do
field :area_name, "Rondônia"
field :area_type, "state"
field :area_abbreviation, "RO"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/rr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.RR do
field :area_name, "Roraima"
field :area_type, "state"
field :area_abbreviation, "RR"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/rs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.RS do
field :area_name, "Rio Grande do Sul"
field :area_type, "state"
field :area_abbreviation, "RS"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/sc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.SC do
field :area_name, "Santa Catarina"
field :area_type, "state"
field :area_abbreviation, "SC"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/se.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.SE do
field :area_name, "Sergipe"
field :area_type, "state"
field :area_abbreviation, "SE"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/sp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.SP do
field :area_name, "São Paulo"
field :area_type, "state"
field :area_abbreviation, "SP"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/br/to.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.BR.TO do
field :area_name, "Tocantins"
field :area_type, "state"
field :area_abbreviation, "TO"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/ab.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.AB do
field :area_name, "Alberta"
field :area_type, "province"
field :area_abbreviation, "AB"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/bc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.BC do
field :area_name, "British Columbia"
field :area_type, "province"
field :area_abbreviation, "BC"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/mb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.MB do
field :area_name, "Manitoba"
field :area_type, "province"
field :area_abbreviation, "MB"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/nb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.NB do
field :area_name, "New Brunswick"
field :area_type, "province"
field :area_abbreviation, "NB"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/nl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.NL do
field :area_name, "Newfoundland and Labrador"
field :area_type, "province"
field :area_abbreviation, "NL"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/ns_pe.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.NS_PE do
field :area_name, ["Nova Scotia","Prince Edward Island"]
field :area_type, "provinces"
field :area_abbreviation, ["NS","PE"]
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/on.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.ON do
field :area_name, "Ontario"
field :area_type, "province"
field :area_abbreviation, "ON"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/qc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.QC do
field :area_name, "Quebec"
field :area_type, "province"
field :area_abbreviation, "QC"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/sk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.SK do
field :area_name, "Saskatchewan"
field :area_type, "province"
field :area_abbreviation, "SK"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/ca/territory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.CA.Territory do
field :area_name, ["Northwest Territories", "Nunavut", "Yukon"]
field :area_type, "territories"
field :area_abbreviation, ["NT","NU","YT"]
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/us/ak.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.US.AK do
field :area_name, "Alaska"
field :area_type, "state"
field :area_abbreviation, "AK"
builder
builder()
end
2 changes: 1 addition & 1 deletion lib/phone/nanp/us/al.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ defmodule Phone.NANP.US.AL do
field :area_name, "Alabama"
field :area_type, "state"
field :area_abbreviation, "AL"
builder
builder()
end
Loading

0 comments on commit f40c47b

Please sign in to comment.