Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Luxembourg phone numbers #311

Merged
merged 3 commits into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/phony/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,16 @@
# Luxembourg
#
country '352',
one_of('4') >> split(2,2,2) | # Luxembourg City
match(/^(2[467]\d{2})$/) >> split(2,2,2) | # 4-digit NDC
match(/^(6\d[18])\d+$/) >> split(3,3) | # mobile
match(/^(60\d{2})\d{8}$/) >> split(2,2,2,2) | # mobile machine to machine
match(/^([2-9]\d)/) >> split(2,2,2) # 2-digit NDC
match(/^(2[467]\d{2})\d{4}$/) >> split(2,2) | # 4-digit NDC
match(/^(6\d[18])\d+$/) >> split(3,3) | # mobile
match(/^(60\d{2})\d{8}$/) >> split(2,2,2,2) | # mobile machine to machine
match(/^((2[^467]|[3-9]\d))\d{4}$/) >> split(2,2) | # 2-digit NDC Regular 6 digits number
match(/^((2[^467]|[3-9]\d))\d{4}$/) >> split(2,2) | # 2-digit NDC Regular 6 digits number
match(/^((2[^467]|[3-9]\d))\d{5}$/) >> split(2,2,1) | # 2-digit NDC Regular 6 digits number w/ 1 digit extension
match(/^((2[^467]|[3-9]\d))\d{6}$/) >> split(2,2,2) | # 2-digit NDC Regular 8 digits number or 6 digits with 2 digits extension
match(/^((2[^467]|[3-9]\d))\d{7}$/) >> split(2,2,3) | # 2-digit NDC Regular 6 digits with 4 digits extension
match(/^((2[^467]|[3-9]\d))\d{8}$/) >> split(2,2,4) | # 2-digit NDC Regular 6 digits number with 4 digits extension
match(/^(\d{2})\d{3}$/) >> split(2,2,1) # fallback for 5 digit number

# country '353' # Republic of Ireland, see special file.

Expand Down
8 changes: 6 additions & 2 deletions spec/lib/phony/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,16 @@ def self.it_splits number, expected
end
describe 'Luxembourg' do
it_splits '352222809', ['352', '22', '28', '09']
it_splits '35226222809', ['352', '26', '22', '28', '09']
it_splits '35226222809', ['352', '2622', '28', '09']
it_splits '352621123456', ['352', '621', '123', '456']
it_splits '3524123456', ['352', '4', '12', '34', '56']
it_splits '3524123456', ['352', '41', '23', '45', '6']
it_splits '352602112345678', ['352', '6021', '12', '34', '56', '78']
it_splits '352370431', ['352', '37', '04', '31']
it_splits '35227855', ['352', '27', '85', '5']
it_splits '352445566', ['352', '44', '55', '66']
it_splits '352545258', ['352', '54', '52', '58']
it_splits '352818181', ['352', '81', '81', '81']
it_splits '3523572141', ['352', '35', '72', '14', '1']
end
describe 'Macedonia' do
it_splits '38921234567', ['389', '2', '123', '4567'] # Skopje
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/phony/country_codes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
@countries.formatted('352222809', :format => :international).should eql '+352 22 28 09'
end
it "should format luxembourgian 4-digit ndc numbers" do
@countries.formatted('35226222809', :format => :international).should eql '+352 26 22 28 09'
@countries.formatted('35226222809', :format => :international).should eql '+352 2622 28 09'
end
it "should format luxembourgian mobile numbers" do
@countries.formatted('352621123456', :format => :international).should eql '+352 621 123 456'
end
it "should format luxembourgian city numbers" do
@countries.formatted('3524123456', :format => :international).should eql '+352 4 12 34 56'
@countries.formatted('3524123456', :format => :international).should eql '+352 41 23 45 6'
end
it "should format luxembourgian machine to machine numbers" do
@countries.formatted('352602112345678', :format => :international).should eql '+352 6021 12 34 56 78'
Expand Down