Skip to content
This repository

Adds support for India, Canada and much more #22

Closed
wants to merge 94 commits into from

11 participants

Wesley Moxam Dan Healy thrillcall Adam Meghji g1smd Glenn Rempe Sebastian Friedrich Kristian Mandrup Espen Antonsen Kyle Wilcox Seba Gamboa
Wesley Moxam

Area code formats now specified so that countries that share a country code can be supported, and invalid area codes (ex: 555 in North America) are recognized as invalid

Local number formats also specified. Allows for better country detection if the country differs from the default country code.

Parsing largely rewritten to better identify countries on parse.

Tests now clear global data between tests (default_country_code & default_area_code were being persisted).

German numbers are now parsed correctly.

Dan Healy

There is already a 1.1 version, it's here: https://rubygems.org/gems/phone but not on GitHub. We are having our own issue with the gem as well.. I am hoping this is still maintained?

thrillcall

+1 for merging this.

Our testing shows that this new version handles US numbers better than the upstream. e.g. 18005551212 != +118005551212, #parse("").to_s doesn't return "" but nil. Several other tests behaving and parsing as expected.

Adam Meghji

+1 for merging this.

Would love to have the Canada country code supported here as well.

grempe-thrillcall and others added some commits
Glenn Rempe grempe-thrillcall Add support for additional toll-free numbers in the US.
822|833|844|855|866|877|880|881|882|883|884|885|886|887|888|889|

Area codes 800 since 1967, 888 (since 1996), 877 (since 1998), 866
(since 2000) and 855 (since 2010). Area codes reserved for future
expansion include 844, 833, 822, 880 through 887, and 889.

See : http://en.wikipedia.org/wiki/Toll-free_telephone_number#North_America
a87bb79
Wesley Moxam Merge pull request #1 from thrillcall/800_numbers
Add support for additional toll-free numbers in the US.
b3cdad8
Sebastian Friedrich feldpost Support for non-geographic area codes
456: International inbound
500: Follow me numbers
533: Personal Communications Services
544	Personal Communications Services
566	Personal Communications Services
700	Carrier-specific services (generally not toll-free)
710	U.S. Federal Government (authorized users only)
45deda8
Wesley Moxam Merge pull request #2 from feldpost/master
Support for non-geographic area codes
9b9f60c
Wesley Moxam wmoxam Adds Aregentina, Costa Rica, Ethiopia and Tonga 53d7102
Wesley Moxam wmoxam Adds Zimbabwe aa2ca12
Wesley Moxam wmoxam Adds Israel fa7a0b0
Wesley Moxam wmoxam Adds Afganistan 0d88aaf
Wesley Moxam wmoxam Adds Albania c057621
Wesley Moxam wmoxam Adds Algeria 63bdb33
Wesley Moxam wmoxam Adds Austria 65f0edd
Wesley Moxam wmoxam Adds Austria, Bulgaria, Brazil and Belize 1732467
Wesley Moxam wmoxam Fixes carr#24
Includes test authored by activefx from here: activefx@e62349b
7bad062
Wesley Moxam wmoxam Forgot to add these tests 6f02b0d
Kristian Mandrup kristianmandrup added norway and improved DK 21afe53
Wesley Moxam wmoxam Adds tests for Denmark and Norway. Fixes loading problem for Norway c9e2260
Wesley Moxam wmoxam Adds Czech Republic & Cyprus fad2f5b
Wesley Moxam wmoxam Adds Ecuador, Estonia, Finland & El Salvador 8f03e0a
Wesley Moxam wmoxam Adds Belarus + forgotten tests 5b41517
Espen Antonsen espen char_3_code should be string. Gave nil for Norway, should be "NO".
test for Norwegian mobile nr, specyfing country_code in parser but no code in input value
763064b
Wesley Moxam wmoxam More comprehensive parsing test c5891cc
Wesley Moxam wmoxam Adds Georgia, Greece, Guam and Guatemala 0af7d07
Wesley Moxam wmoxam Whoops, screwed up checking in tests :p fd7bf54
Kyle Wilcox kwilcox Adds UAE (United Arab Emirates) 36b3b04
Wesley Moxam Merge pull request #5 from kwilcox/master
Adds UAE support
293738b
g1smd g1smd Additional tests for GB number ranges.
Additional GB number ranges and formats not previously tested. Introduces numbers in 4+5, 5+5, 5+4 and 3+6 format.

Corrects that 873 is not freefone.
59119cf
g1smd g1smd Fix RegEx errors such as unnecessary pipes and commas. Optimise RegEx…
… pattern character groups.

|456[7]?|  simplifies to  |4567?|
A character group is not needed for a single character.

[1-7,8-9]  simplifies to  [1-78-9]   then to  [1-9]
The comma should not be used in a character group unless you want to match a literal comma.
f05a4c0
g1smd g1smd Fix GB area code RegEx pattern to include additional number types and…
… better restrict matches to valid ranges.
a11ac28
g1smd g1smd Fixes to various RegEx patterns. 10a73e8
g1smd g1smd Optimise RegEx patterns. 31e9a30
g1smd g1smd When the international_dialing_prefix data was first imported, it app…
…ears to have been done as "integer" instead of "string" as all leading-zero data is missing from every item. Fixing entries that should be "00", and others.
9801dbd
g1smd g1smd When international_dialing_prefix data was first imported (it looks l…
…ike from perhaps the wikipedia page listing these codes), many countries are detailed with very old data not the current situation.
1dde98c
g1smd g1smd Optimise RegEx patterns. 85a4e3b
g1smd g1smd Fix typo. 8844eb6
Wesley Moxam Merge pull request #6 from g1smd/master
Fix GB and other data. Additional GB tests. Fix international_dialing_prefix data. Fix RegEx patterns.
205d2ce
g1smd

12 five-digit area codes, 500, 55, 56 were missing. The 3xx, 7xxx, 8xx, 9xx patterns were overly broad.

g1smd

This "375:" line is an error and should be replaced with the US RegEx pattern.

g1smd

Accidental change: "1" should be "1a" as before.

g1smd

The extra "+375" is also a typo, and the two lines after it are duplicates of two of the lines you just added.

What happened originally is that the US RegEx was accidentally replaced by "375".

You have fixed by adding three lines in, so now there are three redundant lines.

Update coming in a few moments...

The US RegEx wasn't "removed". It was replaced by "375" in quotes, by accident.

Issue #7 reverses that as well as removing the unwanted duplicated lines added in 279ba74.

g1smd

The US RegEx should be here in place of the "375" after the international_dialing_prefix line.

g1smd

The above three lines have been added in error and are in the wrong place.

Two of the lines incorrectly duplicate data that was already correct and in the right place.

Wesley Moxam and others added some commits
Wesley Moxam Merge pull request #7 from g1smd/master
Restore US RegEx and remove the "375" that was in its place.
bd9898f
Wesley Moxam wmoxam Don't raise parse exceptions on .valid? 943ed51
Wesley Moxam wmoxam Fixes parsing problems when there is a default country set 698800d
Wesley Moxam wmoxam Fixes Egyptian number parsing e79a584
Wesley Moxam wmoxam Stop the "no tests were specified" nonsense 81714db
Wesley Moxam wmoxam whoops, these aren't needed 17b9463
Wesley Moxam wmoxam Rename to 'Phonie' to avoid name clash with original gem. This will n…
…ever be merged in :/
9c46fb7
Wesley Moxam wmoxam Merge branch 'master' of github.com:wmoxam/phonie 8421cef
Wesley Moxam wmoxam More renaming e97661c
Wesley Moxam wmoxam Adds Latvia 47327de
Wesley Moxam wmoxam ignore vim swap files d8a5abd
Wesley Moxam wmoxam Adds Lithuania 7e6599e
Wesley Moxam wmoxam Adds support for Russia 685aa4e
Wesley Moxam wmoxam removes tmp file 837b0cd
Wesley Moxam wmoxam Adds Luxembourg 7742ecf
Seba Gamboa sagmor Move development dependencies to gemspec 4b6fc15
Seba Gamboa sagmor Add Chilean number support 4640460
Seba Gamboa sagmor Add phone active model validations 93fc90e
Seba Gamboa sagmor Don't loose extension on number formating e099147
Seba Gamboa sagmor Add phone validation locales 66e1c88
Wesley Moxam wmoxam Fixes mobile parsing regex, leading zero shouldn't exist 2b1e0a6
Wesley Moxam wmoxam Adds Italian number support fa5b11e
Wesley Moxam wmoxam Updates countries list 493e1be
Wesley Moxam wmoxam Merge branch 'master' of https://github.com/sagmor/phonie
Conflicts:
	lib/phonie/data/phone_countries.yml
aeb3ca3
Wesley Moxam wmoxam minor refactor 810243d
Wesley Moxam wmoxam Adds a tool to quickly add new countries 3867ea7
Wesley Moxam wmoxam Adds Armenia dc9c653
Wesley Moxam wmoxam Adds Azerbaijanwq c315c48
Wesley Moxam wmoxam Adds Bahamas 4de77c7
Wesley Moxam wmoxam Adds Bahrain d704047
Wesley Moxam wmoxam Bump version for release fb91316
Wesley Moxam wmoxam Ignore undo files c964050
Wesley Moxam wmoxam Adds Ireland d5aaaf3
Wesley Moxam wmoxam Makes generator tool more robust baaa48f
Wesley Moxam wmoxam Adds New Zealand ce1f288
Wesley Moxam Adds support for Spain baed741
Wesley Moxam Prepare for release f566721
Wesley Moxam wmoxam closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 94 unique commits by 11 authors.

Feb 26, 2012
Wesley Moxam wmoxam Added support for Indian numbers. Large refactoring too. Fixed test s…
…uite so that setting such as default area code is wiped between tests. Better country detection.
ebe4c87
Wesley Moxam wmoxam Refactors country matching, perpare for support of countries that sha…
…re a country code
c10f9ac
Wesley Moxam wmoxam Adds support for Canadian phone numbers e3e782e
Feb 27, 2012
Wesley Moxam wmoxam Fixes German phone parsing fbced98
Wesley Moxam wmoxam Updates docs 25e8d8f
Wesley Moxam wmoxam Updates gemspec 6404b37
Wesley Moxam wmoxam Adds self.find_by_name to Country e4895b4
Wesley Moxam wmoxam Adds support for Guyana b4a1c0b
Wesley Moxam wmoxam Adds formats for Bangladesh, Bhutan, Egypt, Ghana, Iran, Kenya, Sri L…
…anka, Nigeria, Nepal, Phillipines, Pakistan and Saudi Arabia
9d70470
Feb 28, 2012
Wesley Moxam wmoxam Adds find_by_country_code, renames find_all_by_country_code, fixes fi…
…nd_by_name
0ead92f
Wesley Moxam wmoxam Handle nils correctly a43ecf5
Wesley Moxam wmoxam .valid? accepts the same options as .parse b7fabe1
Mar 01, 2012
Wesley Moxam wmoxam Don't raise exceptions for parse errors by default 5305bfa
Wesley Moxam wmoxam .parse no long throws exceptions 9d9f14e
Wesley Moxam wmoxam Adds .is_mobile?
Can tell if a number is possibly mobile in some areas, absolutely in others.
d953ba2
Mar 16, 2012
Wesley Moxam wmoxam Adds Qatar 78f3af0
Mar 19, 2012
Wesley Moxam wmoxam Adds number format checks to correctly check the length of numbers. T…
…ODO: need to enter formats for all of the countries
df681fb
Wesley Moxam wmoxam Whoops, bad default for number format check :p 8569d82
Wesley Moxam wmoxam Adds number length constraint for all supported countries. eb923fc
Apr 03, 2012
Glenn Rempe grempe-thrillcall Add support for additional toll-free numbers in the US.
822|833|844|855|866|877|880|881|882|883|884|885|886|887|888|889|

Area codes 800 since 1967, 888 (since 1996), 877 (since 1998), 866
(since 2000) and 855 (since 2010). Area codes reserved for future
expansion include 844, 833, 822, 880 through 887, and 889.

See : http://en.wikipedia.org/wiki/Toll-free_telephone_number#North_America
a87bb79
Apr 04, 2012
Wesley Moxam Merge pull request #1 from thrillcall/800_numbers
Add support for additional toll-free numbers in the US.
b3cdad8
Apr 14, 2012
Sebastian Friedrich feldpost Support for non-geographic area codes
456: International inbound
500: Follow me numbers
533: Personal Communications Services
544	Personal Communications Services
566	Personal Communications Services
700	Carrier-specific services (generally not toll-free)
710	U.S. Federal Government (authorized users only)
45deda8
Apr 15, 2012
Wesley Moxam Merge pull request #2 from feldpost/master
Support for non-geographic area codes
9b9f60c
Wesley Moxam wmoxam Adds Aregentina, Costa Rica, Ethiopia and Tonga 53d7102
May 07, 2012
Wesley Moxam wmoxam Adds Zimbabwe aa2ca12
May 08, 2012
Wesley Moxam wmoxam Adds Israel fa7a0b0
May 11, 2012
Wesley Moxam wmoxam Adds Afganistan 0d88aaf
Wesley Moxam wmoxam Adds Albania c057621
Wesley Moxam wmoxam Adds Algeria 63bdb33
Wesley Moxam wmoxam Adds Austria 65f0edd
May 28, 2012
Wesley Moxam wmoxam Adds Austria, Bulgaria, Brazil and Belize 1732467
Wesley Moxam wmoxam Fixes carr#24
Includes test authored by activefx from here: activefx@e62349b
7bad062
Wesley Moxam wmoxam Forgot to add these tests 6f02b0d
Jun 04, 2012
Kristian Mandrup kristianmandrup added norway and improved DK 21afe53
Wesley Moxam wmoxam Adds tests for Denmark and Norway. Fixes loading problem for Norway c9e2260
Jun 10, 2012
Wesley Moxam wmoxam Adds Czech Republic & Cyprus fad2f5b
Jun 11, 2012
Wesley Moxam wmoxam Adds Ecuador, Estonia, Finland & El Salvador 8f03e0a
Wesley Moxam wmoxam Adds Belarus + forgotten tests 5b41517
Jun 29, 2012
Espen Antonsen espen char_3_code should be string. Gave nil for Norway, should be "NO".
test for Norwegian mobile nr, specyfing country_code in parser but no code in input value
763064b
Jun 30, 2012
Wesley Moxam wmoxam More comprehensive parsing test c5891cc
Wesley Moxam wmoxam Adds Georgia, Greece, Guam and Guatemala 0af7d07
Wesley Moxam wmoxam Whoops, screwed up checking in tests :p fd7bf54
Jul 30, 2012
Kyle Wilcox kwilcox Adds UAE (United Arab Emirates) 36b3b04
Wesley Moxam Merge pull request #5 from kwilcox/master
Adds UAE support
293738b
Aug 27, 2012
g1smd g1smd Additional tests for GB number ranges.
Additional GB number ranges and formats not previously tested. Introduces numbers in 4+5, 5+5, 5+4 and 3+6 format.

Corrects that 873 is not freefone.
59119cf
g1smd g1smd Fix RegEx errors such as unnecessary pipes and commas. Optimise RegEx…
… pattern character groups.

|456[7]?|  simplifies to  |4567?|
A character group is not needed for a single character.

[1-7,8-9]  simplifies to  [1-78-9]   then to  [1-9]
The comma should not be used in a character group unless you want to match a literal comma.
f05a4c0
g1smd g1smd Fix GB area code RegEx pattern to include additional number types and…
… better restrict matches to valid ranges.
a11ac28
g1smd g1smd Fixes to various RegEx patterns. 10a73e8
g1smd g1smd Optimise RegEx patterns. 31e9a30
g1smd g1smd When the international_dialing_prefix data was first imported, it app…
…ears to have been done as "integer" instead of "string" as all leading-zero data is missing from every item. Fixing entries that should be "00", and others.
9801dbd
g1smd g1smd When international_dialing_prefix data was first imported (it looks l…
…ike from perhaps the wikipedia page listing these codes), many countries are detailed with very old data not the current situation.
1dde98c
g1smd g1smd Optimise RegEx patterns. 85a4e3b
g1smd g1smd Fix typo. 8844eb6
Aug 28, 2012
Wesley Moxam Merge pull request #6 from g1smd/master
Fix GB and other data. Additional GB tests. Fix international_dialing_prefix data. Fix RegEx patterns.
205d2ce
Wesley Moxam wmoxam Regexp optimizations exposed parsing bug. USA Area code regex was mis…
…takenly removed.
279ba74
g1smd g1smd Restore US RegEx and delete "375" that was in its place. b7c5e29
g1smd g1smd Optimise several RegEx patterns. Fix several international_dialing_pr…
…efix items.
a1aea95
Wesley Moxam Merge pull request #7 from g1smd/master
Restore US RegEx and remove the "375" that was in its place.
bd9898f
Sep 24, 2012
Wesley Moxam wmoxam Don't raise parse exceptions on .valid? 943ed51
Wesley Moxam wmoxam Fixes parsing problems when there is a default country set 698800d
Nov 09, 2012
Wesley Moxam wmoxam Fixes Egyptian number parsing e79a584
Wesley Moxam wmoxam Stop the "no tests were specified" nonsense 81714db
Wesley Moxam wmoxam whoops, these aren't needed 17b9463
Dec 31, 2012
Wesley Moxam wmoxam Rename to 'Phonie' to avoid name clash with original gem. This will n…
…ever be merged in :/
9c46fb7
Wesley Moxam wmoxam Merge branch 'master' of github.com:wmoxam/phonie 8421cef
Wesley Moxam wmoxam More renaming e97661c
Jan 01, 2013
Wesley Moxam wmoxam Adds Latvia 47327de
Wesley Moxam wmoxam ignore vim swap files d8a5abd
Wesley Moxam wmoxam Adds Lithuania 7e6599e
Wesley Moxam wmoxam Adds support for Russia 685aa4e
Jan 08, 2013
Wesley Moxam wmoxam removes tmp file 837b0cd
Wesley Moxam wmoxam Adds Luxembourg 7742ecf
Jan 10, 2013
Seba Gamboa sagmor Move development dependencies to gemspec 4b6fc15
Seba Gamboa sagmor Add Chilean number support 4640460
Seba Gamboa sagmor Add phone active model validations 93fc90e
Seba Gamboa sagmor Don't loose extension on number formating e099147
Seba Gamboa sagmor Add phone validation locales 66e1c88
Jan 18, 2013
Wesley Moxam wmoxam Fixes mobile parsing regex, leading zero shouldn't exist 2b1e0a6
Wesley Moxam wmoxam Adds Italian number support fa5b11e
Wesley Moxam wmoxam Updates countries list 493e1be
Wesley Moxam wmoxam Merge branch 'master' of https://github.com/sagmor/phonie
Conflicts:
	lib/phonie/data/phone_countries.yml
aeb3ca3
Jan 23, 2013
Wesley Moxam wmoxam minor refactor 810243d
Wesley Moxam wmoxam Adds a tool to quickly add new countries 3867ea7
Wesley Moxam wmoxam Adds Armenia dc9c653
Jan 29, 2013
Wesley Moxam wmoxam Adds Azerbaijanwq c315c48
Wesley Moxam wmoxam Adds Bahamas 4de77c7
Wesley Moxam wmoxam Adds Bahrain d704047
Wesley Moxam wmoxam Bump version for release fb91316
Feb 17, 2013
Wesley Moxam wmoxam Ignore undo files c964050
Wesley Moxam wmoxam Adds Ireland d5aaaf3
Feb 18, 2013
Wesley Moxam wmoxam Makes generator tool more robust baaa48f
Wesley Moxam wmoxam Adds New Zealand ce1f288
Feb 26, 2013
Wesley Moxam Adds support for Spain baed741
Wesley Moxam Prepare for release f566721
Something went wrong with that request. Please try again.