phony 2.15.25 → 2.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/README.textile +35 -7
  3. data/lib/phony/config.rb +91 -0
  4. data/lib/phony/countries/argentina.rb +355 -0
  5. data/lib/phony/countries/austria.rb +32 -24
  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 +6 -4
  9. data/lib/phony/countries/cambodia.rb +6 -4
  10. data/lib/phony/countries/china.rb +7 -2
  11. data/lib/phony/countries/croatia.rb +13 -16
  12. data/lib/phony/countries/georgia.rb +6 -4
  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 +7 -2
  17. data/lib/phony/countries/ireland.rb +27 -23
  18. data/lib/phony/countries/italy.rb +30 -17
  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 +24 -14
  33. data/lib/phony/countries/saudi_arabia.rb +3 -0
  34. data/lib/phony/countries/serbia.rb +7 -1
  35. data/lib/phony/countries/somalia.rb +5 -1
  36. data/lib/phony/countries/south_korea.rb +16 -9
  37. data/lib/phony/countries/sweden.rb +29 -17
  38. data/lib/phony/countries/taiwan.rb +22 -46
  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 +94 -92
  45. data/lib/phony/countries/zimbabwe.rb +2 -0
  46. data/lib/phony/countries.rb +181 -78
  47. data/lib/phony/country.rb +15 -3
  48. data/lib/phony/country_codes.rb +17 -4
  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 -4
  54. data/lib/phony/vanity.rb +1 -1
  55. data/lib/phony.rb +94 -60
  56. data/spec/functional/config_spec.rb +44 -0
  57. data/spec/functional/plausibility_spec.rb +364 -32
  58. data/spec/lib/phony/countries_spec.rb +245 -52
  59. data/spec/lib/phony/country_codes_spec.rb +106 -33
  60. data/spec/lib/phony/country_spec.rb +54 -15
  61. data/spec/lib/phony/dsl_spec.rb +2 -2
  62. data/spec/lib/phony/local_splitters/regex_spec.rb +12 -5
  63. data/spec/lib/phony/national_splitters/default_spec.rb +1 -1
  64. data/spec/lib/phony/trunk_code_spec.rb +85 -0
  65. data/spec/lib/phony/vanity_spec.rb +30 -0
  66. data/spec/lib/phony_spec.rb +70 -0
  67. metadata +26 -18
@@ -21,31 +21,40 @@ describe 'country descriptions' do
21
21
  it_splits '93201234567', ['93', '20', '1234567'] # Kabul
22
22
  end
23
23
 
24
+ describe 'Albania' do
25
+ it_splits '355691234567', ['355', '69', '123', '4567'] # Mobile 7 digits
26
+ it_splits '35569123456', ['355', '69', '123', '456'] # Mobile 6 digits
27
+ it_splits '35541234567', ['355', '4', '123', '4567'] # Tirana
28
+ end
29
+
24
30
  describe 'Algeria' do
25
31
  it_splits '213211231234', ['213', '21', '123', '1234'] # Algiers
26
32
  it_splits '213331231234', ['213', '33', '123', '1234'] # Batna
27
33
  end
28
34
 
29
35
  describe 'Argentina' do
30
- it_splits '541112345678', ['54', '11', '1234', '5678']
31
- it_splits '542911234567', ['54', '291', '123', '4567']
32
- it_splits '542965123456', ['54', '2965', '12', '3456']
33
- it_splits '5491112345678', ['54', '911', '1234', '5678']
34
- it_splits '5492201234567', ['54', '9220', '123', '4567']
35
- it_splits '5492221123456', ['54', '92221', '12', '3456']
36
- 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
37
43
  end
38
44
 
39
45
  describe 'Austria' do
40
46
  it_splits '43198110', %w( 43 1 98110 ) # Vienna
41
47
  it_splits '4310000000', %w( 43 1 0000000 ) # Vienna
42
48
  it_splits '43800123456789', %w( 43 800 123456789 ) # Free
49
+ it_splits '436780000000', %w( 43 678 0000 000 ) # Mobile
43
50
  it_splits '4368100000000', %w( 43 681 0000 0000 ) # Mobile
44
51
  it_splits '436880000000', %w( 43 688 0000 000 ) # Mobile
45
52
  it_splits '4366900000000', %w( 43 669 0000 0000 ) # Mobile
46
53
  it_splits '4367000000000', %w( 43 670 0000 0000 ) # Mobile
54
+ it_splits '4369000000000', %w( 43 690 0000 0000 ) # Mobile
47
55
  it_splits '433161234567891', %w( 43 316 1234567891 ) # Graz
48
56
  it_splits '432164123456789', %w( 43 2164 123456789 ) # Rohrau
57
+ it_splits '43720116987', %w( 43 720 116987 ) # VoIP
49
58
 
50
59
  # mobile numbers can have from 7 to 10 digits in the subscriber number
51
60
  it_splits '436641234567', %w( 43 664 1234 567 )
@@ -94,9 +103,21 @@ describe 'country descriptions' do
94
103
  it_splits '3295551914', ['32', '9', '555', '19', '14'] # Gent
95
104
  it_splits '3245551414', ['32', '4', '555', '14', '14'] # Liège
96
105
  it_splits '3216473200', ['32', '16', '47', '32', '00'] # Leuven
97
- it_splits '32475279584', ['32', '475', '27', '95', '84'] # mobile
98
- 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)
99
117
  it_splits '3270123123', ['32', '70', '123', '123'] # Bus Service?
118
+ it_splits '3278123123', ['32', '78', '123', '123'] # National rate service
119
+ it_splits '3290123123', ['32', '901', '23', '123'] # National rate service
120
+ it_splits '3280080404', ['32', '800', '80', '404'] # Apple support
100
121
  end
101
122
 
102
123
  describe 'Belize' do
@@ -120,6 +141,11 @@ describe 'country descriptions' do
120
141
  it_splits '26781234567', %w(267 8 1234 567)
121
142
  end
122
143
 
144
+ describe 'Bosnia and Herzegovina' do
145
+ it_splits '38766666666', %w(387 66 666 666)
146
+ it_splits '38733123456', %w(387 33 123 456)
147
+ end
148
+
123
149
  describe 'Brazil' do
124
150
  it_splits '551112341234', ['55', '11', '1234', '1234']
125
151
  it_splits '5511981231234', ['55', '11', '98123', '1234'] # São Paulo's 9 digits mobile
@@ -129,8 +155,10 @@ describe 'country descriptions' do
129
155
  it_splits '5531991311234', ['55', '31', '99131', '1234'] # Belo Horizonte's 9th digit
130
156
  it_splits '5571991311234', ['55', '71', '99131', '1234'] # Salvador's 9th digit
131
157
  it_splits '5579991311234', ['55', '79', '99131', '1234'] # Sergipe's 9th digit
158
+ it_splits '5547991311234', ['55', '47', '99131', '1234'] # Santa Catarina's 9th digit
159
+ it_splits '5541991311234', ['55', '41', '99131', '1234'] # Parana's 9th digit
132
160
 
133
- context 'special states with 9 in mobile' do
161
+ context 'mobile numbers' do
134
162
  %w{
135
163
  11 12 13 14 15 16 17 18 19
136
164
  21 22 24 27 28
@@ -139,6 +167,9 @@ describe 'country descriptions' do
139
167
  71 73 74 75 77 79
140
168
  81 82 83 84 85 86 87 88 89
141
169
  91 92 93 94 95 96 97 98 99
170
+ 41 42 43 44 45 46
171
+ 47 48 49
172
+ 51 53 54 55
142
173
  }.each do |state_code|
143
174
  it_splits "55#{state_code}993051123", ['55', state_code, '99305', '1123']
144
175
  end
@@ -148,6 +179,7 @@ describe 'country descriptions' do
148
179
  it_splits '5508002221234', ['55', '0800', '222', '1234']
149
180
  it_splits '5530032221', ['55', '3003', '2221']
150
181
  it_splits '5540209999', ['55', '4020', '9999']
182
+ it_splits '5540038999', ['55', '4003', '8999']
151
183
  it_splits '5540048999', ['55', '4004', '8999']
152
184
  end
153
185
 
@@ -156,6 +188,26 @@ describe 'country descriptions' do
156
188
  it_splits '55199', ['55', '199', ""]
157
189
  end
158
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
159
211
  describe 'Cambodia' do
160
212
  it_splits '85512236142', ["855", "12", "236", "142"] # mobile (Mobitel)
161
213
  it_splits '855977100872', ["855", "97", "710", "0872"] # mobile (Metfone)
@@ -171,15 +223,35 @@ describe 'country descriptions' do
171
223
  describe 'China' do
172
224
  it_splits '862112345678', ['86', '21', '1234', '5678'] # Shanghai
173
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
174
241
  end
175
242
  describe 'Colombia' do
176
- it_splits '5711234567', ['57', '1', '123', '4567']
243
+ it_splits '5711234567', ['57', '1', '123', '4567'] # Outdated.
177
244
  it_splits '573101234567', ['57', '310', '123', '4567'] # mobile
178
245
  end
179
246
  describe 'Croatia' do
180
247
  it_splits '38521695900', %w( 385 21 695 900 ) # Landline
181
248
  it_splits '38514566666', %w( 385 1 4566 666 ) # Landline (Zagreb)
249
+ it_splits '38599444999', %w( 385 99 444 999 ) # Mobile
182
250
  it_splits '385918967509', %w( 385 91 896 7509 ) # Mobile
251
+ it_splits '3858001234', %w( 385 800 1234 ) # Toll free
252
+ it_splits '385800123456', %w( 385 800 123 456 ) # Toll free
253
+ it_splits '3856012345', %w( 385 60 12 345 ) # Premium rate
254
+ it_splits '38562123456', %w( 385 62 123 456 ) # Premium, personal and UAN
183
255
  end
184
256
  describe 'Cuba' do
185
257
  it_splits '5351231234', ['53', '5123', '1234'] # Mobile
@@ -217,7 +289,7 @@ describe 'country descriptions' do
217
289
  it_splits '3589123123', ['358', '9', '123', '123'] # Helsinki
218
290
  it_splits '3581912312', ['358', '19', '123', '12'] # Nylandia
219
291
  it_splits '3585012312', ['358', '50', '123', '12'] # Mobile
220
- it_splits '358600123', ['358', '600', '123'] # Service
292
+ it_splits '35860012345', ['358', '6001', '23', '45'] # Service
221
293
  end
222
294
  describe 'France' do
223
295
  it_splits '33112345678', ['33', '1', '12','34','56','78'] # Paris
@@ -243,7 +315,7 @@ describe 'country descriptions' do
243
315
  it_splits '49800222340010', ['49', '800', '222', '340010'] # Service number
244
316
 
245
317
  it_splits '4915111231234', ['49', '151', '1123', '1234'] # Mobile number
246
- it_splits '4915771231234', ['49', '157', '7123', '1234'] # Mobile number
318
+ it_splits '4915771231234', ['49', '1577', '123', '1234'] # Mobile number
247
319
  it_splits '491601234567', ['49', '160', '1234', '567'] # Mobile number
248
320
  it_splits '4916312345678', ['49', '163', '1234', '5678'] # Mobile number
249
321
  it_splits '4915211231234', ['49', '1521', '123', '1234'] # Mobile number
@@ -281,7 +353,8 @@ describe 'country descriptions' do
281
353
  end
282
354
 
283
355
  describe 'Hong Kong' do
284
- 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
285
358
  end
286
359
 
287
360
  describe 'Hungary' do
@@ -310,6 +383,8 @@ describe 'country descriptions' do
310
383
  it_splits '622112345567', %w(62 21 1234 5567)
311
384
  it_splits '622212345', %w(62 22 123 45)
312
385
  it_splits '62221234567', %w(62 22 123 4567)
386
+ it_splits '622200000000', %w(62 22 0000 0000)
387
+ it_splits '6222000000000', %w(62 22 000 000 000)
313
388
  it_splits '624311234', %w(62 4 311 234)
314
389
  it_splits '62431123456', %w(62 4 3112 3456)
315
390
  it_splits '6262212345', %w(62 6 221 2345)
@@ -327,6 +402,7 @@ describe 'country descriptions' do
327
402
  it_splits '62877123456', %w(62 877 123 456)
328
403
  it_splits '62881123456', %w(62 881 123 456)
329
404
  it_splits '6288112345656', %w(62 881 1234 5656)
405
+ it_splits '62881123456567', %w(62 881 1234 56567)
330
406
  it_splits '628990344805', %w(62 899 034 4805)
331
407
  it_splits '6291234567', %w(62 9 1234 567)
332
408
  it_splits '629123456789', %w(62 9 123 456 789)
@@ -349,6 +425,7 @@ describe 'country descriptions' do
349
425
  it_splits '35311234567', ['353', '1', '123', '4567'] # Dublin, 7 digit subscriber #
350
426
  it_splits '353539233333', ['353', '53', '923', '3333'] # Wexford, 7 digit subscriber
351
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 #
352
429
  it_splits '35345123456', ['353', '45', '123456'] # Naas, 6 digit subscriber #
353
430
  it_splits '353801234567', ['353', '80', '123', '4567'] # Mobile
354
431
  it_splits '353761234567', ['353', '76', '123', '4567'] # VoIP
@@ -357,14 +434,16 @@ describe 'country descriptions' do
357
434
  end
358
435
 
359
436
  describe 'Israel (972)' do
360
- it_splits '972100', ['972', '1', '00'] # Police
361
- it_splits '97221231234', ['972', '2', '123', '1234'] # Jerusalem Area
362
- it_splits '97282411234', ['972', '8', '241', '1234'] # Gaza Strip (Palestine)
363
- it_splits '97291231234', ['972', '9', '123', '1234'] # Sharon Area
364
- it_splits '972501231234', ['972', '50', '123', '1234'] # Mobile (Pelephone)
365
- it_splits '972591231234', ['972', '59', '123', '1234'] # Mobile Jawwal (Palestine)
366
- 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
367
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)
368
447
  end
369
448
  describe 'Israel (970)' do
370
449
  it_splits '97021231234', ['970', '2', '123', '1234'] # Jerusalem Area
@@ -381,16 +460,23 @@ describe 'country descriptions' do
381
460
  it_splits '3934869528123',['39', '348', '695', '2812', '3'] # Mobile (8-digit subscriber no - new)
382
461
  it_splits '393357210488', ['39', '335', '721', '0488'] # Mobile
383
462
  it_splits '393248644272', ['39', '324', '864', '4272'] # Mobile
384
- it_splits '390612341234', ['39', '06', '1234', '1234'] # Roma
385
- it_splits '390288838883', ['39', '02', '8883', '8883'] # Milano
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
466
+ it_splits '390612341234', ['39', '06', '1234', '1234'] # Roma 8 digit
467
+ it_splits '3902888388', ['39', '02', '8883', '88'] # Milano 6 digit
468
+ it_splits '39028883888', ['39', '02', '8883', '888'] # Milano 7 digit
469
+ it_splits '390288838883', ['39', '02', '8883', '8883'] # Milano 8 digit
386
470
  it_splits '390141595661', ['39', '0141', '595', '661'] # Asti
387
471
  it_splits '3903123391', ['39', '031', '23391'] # Como
388
472
  it_splits '390909709511', ['39', '090', '9709511'] # Barcellona
389
473
  it_splits '390471811353', ['39', '0471', '811', '353'] # Bolzano
474
+ it_splits '3905745730', ['39', '0574', '5730'] # Prato
390
475
  end
391
476
  describe 'Japan' do
392
477
  it_splits '81312345678', %w(81 3 1234 5678) # Tokyo
393
478
  it_splits '81612345678', %w(81 6 1234 5678) # Osaka
479
+ it_splits '818001001234', %w(81 800 100 1234) # Freephone
394
480
  it_splits '81120123456', %w(81 120 123 456) # Freephone
395
481
  it_splits '81111234567', %w(81 11 123 4567)
396
482
  it_splits '81123123456', %w(81 123 12 3456)
@@ -401,12 +487,18 @@ describe 'country descriptions' do
401
487
  it_splits '817012345678', %w(81 70 1234 5678) # PHS
402
488
  it_splits '818012345678', %w(81 80 1234 5678) # Cellular
403
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
404
492
  end
405
493
  describe 'Kenya' do
406
494
  it_splits '254201234567', ['254', '20', '1234567'] # Nairobi
407
495
  it_splits '254111234567', ['254', '11', '1234567'] # Mombasa
408
496
  it_splits '254723100220', ['254', '723', '100220'] # Mombasa
409
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
410
502
  describe 'Kyrgyzstan' do
411
503
  it_splits '996312212345', %w(996 312 212 345)
412
504
  it_splits '996315212345', %w(996 315 212 345)
@@ -446,6 +538,7 @@ describe 'country descriptions' do
446
538
  end
447
539
  describe 'Macao' do
448
540
  it_splits '85328123456', ["853", "28", "12", "3456"] # Landline
541
+ it_splits '85381234567', ["853", "8", "123", "4567"] # Landline
449
542
  it_splits '85361234567', ["853", "6", "123", "4567"] # Mobile
450
543
  end
451
544
  describe 'Malaysia' do
@@ -527,12 +620,13 @@ describe 'country descriptions' do
527
620
  it_splits '595961611234', %w(595 96 161 1234)
528
621
  end
529
622
  describe 'Peru' do
530
- it_splits '51112341234', ['51', '1', '1234', '1234'] # Lima
623
+ it_splits '5111231234', ['51', '1', '123', '1234'] # Lima
531
624
  it_splits '51912341234', ['51', '9', '1234', '1234'] # mobile
532
- it_splits '51841234123', ['51', '84', '1234', '123'] # Cuzco, best effort
625
+ it_splits '5184123123', ['51', '84', '123', '123'] # Cuzco, best effort
533
626
  end
534
627
  describe 'Philippines' do
535
628
  it_splits '6321234567', ['63', '2', '1234567']
629
+ it_splits '63289889999', ['63', '2', '89889999']
536
630
  it_splits '6321234567890', ['63', '2', '1234567890']
537
631
  it_splits '632123456789012', ['63', '2', '123456789012']
538
632
  it_splits '639121234567', ['63', '912', '1234567']
@@ -541,6 +635,8 @@ describe 'country descriptions' do
541
635
  describe 'Poland' do
542
636
  it_splits '48123456789', ['48', '12', '345', '67', '89'] # Landline
543
637
  it_splits '48501123456', ['48', '501', '123', '456'] # Mobile
638
+ it_splits '48571123456', ['48', '571', '123', '456'] # Mobile
639
+ it_splits '48451123456', ['48', '451', '123', '456'] # Mobile
544
640
  it_splits '48800123456', ['48', '800', '123', '456'] # Free
545
641
  it_splits '48801123456', ['48', '801', '123', '456'] # Shared cost
546
642
  it_splits '48701123456', ['48', '701', '123', '456'] # Premium
@@ -566,20 +662,27 @@ describe 'country descriptions' do
566
662
  it_splits '40791231234', ['40', '79', '123', '1234'] # mobile
567
663
  it_splits '40249123123', ['40', '249', '123', '123'] # Olt
568
664
  end
665
+
569
666
  describe 'Russia' do
570
667
  it_splits '78122345678', ['7', '812', '234', '56', '78'] # Russia 3-digit
571
668
  it_splits '74012771077', ['7', '4012', '77', '10', '77'] # Russia 4-digit
572
669
  it_splits '78402411212', ['7', '84024', '1', '12', '12'] # Russia 5-digit
573
- it_splits '79296119119', ['7', '929', '611', '91', '19'] # Russia 3-digit, Megafon Mobile.
670
+ it_splits '79296119119', ['7', '929', '611', '91', '19'] # Russia 3-digit, Megafon Mobile
671
+ it_splits '79691234567', ['7', '969', '123', '45', '67'] # Russia 3-digit, Beeline
672
+ it_splits '79771234567', ['7', '977', '123', '45', '67'] # Russia 3-digit
673
+ it_splits '79961234567', ['7', '996', '123', '45', '67'] # Russia 3-digit
674
+ it_splits '79991234567', ['7', '999', '123', '45', '67'] # Russia 3-digit
574
675
  it_splits '7840121212', ['7', '840', '12', '1212'] # Abhasia
575
676
  it_splits '7799121212', ['7', '799', '12', '1212'] # Kazachstan
576
- it_splits '7995344121212', ['7','995344','12','1212'] # South Osetia
677
+ it_splits '7995344121212', ['7', '995', '344','12','1212'] # South Osetia
577
678
  it_splits '7209175276', ['7', '209', '17', '5276'] # Fantasy number
578
679
  end
579
- describe 'Rwanda' do
680
+
681
+ describe 'Rwanda' do
580
682
  it_splits '250781234567', ['250', '78', '1234567'] # mobile
581
683
  it_splits '250721234567', ['250', '72', '1234567'] # mobile
582
684
  it_splits '250731234567', ['250', '73', '1234567'] # mobile
685
+ it_splits '250791234567', ['250', '79', '1234567'] # mobile
583
686
  it_splits '250251234567', ['250', '25', '1234567'] # fixed
584
687
  it_splits '25006123456', ['250', '06', '123456'] # fixed
585
688
  end
@@ -588,8 +691,10 @@ describe 'country descriptions' do
588
691
  it_splits '2399920012', %w(239 9 920 012)
589
692
  end
590
693
  describe 'South Korea' do
591
- it_splits '82212345678', ['82', '2', '1234', '5678'] # Seoul
592
- it_splits '825112345678', ['82', '51', '1234', '5678'] # Busan
694
+ it_splits '82212345678', ['82', '2', '1234', '5678'] # Seoul (8 digits)
695
+ it_splits '8227111222', ['82', '2', '711', '1222'] # Seoul (7 digits)
696
+ it_splits '825112345678', ['82', '51', '1234', '5678'] # Busan (8 digits)
697
+ it_splits '82511234567', ['82', '51', '123', '4567'] # Busan (7 digits)
593
698
  it_splits '821027975588', ['82', '10', '2797', '5588'] # mobile
594
699
  it_splits '821087971234', ['82', '10', '8797', '1234'] # mobile
595
700
  end
@@ -619,12 +724,15 @@ describe 'country descriptions' do
619
724
  end
620
725
 
621
726
  describe 'Singapore' do
622
- it_splits '6561231234', ['65', false, '6123', '1234'] # Fixed line
727
+ it_splits '6561231234', ['65', false, '6123', '1234'] # Fixed line
728
+ it_splits '658008521234', ['65', false, '800', '852', '1234'] # International Toll Free Service (ITFS) and Home Country Direct Service (HCDS) Numbers
623
729
  end
624
730
  describe 'Slovakia' do
625
731
  it_splits '421912123456', ['421', '912', '123456'] # Mobile
626
732
  it_splits '421212345678', ['421', '2', '12345678'] # Bratislava
733
+ it_splits '4212123', ['421', '2', '123'] # Bratislava Short
627
734
  it_splits '421371234567', ['421', '37', '1234567'] # Nitra / Other
735
+ it_splits '42137123', ['421', '37', '123'] # Nitra / Other Short
628
736
  end
629
737
 
630
738
  describe 'Slovenia' do
@@ -649,13 +757,18 @@ describe 'country descriptions' do
649
757
  it_splits '46111234567', ['46', '11', '123', '45', '67']
650
758
  it_splits '46721234567', ['46', '72', '123', '45', '67'] # mobile
651
759
  it_splits '46791234567', ['46', '79', '123', '45', '67'] # mobile
652
- it_splits '46125123456', ['46', '125', '123', '456']
760
+ it_splits '46125123456', ['46', '125', '12', '34', '56']
653
761
  it_splits '46770820180', ['46', '77', '082', '01', '80']
654
762
  it_splits '4641712345', ['46', '417', '123', '45']
763
+ it_splits '46513123456', ['46', '513', '12', '34', '56']
655
764
  end
656
765
  describe 'Switzerland' do
657
766
  it_splits '41443643532', ['41', '44', '364', '35', '32'] # Zurich (usually)
658
767
  it_splits '41800334455', ['41', '800', '334', '455'] # Service number
768
+ it_splits '41860443643532', ['41', '860', '44', '364', '35', '32'] # Voicemail access
769
+ it_splits '41900123456', ['41', '900', '123', '456'] # Business Number
770
+ it_splits '41901123456', ['41', '901', '123', '456'] # Business Number Entertainment
771
+ it_splits '41906123456', ['41', '906', '123', '456'] # Business Number Adult Entertainment
659
772
  end
660
773
  describe 'Tanzania' do
661
774
  it_splits '255221231234', ['255', '22', '123', '1234'] # Dar Es Salaam
@@ -733,15 +846,23 @@ describe 'country descriptions' do
733
846
  end
734
847
  describe 'Vietnam' do
735
848
  it_splits '8498123456', ['84', '98', '123456'] # Viettel Mobile
736
- it_splits '8499612345', ['84', '996', '12345'] # GTel
737
- it_splits '84412345678', ['84', '4', '1234', '5678'] # Hanoi
849
+ it_splits '8499612345', ['84', '99', '612345'] # GTel
850
+ it_splits '842421234567', ['84', '24', '2123', '4567'] # Hanoi
851
+ it_splits '842841234567', ['84', '28', '4123', '4567'] # Ho Chi Minh City
852
+ it_splits '84341234567', ['84', '34', '1234567'] # Viettel
853
+ it_splits '84841234567', ['84', '84', '1234567'] # Vinaphone
738
854
  end
739
855
  describe 'Zambia' do
740
- it_splits '260955123456', ['260', '955', '123456'] # mobile
741
- it_splits '260211123456', ['260', '211', '123456'] # fixed
856
+ it_splits '260211123456', ['260', '211', '123456'] # Fixed
857
+ it_splits '260955123456', ['260', '95', '512', '3456'] # Mobile
858
+ it_splits '260967123456', ['260', '96', '712', '3456'] # Mobile
859
+ it_splits '260978123456', ['260', '97', '812', '3456'] # Mobile
860
+ it_splits '260800123456', ['260', '800', '123', '456'] # Toll free
742
861
  end
743
862
  describe 'New Zealand' do
744
863
  it_splits '6491234567', ['64', '9', '123', '4567']
864
+ it_splits '64800123123', ['64', '800', '123', '123']
865
+ it_splits '648001231234', ['64', '800', '123', '1234']
745
866
  end
746
867
  describe 'Bhutan (Kingdom of)' do
747
868
  it_splits '9759723642', %w(975 9 723 642)
@@ -781,8 +902,8 @@ describe 'country descriptions' do
781
902
  it_splits '50622345678', %w(506 2 234 5678)
782
903
  end
783
904
  describe "Côte d'Ivoire" do
784
- it_splits '22507335518', ['225', '07', '33', '55', '18']
785
- it_splits '22537335518', ['225', '37', '33', '55', '18']
905
+ it_splits '2250107335518', ['225', '01', '07', '33', '55', '18']
906
+ it_splits '2250237335518', ['225', '02', '37', '33', '55', '18']
786
907
  end
787
908
  describe 'Democratic Republic of Timor-Leste' do
788
909
  it_splits '6701742945', ['670', false, '174', '2945']
@@ -797,7 +918,30 @@ describe 'country descriptions' do
797
918
  it_splits '25349828978', ['253', false, '4982', '8978']
798
919
  end
799
920
  describe 'Ecuador' do
800
- it_splits '593445876756', %w(593 44 587 6756)
921
+ it_splits '593220000000', %w(593 22 000 0000)
922
+ it_splits '59322000000', %w(593 2 200 0000)
923
+ it_splits '593230000000', %w(593 23 000 0000)
924
+ it_splits '59323000000', %w(593 2 300 0000)
925
+ it_splits '59324000000', %w(593 2 400 0000)
926
+ it_splits '59325000000', %w(593 2 500 0000)
927
+ it_splits '593260000000', %w(593 26 000 0000)
928
+ it_splits '59327000000', %w(593 2 700 0000)
929
+ it_splits '593270000000', %w(593 27 000 0000)
930
+ it_splits '59330000000', %w(593 3 000 0000)
931
+ it_splits '59340000000', %w(593 4 000 0000)
932
+ it_splits '593440000000', %w(593 44 000 0000)
933
+ it_splits '593450000000', %w(593 45 000 0000)
934
+ it_splits '59345000000', %w(593 4 500 0000)
935
+ it_splits '59346000000', %w(593 4 600 0000)
936
+ it_splits '593470000000', %w(593 47 000 0000)
937
+ it_splits '59352000000', %w(593 5 200 0000)
938
+ it_splits '59353000000', %w(593 5 300 0000)
939
+ it_splits '59362000000', %w(593 6 200 0000)
940
+ it_splits '59372000000', %w(593 7 200 0000)
941
+ it_splits '59373000000', %w(593 7 300 0000)
942
+ it_splits '59374000000', %w(593 7 400 0000)
943
+ it_splits '59376000000', %w(593 7 600 0000)
944
+ it_splits '593900000000', %w(593 9 0000 0000)
801
945
  end
802
946
  describe 'Eritrea' do
803
947
  it_splits '2916537192', %w(291 6 537 192)
@@ -822,6 +966,7 @@ describe 'country descriptions' do
822
966
  end
823
967
  describe 'Gabonese Republic' do
824
968
  it_splits '2411834375', ['241', '1', '834', '375']
969
+ it_splits '24174012345', ['241', '74', '01', '23', '45']
825
970
  end
826
971
  describe 'Gambia' do
827
972
  it_splits '2206683355', ['220', false, '668', '3355']
@@ -909,11 +1054,14 @@ describe 'country descriptions' do
909
1054
  it_splits '21822123456', %w(218 22 123 456)
910
1055
  it_splits '218211234456', %w(218 21 1234 456)
911
1056
  it_splits '218911234456', %w(218 91 1234 456)
1057
+ it_splits '218941234456', %w(218 94 1234 456)
1058
+ it_splits '218951234456', %w(218 95 1234 456)
912
1059
  end
913
1060
  describe 'Madagascar' do
914
- it_splits '26120012345678', ['261', false, '20', '012', '345', '678']
915
- it_splits '261201243456', ['261', false, *%w(20 124 3456)]
916
- it_splits '261512345678', ['261', false, *%w(512 345 678)]
1061
+ it_splits '261202254716', ['261', '20', *%w(22 547 16)]
1062
+ it_splits '261320254716', ['261', '32', *%w(02 547 16)]
1063
+ it_splits '261330254716', ['261', '33', *%w(02 547 16)]
1064
+ it_splits '261340254716', ['261', '34', *%w(02 547 16)]
917
1065
  end
918
1066
  describe 'Malawi' do
919
1067
  it_splits '2651725123', ['265', false, '1725', '123']
@@ -990,6 +1138,8 @@ describe 'country descriptions' do
990
1138
  describe 'Nigeria' do
991
1139
  it_splits '23411231234', %w(234 1 123 1234) # Lagos
992
1140
 
1141
+ it_splits '23445123456', %w(234 45 123 456) # Ogoja
1142
+
993
1143
  # mobile numbers
994
1144
  it_splits '2347007661234', %w(234 700 766 1234)
995
1145
  it_splits '2347017661234', %w(234 701 766 1234)
@@ -1024,6 +1174,17 @@ describe 'country descriptions' do
1024
1174
  it_splits '2349087661234', %w(234 908 766 1234)
1025
1175
  it_splits '2349097661234', %w(234 909 766 1234)
1026
1176
 
1177
+ it_splits '2349107661234', %w(234 910 766 1234)
1178
+ it_splits '2349117661234', %w(234 911 766 1234)
1179
+ it_splits '2349127661234', %w(234 912 766 1234)
1180
+ it_splits '2349137661234', %w(234 913 766 1234)
1181
+ it_splits '2349147661234', %w(234 914 766 1234)
1182
+ it_splits '2349157661234', %w(234 915 766 1234)
1183
+ it_splits '2349167661234', %w(234 916 766 1234)
1184
+ it_splits '2349177661234', %w(234 917 766 1234)
1185
+ it_splits '2349187661234', %w(234 918 766 1234)
1186
+ it_splits '2349197661234', %w(234 919 766 1234)
1187
+
1027
1188
  it_splits '2348107661234', %w(234 810 766 1234)
1028
1189
  it_splits '2348117661234', %w(234 811 766 1234)
1029
1190
  it_splits '2348127661234', %w(234 812 766 1234)
@@ -1059,6 +1220,9 @@ describe 'country descriptions' do
1059
1220
  it_splits '6752751234', %w(675 275 1234)
1060
1221
  it_splits '67527912', %w(675 279 12)
1061
1222
  it_splits '67511512345678', %w(675 115 1234 5678)
1223
+ it_splits '67574123456', %w(675 74 123 456)
1224
+ it_splits '67573123456', %w(675 731 23 456)
1225
+ it_splits '67577301234', %w(675 7730 1 234)
1062
1226
  end
1063
1227
  describe 'Reunion / Mayotte (new)' do
1064
1228
  it_splits '262594399265', ['262', '594', '39', '92', '65']
@@ -1072,6 +1236,7 @@ describe 'country descriptions' do
1072
1236
  describe 'Samoa (Independent State of)' do
1073
1237
  it_splits '685800123', ['685', false, '800', '123']
1074
1238
  it_splits '68561123', ['685', false, '61', '123']
1239
+ it_splits '6857112345', ['685', false, '711', '2345']
1075
1240
  it_splits '6857212345', ['685', false, '721', '2345']
1076
1241
  it_splits '685830123', ['685', false, '830', '123']
1077
1242
  it_splits '685601234', ['685', false, '601', '234']
@@ -1118,13 +1283,23 @@ describe 'country descriptions' do
1118
1283
  it_splits '67754692', ['677', false, '54', '692']
1119
1284
  it_splits '6777546921', ['677', false, '7546', '921']
1120
1285
  end
1121
- describe 'Somali Democratic Republic' do
1286
+ describe 'Somalia' do
1122
1287
  it_splits '252103412345', %w(252 1034 123 45)
1123
1288
  it_splits '2521313123', %w(252 1313 123)
1124
1289
  it_splits '2521601234', %w(252 160 12 34)
1125
1290
  it_splits '25250012345', %w(252 500 123 45)
1126
- it_splits '252671234567', %w(252 67 1234 567)
1291
+ it_splits '252612345678', %w(252 61 234 5678) # Hormuud
1292
+ it_splits '252622345678', %w(252 62 234 5678) # Somtel Mogadishu
1293
+ it_splits '252634000613', %w(252 63 400 0613) # Telesom
1294
+ it_splits '252642345678', %w(252 64 234 5678) # Hormuud
1295
+ it_splits '252652345678', %w(252 65 234 5678) # Somtel
1296
+ it_splits '252662345678', %w(252 66 234 5678) # Somtel Puntland
1297
+ it_splits '252672345678', %w(252 67 234 5678) # Nationlink Mogadishu
1298
+ it_splits '252682345678', %w(252 68 234 5678) # Nationlink Mogadishu
1299
+ it_splits '252692345678', %w(252 69 234 5678) # Nationlink
1300
+ it_splits '252902345678', %w(252 90 234 5678) # Golis
1127
1301
  end
1302
+
1128
1303
  describe 'Suriname (Republic of)' do
1129
1304
  it_splits '597958434', ['597', false, '958', '434']
1130
1305
 
@@ -1142,16 +1317,22 @@ describe 'country descriptions' do
1142
1317
  it_splits '963912345678', %w(963 9 1234 5678)
1143
1318
  end
1144
1319
  describe 'Taiwan' do
1145
- it_splits '88618123456', %w(886 18 123 456)
1146
- it_splits '8866121234567', %w(886 612 123 4567)
1147
1320
  it_splits '886212345678', %w(886 2 1234 5678)
1148
1321
  it_splits '88631234567', %w(886 3 123 4567)
1149
- it_splits '88633123456', %w(886 33 123 456)
1150
- it_splits '88682712345', %w(886 827 123 45)
1151
- it_splits '8864121234', %w(886 412 1234)
1152
- it_splits '88690123456', %w(886 90 123 456)
1153
- it_splits '886901234567', %w(886 90 123 4567)
1154
- it_splits '88694991345', %w(886 94 991 345)
1322
+ it_splits '88651234567', %w(886 5 123 4567)
1323
+ it_splits '88661234567', %w(886 6 123 4567)
1324
+ it_splits '88671234567', %w(886 7 123 4567)
1325
+ it_splits '88633123456', %w(886 3 312 3456)
1326
+ it_splits '88637123456', %w(886 37 12 3456)
1327
+ it_splits '88682712345', %w(886 82 71 2345)
1328
+ it_splits '886801123123', %w(886 801 123 123)
1329
+ it_splits '88689712345', %w(886 89 71 2345)
1330
+ it_splits '88682672345', %w(886 826 7 2345)
1331
+ it_splits '88683672345', %w(886 836 7 2345)
1332
+ it_splits '88641212345', %w(886 4 121 2345)
1333
+ it_splits '886412123456', %w(886 4 1212 3456)
1334
+ it_splits '886491234567', %w(886 49 123 4567)
1335
+ it_splits '886901234567', %w(886 901 234 567)
1155
1336
  end
1156
1337
  describe 'Togolese Republic' do
1157
1338
  it_splits '22812345678', ['228', false, '1234', '5678']
@@ -1208,11 +1389,15 @@ describe 'country descriptions' do
1208
1389
  describe 'United Arab Emirates' do
1209
1390
  it_splits '97180012', %w(971 800 12)
1210
1391
  it_splits '971800123456789', %w(971 800 12 345 6789)
1392
+ it_splits '97180012345678', %w(971 800 12 345 678)
1393
+ it_splits '9718001234567', %w(971 800 12 345 67)
1211
1394
  it_splits '97121234567', %w(971 2 123 4567)
1212
1395
  it_splits '971506412345', %w(971 50 641 2345)
1213
1396
  it_splits '971600641234', %w(971 600 641 234)
1214
1397
  it_splits '971500641234', %w(971 500 641 234)
1215
1398
  it_splits '971200641234', %w(971 200 641 234)
1399
+ it_splits '971549999999', %w(971 54 999 9999)
1400
+ it_splits '971589999999', %w(971 58 999 9999)
1216
1401
  end
1217
1402
  describe 'Uruguay (Eastern Republic of)' do
1218
1403
  it_splits '59880012345', %w(598 800 123 45)
@@ -1251,6 +1436,14 @@ describe 'country descriptions' do
1251
1436
  it_splits number, ['263', prefix, '234', '5678']
1252
1437
  end
1253
1438
  end
1439
+
1440
+ describe 'Universal International Freephone' do
1441
+ it_splits '80012345678', ['800', false, '12345678']
1442
+ end
1443
+
1444
+ describe 'Shared-Cost Service' do
1445
+ it_splits '80812345678', ['808', false, '12345678']
1446
+ end
1254
1447
  end
1255
1448
 
1256
1449
  end