Skip to content

Commit

Permalink
Merge pull request #41 from filiptepper/master
Browse files Browse the repository at this point in the history
Support for Polish numbers (Thanks @filiptepper!)
  • Loading branch information
floere committed May 17, 2012
2 parents 1005dc8 + 8adac26 commit f105b35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/phony/countries.rb
Expand Up @@ -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.

Expand Down Expand Up @@ -186,7 +187,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)

Expand Down Expand Up @@ -216,7 +217,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.

Expand Down Expand Up @@ -293,7 +294,7 @@
country '252', todo # Somali Democratic Republic
country '253', todo # Djibouti
country '254', fixed(2) >> split(7) # Kenya

# Tanzania.
#
country '255',
Expand All @@ -306,7 +307,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 # -
Expand Down Expand Up @@ -370,7 +371,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',
Expand Down
6 changes: 5 additions & 1 deletion spec/lib/phony/countries_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit f105b35

Please sign in to comment.