From b0e4d47b838e613cc4856e7ce5abe9076adce837 Mon Sep 17 00:00:00 2001 From: Filip Tepper Date: Thu, 17 May 2012 11:40:31 +0200 Subject: [PATCH 1/2] auto whitespace cleanup --- lib/phony/countries.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/phony/countries.rb b/lib/phony/countries.rb index 8a674a86..8c7cee89 100644 --- a/lib/phony/countries.rb +++ b/lib/phony/countries.rb @@ -186,7 +186,7 @@ country '61', match(/^(4\d\d)\d+$/) >> split(3,3) | # Mobile fixed(1) >> split(4,4) # Rest - + country '62', todo # TODO Indonesia (Republic of) country '63', todo # TODO Philippines (Republic of the) @@ -216,7 +216,7 @@ one_of('4', '8') >> split(7) | match(/^(2[025679]|3[0136789]|5[23456789]|6[01234678]|7[02345679]|9[0-8])\d/) >> split(6) | fixed(3) >> split(5) - + # country '86' # China, see special file. @@ -293,7 +293,7 @@ country '252', todo # Somali Democratic Republic country '253', todo # Djibouti country '254', fixed(2) >> split(7) # Kenya - + # Tanzania. # country '255', @@ -306,7 +306,7 @@ country '256', match(/^(46[45]|4[78]\d)/) >> split(6) | # Geo 1. fixed(2) >> split(7) # Geo 2. - + country '257', todo # Burundi country '258', todo # Mozambique country '259', todo # - @@ -370,7 +370,7 @@ match(/^(4\d|50)\d+$/) >> split(3,2,2) | # Mobile one_of('2','3','5','6','8','9') >> split(3,3) | # Short NDCs fixed(2) >> split(3,3) # 2-digit NDCs - + # Bulgaria. # country '359', From 8adac26dfe055f9a5602edebff07adb2e7a09db3 Mon Sep 17 00:00:00 2001 From: Filip Tepper Date: Thu, 17 May 2012 11:40:50 +0200 Subject: [PATCH 2/2] improved support for Polish phone numbers --- lib/phony/countries.rb | 3 ++- spec/lib/phony/countries_spec.rb | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/phony/countries.rb b/lib/phony/countries.rb index 8c7cee89..6b9e5d61 100644 --- a/lib/phony/countries.rb +++ b/lib/phony/countries.rb @@ -121,7 +121,8 @@ # Note: http://wapedia.mobi/en/Telephone_numbers_in_Poland, mobile not yet correct # country '48', - fixed(3) >> split(3,3) # Poland + match(/^(5[013]\d|6[069]\d|7[02389]\d|80[01]|88\d)/) >> split(3,3) | + fixed(2) >> split(3,2,2) # country '49' # Germany, see special file. diff --git a/spec/lib/phony/countries_spec.rb b/spec/lib/phony/countries_spec.rb index 83a8af3b..8cdb2373 100644 --- a/spec/lib/phony/countries_spec.rb +++ b/spec/lib/phony/countries_spec.rb @@ -164,7 +164,11 @@ Phony.split('51841234123').should == ['51', '84', '1234', '123'] # Cuzco, best effort end it 'handles polish numbers' do - Phony.split('48123123123').should == ['48', '123', '123', '123'] + Phony.split('48123456789').should == ['48', '12', '345', '67', '89'] # Landline + Phony.split('48501123456').should == ['48', '501', '123', '456'] # Mobile + Phony.split('48800123456').should == ['48', '800', '123', '456'] # Free + Phony.split('48801123456').should == ['48', '801', '123', '456'] # Shared cost + Phony.split('48701123456').should == ['48', '701', '123', '456'] # Premium end it 'handles portuguese numbers' do Phony.split('351211231234').should == ['351', '21', '123', '1234'] # Lisboa