Skip to content

Commit

Permalink
+ Updated Argentina, added El Salvador
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfischer authored and floere committed Mar 18, 2013
1 parent 6e63426 commit 6c98e42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/phony/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@
match(/^(22[0137]|237|26[14]|29[179]|34[1235]|35[138]|38[1578])/) >> split(3,4) | # Fixed
match(/^(922[0137]|9237|926[14]|929[179]|934[1235]|935[138]|938[1578])/) >> split(3,4) | # Mobile
match(/^(9\d{4})/) >> split(2,4) | # Mobile
fixed(4) >> split(2,4) # Fixed

match(/^([68]\d{2})/) >> split(3,4) | # Service
fixed(4) >> split(2,4), # Fixed
length(10..11)

# Brazil (Federative Republic of).
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
# country '55' # Brazil, see special file.
Expand Down Expand Up @@ -547,7 +549,9 @@
country '500', todo # Falkland Islands (Malvinas)
country '501', todo # Belize
country '502', todo # Guatemala (Republic of)
country '503', todo # El Salvador (Republic of)
# El Salvador (Republic of)
country '503', fixed(4) >> split(4,4), length(7..8)

country '504', todo # Honduras (Republic of)
country '505', todo # Nicaragua
country '506', todo # Costa Rica
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/phony/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def self.it_splits number, expected
it_splits '5491112345678', ['54', '911', '1234', '5678']
it_splits '5492201234567', ['54', '9220', '123', '4567']
it_splits '5492221123456', ['54', '92221', '12', '3456']
it_splits '548001234567', ['54', '800', '123', '4567']
end
describe 'Austria' do
it_splits '43198110', ['43', '1', '98110'] # Vienna
Expand Down Expand Up @@ -312,6 +313,11 @@ def self.it_splits number, expected
it { Phony.split('21611231234').should == ['216', '1', '123', '1234'] } # Ariana
it { Phony.split('21621231234').should == ['216', '2', '123', '1234'] } # Bizerte
end
describe 'Salvador (El)' do
it { Phony.split('50321121234').should == ['503', '2112', '1234'] } # Fixed number
it { Phony.split('50361121234').should == ['503', '6112', '1234'] } # Mobile number
end

describe 'Singapore' do
it { Phony.split('6561231234').should == ['65', false, '6123', '1234'] } # Fixed line
end
Expand Down

0 comments on commit 6c98e42

Please sign in to comment.