phony 2.16.4 → 2.20.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +5 -5
  2. data/README.textile +34 -6
  3. data/lib/phony/config.rb +91 -0
  4. data/lib/phony/countries/argentina.rb +355 -0
  5. data/lib/phony/countries/austria.rb +4 -2
  6. data/lib/phony/countries/bangladesh.rb +2 -0
  7. data/lib/phony/countries/belarus.rb +2 -0
  8. data/lib/phony/countries/brazil.rb +4 -2
  9. data/lib/phony/countries/cambodia.rb +3 -5
  10. data/lib/phony/countries/china.rb +7 -2
  11. data/lib/phony/countries/croatia.rb +2 -0
  12. data/lib/phony/countries/georgia.rb +2 -0
  13. data/lib/phony/countries/germany.rb +5 -2
  14. data/lib/phony/countries/guinea.rb +8 -5
  15. data/lib/phony/countries/india.rb +2 -0
  16. data/lib/phony/countries/indonesia.rb +2 -0
  17. data/lib/phony/countries/ireland.rb +27 -23
  18. data/lib/phony/countries/italy.rb +40 -18
  19. data/lib/phony/countries/japan.rb +61 -8
  20. data/lib/phony/countries/kyrgyzstan.rb +2 -0
  21. data/lib/phony/countries/latvia.rb +2 -0
  22. data/lib/phony/countries/libya.rb +3 -1
  23. data/lib/phony/countries/malaysia.rb +22 -2
  24. data/lib/phony/countries/moldova.rb +2 -0
  25. data/lib/phony/countries/montenegro.rb +2 -0
  26. data/lib/phony/countries/myanmar.rb +2 -0
  27. data/lib/phony/countries/namibia.rb +2 -0
  28. data/lib/phony/countries/nepal.rb +2 -0
  29. data/lib/phony/countries/netherlands.rb +2 -0
  30. data/lib/phony/countries/pakistan.rb +2 -0
  31. data/lib/phony/countries/paraguay.rb +2 -0
  32. data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +22 -13
  33. data/lib/phony/countries/saudi_arabia.rb +2 -0
  34. data/lib/phony/countries/serbia.rb +7 -1
  35. data/lib/phony/countries/somalia.rb +2 -0
  36. data/lib/phony/countries/south_korea.rb +7 -2
  37. data/lib/phony/countries/sweden.rb +2 -0
  38. data/lib/phony/countries/taiwan.rb +3 -0
  39. data/lib/phony/countries/tajikistan.rb +2 -0
  40. data/lib/phony/countries/turkmenistan.rb +2 -0
  41. data/lib/phony/countries/ukraine.rb +3 -0
  42. data/lib/phony/countries/united_kingdom.rb +5 -2
  43. data/lib/phony/countries/uruguay.rb +2 -0
  44. data/lib/phony/countries/vietnam.rb +93 -93
  45. data/lib/phony/countries/zimbabwe.rb +2 -0
  46. data/lib/phony/countries.rb +142 -64
  47. data/lib/phony/country.rb +15 -3
  48. data/lib/phony/country_codes.rb +16 -3
  49. data/lib/phony/dsl.rb +5 -3
  50. data/lib/phony/local_splitters/fixed.rb +2 -0
  51. data/lib/phony/national_code.rb +1 -1
  52. data/lib/phony/national_splitters/none.rb +1 -3
  53. data/lib/phony/trunk_code.rb +5 -5
  54. data/lib/phony.rb +62 -57
  55. data/spec/functional/config_spec.rb +44 -0
  56. data/spec/functional/plausibility_spec.rb +285 -18
  57. data/spec/lib/phony/countries_spec.rb +140 -39
  58. data/spec/lib/phony/country_codes_spec.rb +82 -58
  59. data/spec/lib/phony/country_spec.rb +29 -9
  60. data/spec/lib/phony/dsl_spec.rb +7 -3
  61. data/spec/lib/phony/local_splitters/regex_spec.rb +19 -15
  62. data/spec/lib/phony/national_code_spec.rb +15 -45
  63. data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -16
  64. data/spec/lib/phony/national_splitters/none_spec.rb +3 -3
  65. data/spec/lib/phony/national_splitters/variable_spec.rb +9 -13
  66. data/spec/lib/phony/trunk_code_spec.rb +85 -0
  67. data/spec/lib/phony/vanity_spec.rb +4 -4
  68. data/spec/lib/phony_spec.rb +63 -67
  69. metadata +13 -8
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe 'country descriptions' do
6
6
 
7
7
  def self.it_splits number, expected
8
- it { Phony.split(number).should == expected }
8
+ it { expect(Phony.split(number)).to eq expected }
9
9
  end
10
10
 
11
11
  describe 'regression' do
@@ -33,13 +33,13 @@ describe 'country descriptions' do
33
33
  end
34
34
 
35
35
  describe 'Argentina' do
36
- it_splits '541112345678', ['54', '11', '1234', '5678']
37
- it_splits '542911234567', ['54', '291', '123', '4567']
38
- it_splits '542965123456', ['54', '2965', '12', '3456']
39
- it_splits '5491112345678', ['54', '911', '1234', '5678']
40
- it_splits '5492201234567', ['54', '9220', '123', '4567']
41
- it_splits '5492221123456', ['54', '92221', '12', '3456']
42
- it_splits '548001234567', ['54', '800', '123', '4567']
36
+ it_splits '541112345678', ['54', '11', '1234', '5678'] # 2-digit area code / landline
37
+ it_splits '542911234567', ['54', '291', '123', '4567'] # 3-digit area code / landline
38
+ it_splits '542903123456', ['54', '2903', '12', '3456'] # 4-digit area code / landline
39
+ it_splits '5491112345678', ['54', '911', '1234', '5678'] # 2-digit area code / international mobile
40
+ it_splits '5492201234567', ['54', '9220', '123', '4567'] # 3-digit area code / international mobile
41
+ it_splits '5492221123456', ['54', '92221', '12', '3456'] # 4-digit area code / international mobile
42
+ it_splits '548001234567', ['54', '800', '123', '4567'] # Non-geographic number
43
43
  end
44
44
 
45
45
  describe 'Austria' do
@@ -103,8 +103,17 @@ describe 'country descriptions' do
103
103
  it_splits '3295551914', ['32', '9', '555', '19', '14'] # Gent
104
104
  it_splits '3245551414', ['32', '4', '555', '14', '14'] # Liège
105
105
  it_splits '3216473200', ['32', '16', '47', '32', '00'] # Leuven
106
- it_splits '32475279584', ['32', '475', '27', '95', '84'] # mobile
107
- it_splits '32468279584', ['32', '468', '27', '95', '84'] # mobile (Telenet)
106
+ it_splits '32455123456', ['32', '455', '12', '34', '56'] # mobile (Voo)
107
+ it_splits '32456123456', ['32', '456', '12', '34', '56'] # mobile (MobileViking)
108
+ it_splits '32460123456', ['32', '460', '12', '34', '56'] # mobile (Proximus)
109
+ it_splits '32465123456', ['32', '465', '12', '34', '56'] # mobile (Lycamobile)
110
+ it_splits '32466123456', ['32', '466', '12', '34', '56'] # mobile (Vectone)
111
+ it_splits '32467123456', ['32', '467', '12', '34', '56'] # mobile (Telenet)
112
+ it_splits '32468123456', ['32', '468', '12', '34', '56'] # mobile (Telenet)
113
+ it_splits '32469123456', ['32', '469', '12', '34', '56'] # mobile ()
114
+ it_splits '32475123456', ['32', '475', '12', '34', '56'] # mobile (Proximus)
115
+ it_splits '32485123456', ['32', '485', '12', '34', '56'] # mobile (Telenet)
116
+ it_splits '32495123456', ['32', '495', '12', '34', '56'] # mobile (Orange)
108
117
  it_splits '3270123123', ['32', '70', '123', '123'] # Bus Service?
109
118
  it_splits '3278123123', ['32', '78', '123', '123'] # National rate service
110
119
  it_splits '3290123123', ['32', '901', '23', '123'] # National rate service
@@ -138,9 +147,8 @@ describe 'country descriptions' do
138
147
  end
139
148
 
140
149
  describe 'Brazil' do
141
- it_splits '551112341234', ['55', '11', '1234', '1234']
150
+ it_splits '551122341234', ['55', '11', '2234', '1234']
142
151
  it_splits '5511981231234', ['55', '11', '98123', '1234'] # São Paulo's 9 digits mobile
143
- it_splits '552181231234', ['55', '21', '8123', '1234']
144
152
  it_splits '5521981231234', ['55', '21', '98123', '1234'] # Rio de Janeiro's 9 digits mobile
145
153
  it_splits '551931311234', ['55', '19', '3131', '1234']
146
154
  it_splits '5531991311234', ['55', '31', '99131', '1234'] # Belo Horizonte's 9th digit
@@ -148,6 +156,7 @@ describe 'country descriptions' do
148
156
  it_splits '5579991311234', ['55', '79', '99131', '1234'] # Sergipe's 9th digit
149
157
  it_splits '5547991311234', ['55', '47', '99131', '1234'] # Santa Catarina's 9th digit
150
158
  it_splits '5541991311234', ['55', '41', '99131', '1234'] # Parana's 9th digit
159
+ it_splits '556734212121', ['55', '67', '3421', '2121']
151
160
 
152
161
  context 'mobile numbers' do
153
162
  %w{
@@ -179,6 +188,26 @@ describe 'country descriptions' do
179
188
  it_splits '55199', ['55', '199', ""]
180
189
  end
181
190
  end
191
+ describe "Bulgaria" do
192
+ it_splits '35929284000', ['359', '2', '928', '4000'] # Sofia
193
+ it_splits '359878357523', ['359', '87', '8357', '523']
194
+ it_splits '3593012345', ['359', '30', '12345']
195
+ it_splits '35930123456', ['359', '30', '12', '3456']
196
+ it_splits '35943312345', ['359', '433', '12345']
197
+ it_splits '3596012345', ['359', '60', '12345']
198
+ it_splits '35969123456', ['359', '69', '123456']
199
+ it_splits '35970512345', ['359', '705', '12345']
200
+ it_splits '3597051234', ['359', '705', '1234']
201
+ it_splits '3597112345', ['359', '71', '12345']
202
+ it_splits '35979123456', ['359', '79', '123456']
203
+ it_splits '35980112345', ['359', '801', '12345']
204
+ it_splits '3598112345', ['359', '81', '12345']
205
+ it_splits '35986123456', ['359', '86', '123456']
206
+ it_splits '359881234567', ['359', '88', '1234', '567']
207
+ it_splits '35990123456', ['359', '90', '123456']
208
+ it_splits '359988123456', ['359', '988', '123456']
209
+ it_splits '359998123456', ['359', '998', '123456']
210
+ end
182
211
  describe 'Cambodia' do
183
212
  it_splits '85512236142', ["855", "12", "236", "142"] # mobile (Mobitel)
184
213
  it_splits '855977100872', ["855", "97", "710", "0872"] # mobile (Metfone)
@@ -194,9 +223,24 @@ describe 'country descriptions' do
194
223
  describe 'China' do
195
224
  it_splits '862112345678', ['86', '21', '1234', '5678'] # Shanghai
196
225
  it_splits '8675582193447', ['86', '755', '8219', '3447'] # Shenzhen
226
+ it_splits '869511234567', ['86', '951', '123', '4567'] # Yinchuan
227
+
228
+ context 'mobile numbers' do
229
+ %w{
230
+ 130 131 132 133 134 135 136 137 138 139
231
+ 145 146 147 148 149
232
+ 150 151 152 153 155 156 157 158 159
233
+ 162 165 166 167
234
+ 170 171 172 173 174 175 176 177 178
235
+ 180 181 182 183 184 185 186 187 188 189
236
+ 190 191 192 193 195 196 197 198 199
237
+ }.each do |prefix|
238
+ it_splits "86#{prefix}12345678", ['86', prefix, '1234', '5678']
239
+ end
240
+ end
197
241
  end
198
242
  describe 'Colombia' do
199
- it_splits '5711234567', ['57', '1', '123', '4567']
243
+ it_splits '5711234567', ['57', '1', '123', '4567'] # Outdated.
200
244
  it_splits '573101234567', ['57', '310', '123', '4567'] # mobile
201
245
  end
202
246
  describe 'Croatia' do
@@ -271,7 +315,7 @@ describe 'country descriptions' do
271
315
  it_splits '49800222340010', ['49', '800', '222', '340010'] # Service number
272
316
 
273
317
  it_splits '4915111231234', ['49', '151', '1123', '1234'] # Mobile number
274
- it_splits '4915771231234', ['49', '157', '7123', '1234'] # Mobile number
318
+ it_splits '4915771231234', ['49', '1577', '123', '1234'] # Mobile number
275
319
  it_splits '491601234567', ['49', '160', '1234', '567'] # Mobile number
276
320
  it_splits '4916312345678', ['49', '163', '1234', '5678'] # Mobile number
277
321
  it_splits '4915211231234', ['49', '1521', '123', '1234'] # Mobile number
@@ -309,7 +353,8 @@ describe 'country descriptions' do
309
353
  end
310
354
 
311
355
  describe 'Hong Kong' do
312
- it_splits '85212341234', ['852', false, '1234', '1234'] #
356
+ it_splits '85212341234', ['852', false, '1234', '1234'] #Other Numbers
357
+ it_splits '852800121234', ['852', '800', '12', '1234'] #Toll Free
313
358
  end
314
359
 
315
360
  describe 'Hungary' do
@@ -380,6 +425,7 @@ describe 'country descriptions' do
380
425
  it_splits '35311234567', ['353', '1', '123', '4567'] # Dublin, 7 digit subscriber #
381
426
  it_splits '353539233333', ['353', '53', '923', '3333'] # Wexford, 7 digit subscriber
382
427
  it_splits '3532212345', ['353', '22', '12345'] # Mallow, 5 digit subscriber #
428
+ it_splits '353441234567', ['353', '44', '123', '4567'] # Mullingar, Castlepollard, Tyrellspass 7 digit subscriber #
383
429
  it_splits '35345123456', ['353', '45', '123456'] # Naas, 6 digit subscriber #
384
430
  it_splits '353801234567', ['353', '80', '123', '4567'] # Mobile
385
431
  it_splits '353761234567', ['353', '76', '123', '4567'] # VoIP
@@ -388,14 +434,16 @@ describe 'country descriptions' do
388
434
  end
389
435
 
390
436
  describe 'Israel (972)' do
391
- it_splits '972100', ['972', '1', '00'] # Police
392
- it_splits '97221231234', ['972', '2', '123', '1234'] # Jerusalem Area
393
- it_splits '97282411234', ['972', '8', '241', '1234'] # Gaza Strip (Palestine)
394
- it_splits '97291231234', ['972', '9', '123', '1234'] # Sharon Area
395
- it_splits '972501231234', ['972', '50', '123', '1234'] # Mobile (Pelephone)
396
- it_splits '972591231234', ['972', '59', '123', '1234'] # Mobile Jawwal (Palestine)
397
- it_splits '972771231234', ['972', '77', '123', '1234'] # Cable Phone Services
437
+ it_splits '972100', ['972', '1', '00'] # Police
438
+ it_splits '97221231234', ['972', '2', '123', '1234'] # Jerusalem Area
439
+ it_splits '97282411234', ['972', '8', '241', '1234'] # Gaza Strip (Palestine)
440
+ it_splits '97291231234', ['972', '9', '123', '1234'] # Sharon Area
441
+ it_splits '972501231234', ['972', '50', '123', '1234'] # Mobile (Pelephone)
442
+ it_splits '972591231234', ['972', '59', '123', '1234'] # Mobile Jawwal (Palestine)
443
+ it_splits '972771231234', ['972', '77', '123', '1234'] # Cable Phone Services
398
444
  it_splits '9721700123123', ['972', '1', '700', '123', '123'] # Cable Phone Services
445
+ it_splits '972511234567', ['972', '51', '123', '4567'] # Mobile (We4G)
446
+ it_splits '972791111111', ['972', '79', '111', '1111'] # Landline (Hallo, Cellact, Telzar)
399
447
  end
400
448
  describe 'Israel (970)' do
401
449
  it_splits '97021231234', ['970', '2', '123', '1234'] # Jerusalem Area
@@ -412,8 +460,9 @@ describe 'country descriptions' do
412
460
  it_splits '3934869528123',['39', '348', '695', '2812', '3'] # Mobile (8-digit subscriber no - new)
413
461
  it_splits '393357210488', ['39', '335', '721', '0488'] # Mobile
414
462
  it_splits '393248644272', ['39', '324', '864', '4272'] # Mobile
415
- it_splits '3906123412', ['39', '06', '1234', '12'] # Roma 6 digit
416
- it_splits '39061234123', ['39', '06', '1234', '123'] # Roma 7 digit
463
+ it_splits '390612341', ['39', '06', '12341'] # Roma 5 digit
464
+ it_splits '3906123412', ['39', '06', '1234', '12'] # Roma 6 digit
465
+ it_splits '39061234123', ['39', '06', '1234', '123'] # Roma 7 digit
417
466
  it_splits '390612341234', ['39', '06', '1234', '1234'] # Roma 8 digit
418
467
  it_splits '3902888388', ['39', '02', '8883', '88'] # Milano 6 digit
419
468
  it_splits '39028883888', ['39', '02', '8883', '888'] # Milano 7 digit
@@ -422,10 +471,12 @@ describe 'country descriptions' do
422
471
  it_splits '3903123391', ['39', '031', '23391'] # Como
423
472
  it_splits '390909709511', ['39', '090', '9709511'] # Barcellona
424
473
  it_splits '390471811353', ['39', '0471', '811', '353'] # Bolzano
474
+ it_splits '3905745730', ['39', '0574', '5730'] # Prato
425
475
  end
426
476
  describe 'Japan' do
427
477
  it_splits '81312345678', %w(81 3 1234 5678) # Tokyo
428
478
  it_splits '81612345678', %w(81 6 1234 5678) # Osaka
479
+ it_splits '818001001234', %w(81 800 100 1234) # Freephone
429
480
  it_splits '81120123456', %w(81 120 123 456) # Freephone
430
481
  it_splits '81111234567', %w(81 11 123 4567)
431
482
  it_splits '81123123456', %w(81 123 12 3456)
@@ -436,12 +487,18 @@ describe 'country descriptions' do
436
487
  it_splits '817012345678', %w(81 70 1234 5678) # PHS
437
488
  it_splits '818012345678', %w(81 80 1234 5678) # Cellular
438
489
  it_splits '819012345678', %w(81 90 1234 5678) # Cellular
490
+ it_splits '810570123456', %w(81 570 123 456) # Navi-dial
491
+ it_splits '810180123456', %w(81 180 123 456) # Tele-gong/Tele-dome
439
492
  end
440
493
  describe 'Kenya' do
441
494
  it_splits '254201234567', ['254', '20', '1234567'] # Nairobi
442
495
  it_splits '254111234567', ['254', '11', '1234567'] # Mombasa
443
496
  it_splits '254723100220', ['254', '723', '100220'] # Mombasa
444
497
  end
498
+ describe 'Kosovo' do
499
+ it_splits '38329000000', ['383', '29', '000', '000'] # Landline
500
+ it_splits '38344000000', ['383', '44', '000', '000'] # Mobile
501
+ end
445
502
  describe 'Kyrgyzstan' do
446
503
  it_splits '996312212345', %w(996 312 212 345)
447
504
  it_splits '996315212345', %w(996 315 212 345)
@@ -536,6 +593,10 @@ describe 'country descriptions' do
536
593
  it_splits '31222123456', ['31', '222', '123', '456']
537
594
  it_splits '3197012345678', ['31', '970', '1234', '5678'] # machine-to-machine
538
595
  end
596
+ describe 'Norfolk Island' do
597
+ it_splits '672321234', ['672', '3', '21', '234'] # fixed
598
+ it_splits '672351234', ['672', '3', '51', '234'] # mobile
599
+ end
539
600
  describe 'Norway' do
540
601
  it_splits '4721234567', ['47',false,'21','23','45','67']
541
602
  it_splits '4731234567', ['47',false,'31','23','45','67']
@@ -563,12 +624,13 @@ describe 'country descriptions' do
563
624
  it_splits '595961611234', %w(595 96 161 1234)
564
625
  end
565
626
  describe 'Peru' do
566
- it_splits '51112341234', ['51', '1', '1234', '1234'] # Lima
627
+ it_splits '5111231234', ['51', '1', '123', '1234'] # Lima
567
628
  it_splits '51912341234', ['51', '9', '1234', '1234'] # mobile
568
- it_splits '51841234123', ['51', '84', '1234', '123'] # Cuzco, best effort
629
+ it_splits '5184123123', ['51', '84', '123', '123'] # Cuzco, best effort
569
630
  end
570
631
  describe 'Philippines' do
571
632
  it_splits '6321234567', ['63', '2', '1234567']
633
+ it_splits '63289889999', ['63', '2', '89889999']
572
634
  it_splits '6321234567890', ['63', '2', '1234567890']
573
635
  it_splits '632123456789012', ['63', '2', '123456789012']
574
636
  it_splits '639121234567', ['63', '912', '1234567']
@@ -616,7 +678,7 @@ describe 'country descriptions' do
616
678
  it_splits '79991234567', ['7', '999', '123', '45', '67'] # Russia 3-digit
617
679
  it_splits '7840121212', ['7', '840', '12', '1212'] # Abhasia
618
680
  it_splits '7799121212', ['7', '799', '12', '1212'] # Kazachstan
619
- it_splits '7995344121212', ['7','995344','12','1212'] # South Osetia
681
+ it_splits '7995344121212', ['7', '995', '344','12','1212'] # South Osetia
620
682
  it_splits '7209175276', ['7', '209', '17', '5276'] # Fantasy number
621
683
  end
622
684
 
@@ -624,6 +686,7 @@ describe 'country descriptions' do
624
686
  it_splits '250781234567', ['250', '78', '1234567'] # mobile
625
687
  it_splits '250721234567', ['250', '72', '1234567'] # mobile
626
688
  it_splits '250731234567', ['250', '73', '1234567'] # mobile
689
+ it_splits '250791234567', ['250', '79', '1234567'] # mobile
627
690
  it_splits '250251234567', ['250', '25', '1234567'] # fixed
628
691
  it_splits '25006123456', ['250', '06', '123456'] # fixed
629
692
  end
@@ -706,6 +769,7 @@ describe 'country descriptions' do
706
769
  describe 'Switzerland' do
707
770
  it_splits '41443643532', ['41', '44', '364', '35', '32'] # Zurich (usually)
708
771
  it_splits '41800334455', ['41', '800', '334', '455'] # Service number
772
+ it_splits '41860443643532', ['41', '860', '44', '364', '35', '32'] # Voicemail access
709
773
  it_splits '41900123456', ['41', '900', '123', '456'] # Business Number
710
774
  it_splits '41901123456', ['41', '901', '123', '456'] # Business Number Entertainment
711
775
  it_splits '41906123456', ['41', '906', '123', '456'] # Business Number Adult Entertainment
@@ -787,13 +851,16 @@ describe 'country descriptions' do
787
851
  describe 'Vietnam' do
788
852
  it_splits '8498123456', ['84', '98', '123456'] # Viettel Mobile
789
853
  it_splits '8499612345', ['84', '99', '612345'] # GTel
790
- it_splits '84412345678', ['84', '4', '1234', '5678'] # Hanoi
854
+ it_splits '842421234567', ['84', '24', '2123', '4567'] # Hanoi
855
+ it_splits '842841234567', ['84', '28', '4123', '4567'] # Ho Chi Minh City
856
+ it_splits '84341234567', ['84', '34', '1234567'] # Viettel
857
+ it_splits '84841234567', ['84', '84', '1234567'] # Vinaphone
791
858
  end
792
859
  describe 'Zambia' do
793
860
  it_splits '260211123456', ['260', '211', '123456'] # Fixed
794
- it_splits '260955123456', ['260', '955', '123456'] # Mobile
795
- it_splits '260967123456', ['260', '967', '123456'] # Mobile
796
- it_splits '260978123456', ['260', '978', '123456'] # Mobile
861
+ it_splits '260955123456', ['260', '95', '512', '3456'] # Mobile
862
+ it_splits '260967123456', ['260', '96', '712', '3456'] # Mobile
863
+ it_splits '260978123456', ['260', '97', '812', '3456'] # Mobile
797
864
  it_splits '260800123456', ['260', '800', '123', '456'] # Toll free
798
865
  end
799
866
  describe 'New Zealand' do
@@ -808,7 +875,8 @@ describe 'country descriptions' do
808
875
  it_splits '6737932744', %w(673 7 932 744)
809
876
  end
810
877
  describe 'Burkina Faso' do
811
- it_splits '22667839323', ['226', false, '6783', '9323']
878
+ it_splits '22667839323', ['226', false, '67', '83', '93', '23']
879
+ it_splits '22601234567', ['226', false, '01', '23', '45', '67'] # 0 not removed.
812
880
  end
813
881
  describe 'Burundi' do
814
882
  it_splits '25712345678', ['257', false, '1234', '5678']
@@ -839,8 +907,8 @@ describe 'country descriptions' do
839
907
  it_splits '50622345678', %w(506 2 234 5678)
840
908
  end
841
909
  describe "Côte d'Ivoire" do
842
- it_splits '22507335518', ['225', '07', '33', '55', '18']
843
- it_splits '22537335518', ['225', '37', '33', '55', '18']
910
+ it_splits '2250107335518', ['225', '01', '07', '33', '55', '18']
911
+ it_splits '2250237335518', ['225', '02', '37', '33', '55', '18']
844
912
  end
845
913
  describe 'Democratic Republic of Timor-Leste' do
846
914
  it_splits '6701742945', ['670', false, '174', '2945']
@@ -903,6 +971,7 @@ describe 'country descriptions' do
903
971
  end
904
972
  describe 'Gabonese Republic' do
905
973
  it_splits '2411834375', ['241', '1', '834', '375']
974
+ it_splits '24174012345', ['241', '74', '01', '23', '45']
906
975
  end
907
976
  describe 'Gambia' do
908
977
  it_splits '2206683355', ['220', false, '668', '3355']
@@ -948,7 +1017,7 @@ describe 'country descriptions' do
948
1017
  it_splits '96287901456', %w(962 8790 1456)
949
1018
  end
950
1019
  describe 'Kiribati (Republic of)' do
951
- it_splits '68634814', ['686', false, '34', '814']
1020
+ it_splits '68634814527', ['686', false, '34814527']
952
1021
  end
953
1022
  describe "Democratic People's Republic of Korea" do
954
1023
  it_splits '850212345', %w(850 2 123 45)
@@ -990,11 +1059,14 @@ describe 'country descriptions' do
990
1059
  it_splits '21822123456', %w(218 22 123 456)
991
1060
  it_splits '218211234456', %w(218 21 1234 456)
992
1061
  it_splits '218911234456', %w(218 91 1234 456)
1062
+ it_splits '218941234456', %w(218 94 1234 456)
1063
+ it_splits '218951234456', %w(218 95 1234 456)
993
1064
  end
994
1065
  describe 'Madagascar' do
995
- it_splits '26120012345678', ['261', false, '20', '012', '345', '678']
996
- it_splits '261201243456', ['261', false, *%w(20 124 3456)]
997
- it_splits '261512345678', ['261', false, *%w(512 345 678)]
1066
+ it_splits '261202254716', ['261', '20', *%w(22 547 16)]
1067
+ it_splits '261320254716', ['261', '32', *%w(02 547 16)]
1068
+ it_splits '261330254716', ['261', '33', *%w(02 547 16)]
1069
+ it_splits '261340254716', ['261', '34', *%w(02 547 16)]
998
1070
  end
999
1071
  describe 'Malawi' do
1000
1072
  it_splits '2651725123', ['265', false, '1725', '123']
@@ -1018,7 +1090,8 @@ describe 'country descriptions' do
1018
1090
  it_splits '22212345678', ['222', false, '1234', '5678']
1019
1091
  end
1020
1092
  describe 'Mauritius' do
1021
- it_splits '23059518919', ['230', false, '5951', '8919']
1093
+ it_splits '23059518919', ['230', false, '5', '951', '8919']
1094
+ it_splits '2302600070', ['230', false, '260', '0070']
1022
1095
  end
1023
1096
  describe 'Micronesia (Federated States of)' do
1024
1097
  it_splits '6911991754', ['691', false, '199', '1754']
@@ -1071,6 +1144,8 @@ describe 'country descriptions' do
1071
1144
  describe 'Nigeria' do
1072
1145
  it_splits '23411231234', %w(234 1 123 1234) # Lagos
1073
1146
 
1147
+ it_splits '23445123456', %w(234 45 123 456) # Ogoja
1148
+
1074
1149
  # mobile numbers
1075
1150
  it_splits '2347007661234', %w(234 700 766 1234)
1076
1151
  it_splits '2347017661234', %w(234 701 766 1234)
@@ -1105,6 +1180,17 @@ describe 'country descriptions' do
1105
1180
  it_splits '2349087661234', %w(234 908 766 1234)
1106
1181
  it_splits '2349097661234', %w(234 909 766 1234)
1107
1182
 
1183
+ it_splits '2349107661234', %w(234 910 766 1234)
1184
+ it_splits '2349117661234', %w(234 911 766 1234)
1185
+ it_splits '2349127661234', %w(234 912 766 1234)
1186
+ it_splits '2349137661234', %w(234 913 766 1234)
1187
+ it_splits '2349147661234', %w(234 914 766 1234)
1188
+ it_splits '2349157661234', %w(234 915 766 1234)
1189
+ it_splits '2349167661234', %w(234 916 766 1234)
1190
+ it_splits '2349177661234', %w(234 917 766 1234)
1191
+ it_splits '2349187661234', %w(234 918 766 1234)
1192
+ it_splits '2349197661234', %w(234 919 766 1234)
1193
+
1108
1194
  it_splits '2348107661234', %w(234 810 766 1234)
1109
1195
  it_splits '2348117661234', %w(234 811 766 1234)
1110
1196
  it_splits '2348127661234', %w(234 812 766 1234)
@@ -1140,6 +1226,9 @@ describe 'country descriptions' do
1140
1226
  it_splits '6752751234', %w(675 275 1234)
1141
1227
  it_splits '67527912', %w(675 279 12)
1142
1228
  it_splits '67511512345678', %w(675 115 1234 5678)
1229
+ it_splits '67574123456', %w(675 74 123 456)
1230
+ it_splits '67573123456', %w(675 731 23 456)
1231
+ it_splits '67577301234', %w(675 7730 1 234)
1143
1232
  end
1144
1233
  describe 'Reunion / Mayotte (new)' do
1145
1234
  it_splits '262594399265', ['262', '594', '39', '92', '65']
@@ -1153,6 +1242,7 @@ describe 'country descriptions' do
1153
1242
  describe 'Samoa (Independent State of)' do
1154
1243
  it_splits '685800123', ['685', false, '800', '123']
1155
1244
  it_splits '68561123', ['685', false, '61', '123']
1245
+ it_splits '6857112345', ['685', false, '711', '2345']
1156
1246
  it_splits '6857212345', ['685', false, '721', '2345']
1157
1247
  it_splits '685830123', ['685', false, '830', '123']
1158
1248
  it_splits '685601234', ['685', false, '601', '234']
@@ -1241,6 +1331,7 @@ describe 'country descriptions' do
1241
1331
  it_splits '88633123456', %w(886 3 312 3456)
1242
1332
  it_splits '88637123456', %w(886 37 12 3456)
1243
1333
  it_splits '88682712345', %w(886 82 71 2345)
1334
+ it_splits '886801123123', %w(886 801 123 123)
1244
1335
  it_splits '88689712345', %w(886 89 71 2345)
1245
1336
  it_splits '88682672345', %w(886 826 7 2345)
1246
1337
  it_splits '88683672345', %w(886 836 7 2345)
@@ -1304,6 +1395,8 @@ describe 'country descriptions' do
1304
1395
  describe 'United Arab Emirates' do
1305
1396
  it_splits '97180012', %w(971 800 12)
1306
1397
  it_splits '971800123456789', %w(971 800 12 345 6789)
1398
+ it_splits '97180012345678', %w(971 800 12 345 678)
1399
+ it_splits '9718001234567', %w(971 800 12 345 67)
1307
1400
  it_splits '97121234567', %w(971 2 123 4567)
1308
1401
  it_splits '971506412345', %w(971 50 641 2345)
1309
1402
  it_splits '971600641234', %w(971 600 641 234)
@@ -1349,6 +1442,14 @@ describe 'country descriptions' do
1349
1442
  it_splits number, ['263', prefix, '234', '5678']
1350
1443
  end
1351
1444
  end
1445
+
1446
+ describe 'Universal International Freephone' do
1447
+ it_splits '80012345678', ['800', false, '12345678']
1448
+ end
1449
+
1450
+ describe 'Shared-Cost Service' do
1451
+ it_splits '80812345678', ['808', false, '12345678']
1452
+ end
1352
1453
  end
1353
1454
 
1354
1455
  end