Adds support for India, Canada and much more #22

Closed
wants to merge 94 commits into
from
@wmoxam

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.

@danhealy

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.

@adammeghji

+1 for merging this.

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

grempe-thrillcall and others added some commits Apr 3, 2012
@grempe-thrillcall 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
@feldpost 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
@wmoxam wmoxam Adds Aregentina, Costa Rica, Ethiopia and Tonga 53d7102
@wmoxam wmoxam Adds Zimbabwe aa2ca12
@wmoxam wmoxam Adds Israel fa7a0b0
@wmoxam wmoxam Adds Afganistan 0d88aaf
@wmoxam wmoxam Adds Albania c057621
@wmoxam wmoxam Adds Algeria 63bdb33
@wmoxam wmoxam Adds Austria 65f0edd
@wmoxam wmoxam Adds Austria, Bulgaria, Brazil and Belize 1732467
@wmoxam wmoxam Fixes carr#24
Includes test authored by activefx from here: activefx@e62349b
7bad062
@wmoxam wmoxam Forgot to add these tests 6f02b0d
@kristianmandrup kristianmandrup added norway and improved DK 21afe53
@wmoxam wmoxam Adds tests for Denmark and Norway. Fixes loading problem for Norway c9e2260
@wmoxam wmoxam Adds Czech Republic & Cyprus fad2f5b
@wmoxam wmoxam Adds Ecuador, Estonia, Finland & El Salvador 8f03e0a
@wmoxam wmoxam Adds Belarus + forgotten tests 5b41517
@espen 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
@wmoxam wmoxam More comprehensive parsing test c5891cc
@wmoxam wmoxam Adds Georgia, Greece, Guam and Guatemala 0af7d07
@wmoxam wmoxam Whoops, screwed up checking in tests :p fd7bf54
@kwilcox 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 Aug 28, 2012
Wesley Moxam Merge pull request #7 from g1smd/master
Restore US RegEx and remove the "375" that was in its place.
bd9898f
@wmoxam wmoxam Don't raise parse exceptions on .valid? 943ed51
@wmoxam wmoxam Fixes parsing problems when there is a default country set 698800d
@wmoxam wmoxam Fixes Egyptian number parsing e79a584
@wmoxam wmoxam Stop the "no tests were specified" nonsense 81714db
@wmoxam wmoxam whoops, these aren't needed 17b9463
@wmoxam wmoxam Rename to 'Phonie' to avoid name clash with original gem. This will n…
…ever be merged in :/
9c46fb7
@wmoxam wmoxam Merge branch 'master' of github.com:wmoxam/phonie 8421cef
@wmoxam wmoxam More renaming e97661c
@wmoxam wmoxam Adds Latvia 47327de
@wmoxam wmoxam ignore vim swap files d8a5abd
@wmoxam wmoxam Adds Lithuania 7e6599e
@wmoxam wmoxam Adds support for Russia 685aa4e
@wmoxam wmoxam removes tmp file 837b0cd
@wmoxam wmoxam Adds Luxembourg 7742ecf
@sagmor sagmor Move development dependencies to gemspec 4b6fc15
@sagmor sagmor Add Chilean number support 4640460
@sagmor sagmor Add phone active model validations 93fc90e
@sagmor sagmor Don't loose extension on number formating e099147
@sagmor sagmor Add phone validation locales 66e1c88
@wmoxam wmoxam Fixes mobile parsing regex, leading zero shouldn't exist 2b1e0a6
@wmoxam wmoxam Adds Italian number support fa5b11e
@wmoxam wmoxam Updates countries list 493e1be
@wmoxam wmoxam Merge branch 'master' of https://github.com/sagmor/phonie
Conflicts:
	lib/phonie/data/phone_countries.yml
aeb3ca3
@wmoxam wmoxam minor refactor 810243d
@wmoxam wmoxam Adds a tool to quickly add new countries 3867ea7
@wmoxam wmoxam Adds Armenia dc9c653
@wmoxam wmoxam Adds Azerbaijanwq c315c48
@wmoxam wmoxam Adds Bahamas 4de77c7
@wmoxam wmoxam Adds Bahrain d704047
@wmoxam wmoxam Bump version for release fb91316
@wmoxam wmoxam Ignore undo files c964050
@wmoxam wmoxam Adds Ireland d5aaaf3
@wmoxam wmoxam Makes generator tool more robust baaa48f
@wmoxam wmoxam Adds New Zealand ce1f288
Wesley Moxam Adds support for Spain baed741
Wesley Moxam Prepare for release f566721
@wmoxam wmoxam closed this Mar 3, 2013
@tiegz

throwback to 2013! Curious if this newline was intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment