Skip to content
Browse files

+ added Haiti & Iran

  • Loading branch information...
1 parent 1e2134a commit 1fe6d73a920a59babaa6f3b4b1cb352d9886b7a6 @jcfischer jcfischer committed with Dec 5, 2012
Showing with 22 additions and 3 deletions.
  1. +1 −1 README.textile
  2. +9 −2 lib/phony/countries.rb
  3. +12 −0 spec/lib/phony/countries_spec.rb
View
2 README.textile
@@ -13,7 +13,7 @@ This gem can normalize, format and split E164 numbers.
The (admittedly crazy) *goal* of this Gem is to be able to format/split all phone numbers in the world.
-Currently handles Abhas, Afghan, Algerian, Austrian, Australian, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, Estonian, French, German, Ghanan, Gibraltar, Greek, Hong Kong, Hungarian, Italian, Irish, Kazakh, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, and Vietnamese numbers.
+Currently handles Abhas, Afghan, Algerian, Austrian, Australian, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Italian, Iran, Irish, Kazakh, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, and Vietnamese numbers.
And to some extent, all others. Just try if it works for you.
View
11 lib/phony/countries.rb
@@ -260,7 +260,11 @@
country '94', fixed(2) >> split(3,2,2) # TODO Sri Lanka (Democratic Socialist Republic of)
country '95', fixed(2) >> split(3,2,2) # TODO Myanmar (Union of)
- country '98', fixed(2) >> split(3,2,2) # TODO Iran (Islamic Republic of)
+
+ country '98', # Iran (Islamic Republic of)
+ one_of('21') >> split(4,4) | # Teheran
+ fixed(3) >> split(3,4),
+ validate_lengths(10)
country '210', todo # -
country '211', todo # South Sudan
@@ -534,7 +538,10 @@
country '506', todo # Costa Rica
country '507', todo # Panama (Republic of)
country '508', todo # Saint Pierre and Miquelon (Collectivité territoriale de la République française)
- country '509', todo # Haiti (Republic of)
+
+ country '509', # Haiti (Republic of)
+ fixed(2) >> split(2,4),
+ validate_lengths(8)
country '590', todo # Guadeloupe (French Department of)
country '591', todo # Bolivia (Republic of)
View
12 spec/lib/phony/countries_spec.rb
@@ -96,6 +96,7 @@ def self.it_splits number, expected
it_splits '37281231234', ['372', '8123', '1234'] # Mobile
it_splits '37282231234', ['372', '8223', '1234'] # Mobile
it_splits '37283212345', ['372', '832', '12345'] # Mobile
+ it_splits '37270121234', ['372', '7012', '1234'] # Premium
end
describe 'Finland' do
it_splits '3589123123', ['358', '9', '123', '123'] # Helsinki
@@ -138,6 +139,11 @@ def self.it_splits number, expected
it_splits '3025941234', ['30', '2594', '1234']
it_splits '3022631234', ['30', '2263', '1234']
end
+
+ describe 'Haiti' do
+ it_splits '50922121234', ['509', '22', '12', '1234']
+ end
+
describe 'Hong Kong' do
it_splits '85212341234', ['852', false, '1234', '1234'] #
end
@@ -157,6 +163,12 @@ def self.it_splits number, expected
it_splits '6285220119289', ['62', '852', '20119289']
it_splits '62217815263', ['62', '21', '7815263']
end
+
+ describe 'Iran' do
+ it_splits '982112341234', ['98', '21', '1234', '1234'] # Teheran
+ it_splits '989191231234', ['98', '919', '123', '1234'] # Example Cell Phone
+ end
+
describe 'Ireland' do
it_splits '35311234567', ['353', '1', '123', '4567'] # Dublin, 7 digit subscriber #
it_splits '3532212345', ['353', '22', '12345'] # Mallow, 5 digit subscriber #

0 comments on commit 1fe6d73

Please sign in to comment.
Something went wrong with that request. Please try again.