diff --git a/lib/phony/countries.rb b/lib/phony/countries.rb index ecd0a102..7cf4b4eb 100644 --- a/lib/phony/countries.rb +++ b/lib/phony/countries.rb @@ -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. diff --git a/spec/lib/phony/countries_spec.rb b/spec/lib/phony/countries_spec.rb index e8c1082b..5cda21ad 100644 --- a/spec/lib/phony/countries_spec.rb +++ b/spec/lib/phony/countries_spec.rb @@ -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 diff --git a/spec/lib/phony/country_codes_spec.rb b/spec/lib/phony/country_codes_spec.rb index 682bb1b6..e74a2c0f 100644 --- a/spec/lib/phony/country_codes_spec.rb +++ b/spec/lib/phony/country_codes_spec.rb @@ -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'