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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Guinea (sometimes Guinea-Conakry; officially Republic of Guinea)
2
4
  # http://www.itu.int/oth/T020200005B/en
3
5
 
@@ -25,12 +27,13 @@ land_ndcs_with_5_digits = [
25
27
  '30613' # Télimélé
26
28
  ]
27
29
 
30
+ # NOTE We're not using *('660'..'669') since it does not freeze easily.
28
31
  mobile_ndcs_with_3_digits = [
29
- *('660'..'669'), # Areeba
30
- *('620'..'629'), # Orange
31
- *('650'..'659'), # Cellcom
32
- *('630'..'639'), # Intercel
33
- *('600'..'609') # Sotelgui
32
+ '600', '601', '602', '603', '604', '605', '606', '607', '608', '609', # Sotelgui
33
+ '620', '621', '622', '623', '624', '625', '626', '627', '628', '629', # Orange
34
+ '650', '651', '652', '653', '654', '655', '656', '657', '658', '659', # Cellcom
35
+ '630', '631', '632', '633', '634', '635', '636', '637', '638', '639', # Intercel
36
+ '660', '661', '662', '663', '664', '665', '666', '667', '668', '669', # Areeba
34
37
  ]
35
38
 
36
39
  Phony.define do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Indian phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_India
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Indonesia (Republic of)
2
4
  # http://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=ID
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The Republic of Ireland has variable-length NDCs from 2-3 digits in length. Depending on the NDC, the length of the subscriber number varies from 5-7 characters in length. There does not appear to be any pattern that relates NDCs to subscriber number length.
2
4
  #
3
5
  # 7 digit subscriber numbers follow a 3-4 split pattern.
@@ -7,33 +9,30 @@
7
9
  #
8
10
  # References:
9
11
  # http://www.comreg.ie/_fileupload/publications/ComReg03147.pdf (2003)
12
+ # https://www.comreg.ie/media/dlm_uploads/2015/12/ComReg0804.pdf (2008)
10
13
  # http://www.comreg.ie/licensing_and_services/area_code_maps.552.1040.html
11
14
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_the_Republic_of_Ireland
12
15
  #
13
16
  ndcs_with_5_subscriber_digits = [
14
- ('22'..'29').to_a, # Mallow, Bandon, Youghal, Fermoy, Macroom, Bantry, Skibbereen, Kanturk
15
- '402', # Arklow
16
- '404', # Wicklow
17
- '43', # Longford, Granard
18
- '44', # Mullingar, Castlepollard, Tyrellspass
19
- '47', # Monaghan, Clones
20
- '48', # Northern Ireland
21
- '502', # Portlaoise, Abbeyleix
22
- '504', # Thurles
23
- '505', # Roscrea
24
- '506', # Tullamore
25
- '509', # Bin-
26
- '52', # Killenaule
27
- '54', # Legacy Ferns, Enniscorthy
28
- '55', # Legacy Gorey
29
- '62', # Tipperary, Cashel
30
- '63', # Charleville
31
- '64', # Killarney, Rathmore
32
- '67', # Nenagh
33
- '68', # Listowel
34
- '69', # Newcastle West
35
- '93', # Tuam
36
- ('94'..'99').to_a # Castlebar, Castlerea, Claremorris, Clifden, Ballina, Belmullet, Westport, Kilronan
17
+ '22', '24', '25', '26', '27', '28', '29', # Mallow, Youghal, Fermoy, Macroom, Bantry, Skibbereen, Kanturk
18
+ '402', # Arklow
19
+ '404', # Wicklow
20
+ '47', # Monaghan, Clones
21
+ '48', # Northern Ireland
22
+ '502', # Portlaoise, Abbeyleix
23
+ '504', # Thurles
24
+ '505', # Roscrea
25
+ '506', # Tullamore
26
+ '509', # Bin-
27
+ '54', # Legacy Ferns, Enniscorthy
28
+ '55', # Legacy Gorey
29
+ '62', # Tipperary, Cashel
30
+ '63', # Charleville
31
+ '67', # Nenagh
32
+ '68', # Listowel
33
+ '69', # Newcastle West
34
+ '93', # Tuam
35
+ '94', '95', '96', '97', '98', '99' # Castlebar, Castlerea, Claremorris, Clifden, Ballina, Belmullet, Westport, Kilronan
37
36
  ].flatten
38
37
 
39
38
  ndcs_with_6_subscriber_digits = [
@@ -46,14 +45,19 @@ ndcs_with_6_subscriber_digits = [
46
45
  ndcs_with_7_subscriber_digits = [
47
46
  '1', # Dublin
48
47
  '21', # Cork, Coachford, Kinsale
48
+ '23', # Bandon
49
49
  '41', # Ardee
50
50
  '42', # Dundalk, Carrickmacross, Castleblaney
51
+ '43', # Longford, Granard
52
+ '44', # Mullingar, Castlepollard, Tyrellspass
51
53
  '46', # Navan, Kells, Trim, Enfield, Edenderry
52
54
  '49', # Cavan, Cootehill, Oldcastle, Belturbet
55
+ '52', # Killenaule
53
56
  '53', # Wexford, Enniscorthy, Ferns, Gorey, Craanford
54
57
  '56', # Kilkenny, Castlecomer
55
58
  '58', # Dungarvan
56
59
  '59', # Carlow, Muine Bheag, Athy, Baltinglass
60
+ '64', # Killarney, Rathmore
57
61
  '65', # Ennistymon, Kilrush
58
62
  '66', # Tralee, Dingle, Killorglin, Cahirciveen
59
63
  '71', # Sligo, Manorhamilton, Carrick-on-Shannon
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Italian phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Italy
4
- #
6
+ # https://www.itu.int/dms_pub/itu-t/oth/02/02/T020200006B0001PDFE.pdf
5
7
 
6
- ndcs_2digit = [
8
+ ndcs_1digit = [
7
9
  '02', # Milan
8
10
  '06', # Rome (including State of Vatican City) and Aprilia
9
11
  ]
10
12
 
11
- ndcs_3digit = [
13
+ ndcs_2digit = [
12
14
  '010', # Genoa
13
15
  '011', # Turin
14
16
  '015', # Biella
@@ -40,7 +42,7 @@ ndcs_3digit = [
40
42
  '099', # Taranto
41
43
  ]
42
44
 
43
- ndcs_4digit = [
45
+ ndcs_3digit = [
44
46
  '0121', # Pinerolo
45
47
  '0122', # Sestrieres, Bardonecchia and other Susa Valley mountain resorts
46
48
  '0123', # Lanzo Torinese
@@ -249,9 +251,13 @@ ndcs_4digit = [
249
251
 
250
252
  # All 3-- numbers are reserved for mobile phones according to
251
253
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Italy#Mobile_telephones
252
- mobile = (300..399).collect(&:to_s).to_a
254
+ # NOTE was:
255
+ # mobile = ('300'..'399').to_a
256
+ # but this was not frozen so easily.
257
+ mobile = %w(300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399)
253
258
 
254
- service = [ # Not exhaustive.
259
+ # Not exhaustive.
260
+ service = [
255
261
  '112',
256
262
  '113',
257
263
  '115',
@@ -263,21 +269,37 @@ service = [ # Not exhaustive.
263
269
  '1530'
264
270
  ]
265
271
 
272
+ # Not exhaustive. Unused below - just for info purposes.
273
+ free_of_charge_services = [
274
+ '800',
275
+ '803'
276
+ ]
277
+
266
278
  Phony.define do
267
- country '39', trunk('', :normalize => false) |
279
+ # Note: The 0 does not count towards NDC number length.
280
+ country '39', trunk('', normalize: false) |
268
281
  one_of(*service) >> split(3,3) |
269
282
  one_of(*mobile) >> split(3,4,-1..1) |
270
- one_of(*ndcs_2digit) >> split(4, 2..4) |
271
- one_of(*ndcs_3digit) >> matched_split(
272
- /^1\d{6}$/ => [7],
273
- /^1\d{7}$/ => [8],
274
- /^[^1]\d{5}$/ => [6],
275
- /^[^1]\d{6}$/ => [7]
283
+ match(/^(800)\d{6}$/) >> split(6) | # 3-6, Special handling for 800 numbers.
284
+ match(/^(803)\d{3}$/) >> split(3) | # 3-3, Special handling for 803 numbers.
285
+ one_of(*ndcs_1digit) >> matched_split(
286
+ /\A\d{5}\z/ => [5],
287
+ /\A\d{6}\z/ => [4,2],
288
+ /\A\d{7}\z/ => [4,3],
289
+ /\A\d{8}\z/ => [4,4],
276
290
  ) |
277
- one_of(*ndcs_4digit) >> matched_split(
278
- /^1\d{5}$/ => [6],
279
- /^1\d{6}$/ => [7],
280
- /^[^1]\d{4}$/ => [5],
281
- /^[^1]\d{5}$/ => [3,3]
291
+ one_of(*ndcs_2digit) >> matched_split(
292
+ /\A\d{4}\z/ => [4],
293
+ /\A\d{5}\z/ => [5],
294
+ /\A\d{6}\z/ => [6],
295
+ /\A\d{7}\z/ => [7],
296
+ /\A\d{8}\z/ => [8]
297
+ ) |
298
+ one_of(*ndcs_3digit) >> matched_split(
299
+ /\A\d{4}\z/ => [4],
300
+ /\A1\d{5}\z/ => [6],
301
+ /\A1\d{6}\z/ => [7],
302
+ /\A[^1]\d{4}\z/ => [5],
303
+ /\A[^1]\d{5}\z/ => [3,3]
282
304
  )
283
305
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Japan
2
4
  # http://www.itu.int/oth/T020200006D/en
3
5
 
@@ -164,6 +166,7 @@ ndcs_with_6_subscriber_numbers = %w(
164
166
  422
165
167
  428
166
168
  436
169
+ 438
167
170
  439
168
171
  460
169
172
  463
@@ -279,7 +282,6 @@ ndcs_with_6_subscriber_numbers = %w(
279
282
  846
280
283
  847
281
284
  848
282
- 849
283
285
  852
284
286
  853
285
287
  854
@@ -359,7 +361,6 @@ ndcs_with_5_subscriber_numbers = %w(
359
361
  1374
360
362
  1377
361
363
  1392
362
- 1394
363
364
  1397
364
365
  1398
365
366
  1456
@@ -391,7 +392,6 @@ ndcs_with_5_subscriber_numbers = %w(
391
392
  8477
392
393
  8512
393
394
  8514
394
- 8636
395
395
  9496
396
396
  9802
397
397
  9912
@@ -401,15 +401,68 @@ ndcs_with_5_subscriber_numbers = %w(
401
401
 
402
402
  Phony.define do
403
403
  country '81',
404
- trunk('0') |
405
- one_of('20', '50', '60', '70', '90') >> split(4,4) | # mobile, VoIP telephony
404
+ trunk('0', normalize: true, format: true, split: true) |
405
+ one_of(%w(20 50 60 70 90)) >> split(4,4) | # mobile, VoIP telephony
406
+ match(/\A(597)9[0178]\d+\z/) >> split(2,4) |
406
407
  one_of(ndcs_with_5_subscriber_numbers) >> split(1,4) |
408
+ match(/\A(4)70[019]\d+\z/) >> split(4,4) |
409
+ match(/\A(4)71\d+\z/) >> split(4,4) |
410
+ match(/\A(4)20\d+\z/) >> split(4,4) |
411
+ match(/\A(4)29[02-69]\d+\z/) >> split(4,4) |
412
+ match(/\A(15)4[018]\d+\z/) >> split(3,4) |
413
+ match(/\A(22)3[014-9]\d+\z/) >> split(3,4) |
414
+ match(/\A(25)[04][01]\d+\z/) >> split(3,4) |
415
+ match(/\A(25)5[0-69]\d+\z/) >> split(3,4) |
416
+ match(/\A(25)[68][01]\d+\z/) >> split(3,4) |
417
+ match(/\A(25)7[015-9]\d+\z/) >> split(3,4) |
418
+ match(/\A(25)917\d+\z/) >> split(3,4) |
419
+ match(/\A(25)999\d+\z/) >> split(3,4) |
420
+ match(/\A(26)4[016-9]\d+\z/) >> split(3,4) |
421
+ match(/\A(28)3[0134]\d+\z/) >> split(3,4) |
422
+ match(/\A(28)9[0-5]\d+\z/) >> split(3,4) |
423
+ match(/\A(29)17\d+\z/) >> split(3,4) |
424
+ match(/\A(29)3[015-9]\d+\z/) >> split(3,4) |
425
+ match(/\A(42)21\d+\z/) >> split(3,4) |
426
+ match(/\A(42)8[01456]\d+\z/) >> split(3,4) |
427
+ match(/\A(47)5[019]\d+\z/) >> split(3,4) |
428
+ match(/\A(47)9[019]\d+\z/) >> split(3,4) |
429
+ match(/\A(59)8[019]\d+\z/) >> split(3,4) |
430
+ match(/\A(59)9[01]\d+\z/) >> split(3,4) |
431
+ match(/\A(79)4[0-59]\d+\z/) >> split(3,4) |
432
+ match(/\A(79)5[01569]\d+\z/) >> split(3,4) |
433
+ match(/\A(79)6[0167]\d+\z/) >> split(3,4) |
434
+ match(/\A(82)4[0-39]\d+\z/) >> split(3,4) |
435
+ match(/\A(82)9[019]\d+\z/) >> split(3,4) |
436
+ match(/\A(82)92[1-9]\d+\z/) >> split(3,4) |
437
+ match(/\A(82)94[1-3]\d+\z/) >> split(3,4) |
438
+ match(/\A(82)96[0-47-9]\d+\z/) >> split(3,4) |
439
+ match(/\A(82)965[01346-9]\d+\z/) >> split(3,4) |
440
+ match(/\A(82)966[1-9]\d+\z/) >> split(3,4) |
441
+ match(/\A(83)76[6-8]\d+\z/) >> split(3,4) |
442
+ match(/\A(83)7[01789]\d+\z/) >> split(3,4) |
443
+ match(/\A(83)8[01]\d+\z/) >> split(3,4) |
444
+ match(/\A(86)36[23]\d+\z/) >> split(3,4) |
445
+ match(/\A(86)5[0-389]\d+\z/) >> split(3,4) |
446
+ match(/\A(86)55[23]\d+\z/) >> split(3,4) |
447
+ match(/\A(86)[01]\d+\z/) >> split(3,4) |
448
+ match(/\A(86)9[178]\d+\z/) >> split(3,4) |
449
+ match(/\A(86)72\d+\z/) >> split(3,4) |
450
+ match(/\A(86)8[019]\d+\z/) >> split(3,4) |
451
+ match(/\A(86)9[0145]\d+\z/) >> split(3,4) |
452
+ match(/\A(86)99[014-9]\d+\z/) >> split(3,4) |
453
+ match(/\A(99)331\d+\z/) >> split(3,4) |
454
+ match(/\A(99)34[357]\d+\z/) >> split(3,4) |
455
+ match(/\A(99)4[0178]\d+\z/) >> split(3,4) |
407
456
  one_of(ndcs_with_6_subscriber_numbers) >> split(2,4) |
408
- one_of(%w(120 800)) >> split(3,3) | # freephone
457
+ one_of(%w(120)) >> split(3,3) | # freephone
458
+ one_of(%w(800)) >> split(3,4) | # freephone
459
+ one_of(%w(180 570)) >> split(3,3) | # Tele-gong/Tele-dome, Navi-dial
460
+ one_of(%w(170 990)) >> split(2,4) | # Dengon-dial, Dial Q2 (discontinued)
461
+ one_of(%w(80)) >> split(4,4) | # mobile
409
462
  one_of(ndcs_with_7_subscriber_numbers) >> split(3,4) |
410
463
  one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
411
464
  # TODO: 91(NDC) N(S)N length: 5-13 - Non-geographic number (Direct subscriber telephone service (legacy))
412
465
  fixed(2) >> split(4,4),
413
- :local_space => :- ,
414
- :space => :-
466
+ local_space: :-,
467
+ space: :-
415
468
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Kyrgyz Republic
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=KG
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Latvia
2
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=LV
3
5
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Lybia, https://www.numberingplans.com/?page=dialling&sub=areacodes
2
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=LY
3
5
 
@@ -109,6 +111,6 @@ Phony.define do
109
111
  one_of(ndcs_with_5_subscriber_numbers) >> split(3,2) |
110
112
  one_of(ndcs_with_6_subscriber_numbers) >> split(3,3) |
111
113
  one_of(ndcs_with_7_subscriber_numbers) >> split(4,3) |
112
- one_of(%w(91 92)) >> split(4,3) | # mobile
114
+ one_of(%w(91 92 94 95)) >> split(4,3) | # mobile
113
115
  fixed(2) >> split(3,3)
114
116
  end
@@ -1,19 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Malaysian phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
4
6
  #
5
7
  ndcs = [
6
8
  '2', # Singapore
7
- '3', # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
8
9
  '4', # Kedah, Penang & Perlis
9
10
  '5', # Perak & Cameron Highlands (Pahang)
10
11
  '6', # Melaka, Negeri Sembilan & Muar (Johor)
11
12
  '7', # Johor (except Muar)
12
13
  '9', # Kelantan, Pahang (except Cameron Highlands & Genting Highlands) & Terengganu
13
14
  ]
15
+
16
+ ndcs_two_digits = [
17
+ '80', # Domestic access code from East Malaysia to Brunei
18
+ '81', # Reserved number for future use
19
+ '82', # Sarawak – Kuching, Samarahan and Serian
20
+ '83', # Sarawak – Sri Aman and Betong
21
+ '84', # Sarawak – Sibu, Sarikei, Mukah and Kapit
22
+ '85', # Sarawak – Miri, Limbang and Lawas
23
+ '86', # Sarawak – Bintulu and Belaga
24
+ '87', # Labuan Interior Division, Sabah
25
+ '88', # Sabah – Kota Kinabalu and Kudat
26
+ '89', # Sabah – Lahad Datu, Sandakan and Tawau
27
+ ]
28
+
14
29
  mobile = %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 }
15
30
  # service = %w{ 100 101 102 103 104 108 991 994 995 999 } # Emergeny and Service numbers, only 3 digits long
16
31
  freephone = %w{ 300 700 800 }
32
+ ndcs_eight = [
33
+ '3' # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
34
+ ]
17
35
 
18
36
  Phony.define do
19
37
  country '60',
@@ -21,6 +39,8 @@ Phony.define do
21
39
  one_of(freephone) >> split(2,4) | # Freephone, Tollfree, Forwarding
22
40
  # one_of(service) >> none | # Service
23
41
  one_of(mobile) >> split(3,4..5) | # Mobile
24
- one_of(ndcs) >> split(8) | # 1-digit NDCs
42
+ one_of(ndcs_two_digits) >> split(6) | # 2-digit NDCs
43
+ one_of(ndcs) >> split(7) | # 1-digit NDCs
44
+ one_of(ndcs_eight) >> split(8) | # 1-digit NDCs
25
45
  fixed(2) >> split(8) # 2-digit NDCs (Also, fallback)
26
46
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Moldova
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=MD
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Montenegro
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=ME
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Myanmar: http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000920003PDFE.pdf
2
4
  #
3
5
  # formatting according to Google's libphonenumber library. (r680 7/30/2014)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Namibia
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=NA
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Nepal
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=NP
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The Netherlands use a variable-length ndc code, thus we use a separate file to not let all_other.rb explode. The
2
4
  # latest version of the numbering plan is available at http://wetten.overheid.nl/BWBR0010198/
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Pakistan (Islamic Republic of)
2
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=PK
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Paraguay (Republic of)
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=PY
@@ -1,14 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ndcs_with_5_subscriber_digits = %w(30130 30131 30132 30133 30134 30135 30136 30137 30138 30140 30141 30142 30143 30144
2
4
  30145 30146 30147 30148 30149 30150 30153 30230 30231 30232 30233 30234 30235 30236 30237 30238 30239 30240 30241
3
5
  30242 30243 30244 30245 30246 30247 30248 30249 30251 30252 30253 30255 30256 30257 30261 30262 30264 30265 30266
6
+ 33622
4
7
  34126 34130 34132 34133 34134 34136 34138 34139 34141 34145 34147 34150 34151 34152 34153 34154 34155 34157 34158
5
- 34159 34161 34162 34163 34164 34166 34240 34241 34242 34243 34244 34245 34246 34248 34249 34250 34251 34252 34253
8
+ 34159 34161 34162 34163 34164 34166 34240 34241 34243 34244 34245 34246 34248 34249 34250 34251 34252 34253
6
9
  34254 34255 34256 34257 34258 34259 34260 34261 34262 34263 34265 34266 34268 34269 34271 34272 34273 34274 34275
7
10
  34276 34277 34278 34279 34291 34292 34293 34294 34296 34297 34298 34341 34342 34343 34344 34345 34346 34347 34349
8
11
  34350 34355 34356 34357 34358 34360 34361 34362 34363 34364 34365 34367 34368 34369 34370 34371 34372 34373 34374
9
12
  34375 34376 34377 34380 34383 34384 34385 34386 34387 34388 34389 34391 34394 34395 34397 34398 34531 34533 34535
10
13
  34537 34539 34541 34542 34543 34544 34545 34546 34547 34550 34551 34553 34554 34555 34556 34557 34561 34634 34638
11
- 34643 34667 34668 34669 34670 34672 34673 34674 34675 34676 34677 34678 34731 34739 34740 34741 34742 34743 34744
14
+ 34643 34667 34668 34669 34670 34672 34674 34675 34676 34677 34678 34731 34739 34740 34741 34742 34743 34744
12
15
  34745 34746 34747 34748 34749 34750 34751 34752 34753 34754 34755 34756 34757 34758 34759 34760 34761 34762 34763
13
16
  34764 34765 34766 34767 34768 34769 34770 34771 34772 34773 34774 34775 34776 34777 34778 34779 34780 34781 34782
14
17
  34783 34784 34785 34786 34787 34788 34789 34791 34792 34794 34795 34796 34797 34798 34922 34932 34934 34936 34938
@@ -61,7 +64,9 @@ ndcs_with_5_subscriber_digits = %w(30130 30131 30132 30133 30134 30135 30136 301
61
64
  49146 49147 49148 49151 49152 49153 49154 49155 49156 49157 49158 49231 49232 49233 49234 49235 49236 49237 49238
62
65
  49241 49242 49243 49244 49245 49246 49247 49248 49254 49331 49333 49334 49336 49337 49339 49341 49343 49344 49345
63
66
  49346 49347 49349 49351 49352 49353 49354 49355 49356 49357 49430 49431 49432 49433 49434 49435 49436 49437 49438
64
- 49439 49440 49441 49442 49443 49444 49445 49446 49447 49448 49449 49450 49451 49452 49453 81131 81132 81133 81134
67
+ 49439 49440 49441 49442 49443 49444 49445 49446 49447 49448 49449 49450 49451 49452 49453 71036 71063 71133 71237
68
+ 71336 71337 71431 71433 71435 71536 71538 71543 71630 71636 71644 71645 71651 71837 72137 72153 72251 72335 72336
69
+ 72340 72433 72533 72537 72636 72752 72771 72772 72774 72775 72834 72835 81131 81132 81133 81134
65
70
  81135 81136 81137 81138 81139 81140 81141 81142 81143 81144 81145 81146 81147 81148 81149 81150 81151 81152 81153
66
71
  81361 81362 81363 81364 81365 81366 81367 81368 81369 81370 81371 81372 81373 81374 81375 81376 81378 81379 81430
67
72
  81431 81433 81434 81436 81437 81439 81450 81451 81452 81454 81455 81456 81457 81458 81459 81530 81531 81532 81533
@@ -85,7 +90,7 @@ ndcs_with_5_subscriber_digits = %w(30130 30131 30132 30133 30134 30135 30136 301
85
90
  84377 84378 84379 84396 84442 84443 84444 84445 84446 84447 84452 84453 84454 84455 84456 84457 84458 84461 84462
86
91
  84463 84464 84465 84466 84467 84468 84472 84473 84474 84475 84476 84477 84478 84479 84492 84493 84494 84495 84540
87
92
  84542 84543 84544 84545 84548 84549 84550 84551 84552 84554 84555 84557 84558 84560 84561 84562 84563 84564 84565
88
- 84566 84567 84568 84573 84574 84575 84576 84577 84578 84579 84591 84592 84593 84595 84596 84630 84635 84639 84646
93
+ 84566 84567 84568 84573 84574 84575 84576 84577 84578 84579 84591 84592 84593 84595 84596 84635 84639 84646
89
94
  84647 84648 84650 84651 84652 84653 84654 84655 84656 84657 84658 84660 84661 84663 84664 84666 84667 84670 84671
90
95
  84672 84673 84674 84675 84676 84677 84722 84731 84732 84733 84734 84735 84736 84741 84742 84743 84744 84745 84746
91
96
  84747 84862 85140 85141 85142 85143 85144 85145 85146 85147 85148 85149 85171 85172 85549 85551 85552 85555 85556
@@ -103,17 +108,21 @@ ndcs_with_5_subscriber_digits = %w(30130 30131 30132 30133 30134 30135 30136 301
103
108
  87872 87873 87874 87875 87876 87877 87878 87879 87922 87932 87934 87935 87937 87938 87951 87961 87964
104
109
  )
105
110
 
106
- ndcs_with_6_subscriber_digits = %w(3012 3022 3412 3435 3439 3452 3456 3462 3463 3466 3473 3494 3496 3513 3519 3522 3532 3537
107
- 3812 3822 3823 3842 3843 3846 3852 3854 3882 3902 3919 3942 3952 3953 3955 4012 4112 4132 4152 4162 4212 4217 4232 4234
108
- 4236 4242 4712 4722 4725 4742 4752 4812 4822 4832 4842 4852 4855 4862 4872 4912 4922 4932 4942 8112 8142 8152 8162
109
- 8172 8202 8212 8216 8313 8332 8342 8352 8362 8412 8422 8442 8443 8452 8453 8464 8482 8512 8552 8553 8555 8557 8617
110
- 8622 8634 8635 8636 8639 8652 8662 8672 8712 8722 8732 8772 8782 8793
111
+ ndcs_with_6_subscriber_digits = %w(3012 3022 3412 3424 3435 3439 3452 3456 3462 3463 3466 3467 3473 3494 3496 3513 3519
112
+ 3522 3532 3537 3812 3822 3823 3842 3843 3846 3852 3854 3882 3902 3919 3942 3952 3953 3955 4012 4112 4132 4152 4162
113
+ 4212 4217 4234 4236 4242 4712 4722 4725 4742 4752 4812 4822 4832 4842 4852 4855 4862 4872 4912 4922 4932 4942
114
+ 7102 7112 7122 7132 7142 7152 7162 7172 7182 7187 7212 7213 7222 7232 7242 7252 7262 7272 7282 7292 8112 8142 8152
115
+ 8162 8172 8202 8212 8216 8313 8332 8342 8352 8362 8412 8422 8442 8443 8452 8453 8464 8482 8512 8552 8553 8555 8557
116
+ 8617 8622 8634 8635 8636 8639 8652 8662 8672 8712 8722 8732 8772 8782 8793
111
117
  )
112
118
 
113
- ndcs_with_7_subscriber_digits = %w(342 343 347 351 383 391 473 495 496 498 499 812 818 831 843 844 846 861 863
114
- 901 902 903 904 905 906 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929
115
- 930 931 932 933 934 936 937 938 950 951 952 953 960 961 962 963 964 965 967 968 969 977 980 981 982 983 984 985
116
- 987 988 989 996 997 999
119
+ # 978, 869, and 365 are mobile, Sevastopol landlines, and Crimean landlines,
120
+ # which I can't wait to have removed from this library ASAP due to the illegal
121
+ # annexation of Ukrainian territory.
122
+ ndcs_with_7_subscriber_digits = %w(342 343 347 351 365 383 391 423 473 495 496 498 499 700 701 702 727 777 778 804 812
123
+ 818 831 843 844 846 861 863 869 900 901 902 903 904 905 906 908 909 910 911 912 913 914 915 916 917 918 919 920 921
124
+ 922 923 924 925 926 927 928 929 930 931 932 933 934 936 937 938 950 951 952 953 958 960 961 962 963 964 965 966 967
125
+ 968 969 977 978 980 981 982 983 984 985 986 987 988 989 992 993 995 996 997 999
117
126
  )
118
127
 
119
128
  Phony.define do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # References:
2
4
  # http://www.itu.int/oth/T02020000B7/en
3
5
  # https://en.wikipedia.org/wiki/Telephone_numbers_in_Saudi_Arabia
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Serbia
2
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=RS
3
5
 
@@ -6,6 +8,9 @@ Phony.define do
6
8
  trunk('0') |
7
9
  one_of(%w(800)) >> split(3,2) | # freephone
8
10
  one_of(%w(808)) >> split(3,2) | # payphone
11
+ one_of(%w(677 678)) >> matched_split(
12
+ /\A\d{4}\z/ => [3],
13
+ /\A\d+\z/ => [3,3]) |
9
14
  one_of(%w(230)) >> matched_split(
10
15
  /\A\d{4}\z/ => [4],
11
16
  /\A\d+\z/ => [3,2]) |
@@ -19,6 +24,7 @@ Phony.define do
19
24
  one_of(%w(72)) >> split(3,3) | # ISP
20
25
  one_of(%w(60 61 68 69)) >> matched_split(
21
26
  /\A\d{3}\z/ => [3],
27
+ /\A\d{6}\z/ => [3,3],
22
28
  /\A\d{7}\z/ => [3,4],
23
29
  /\A\d+\z/ => [3,3,4]) | # mobile, voicemail (mobile)
24
30
  one_of(%w(66 63)) >> matched_split(
@@ -38,4 +44,4 @@ Phony.define do
38
44
  fixed(2) >> matched_split(
39
45
  /\A\d{5}\z/ => [3,2],
40
46
  /\A\d+\z/ => [3,3])
41
- end
47
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Phony.define do
2
4
  # Somali Democratic Republic http://www.wtng.info/wtng-252-so.html
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=SO
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # South Korean (Republic of Korea) phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_South_Korea
@@ -7,8 +9,11 @@
7
9
  # TODO 4-digit services, like "unreasonable infringement of livelihood report" number :)
8
10
  #
9
11
 
10
- special = %w{ 100 101 105 106 107 108 109 111 112 113 114 115 116 117 118 119 120 121 122 123 125 127 128 129 131 132 134 141 182 188 }
11
- mobile = ('10'..'19').to_a
12
+ special = %w(100 101 105 106 107 108 109 111 112 113 114 115 116 117 118 119 120 121 122 123 125 127 128 129 131 132 134 141 182 188)
13
+ # NOTE was:
14
+ # mobile = ('10'..'19').to_a
15
+ # but this was not frozen so easily.
16
+ mobile = %w(10 11 12 13 14 15 16 17 18 19)
12
17
 
13
18
  Phony.define do
14
19
  country '82',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Sweden uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
2
4
  #
3
5
  # Note: Sweden use a variable ndc format from length 2 to 3.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Taiwan
2
4
  # https://zh.wikipedia.org/wiki/%E4%B8%AD%E8%8F%AF%E6%B0%91%E5%9C%8B%E9%95%B7%E9%80%94%E9%9B%BB%E8%A9%B1%E5%8D%80%E8%99%9F%E8%A1%A8
3
5
  # https://en.wikipedia.org/wiki/Telephone_numbers_in_Taiwan
@@ -9,6 +11,7 @@ Phony.define do
9
11
  match(/\A(836)\d{5}\z/) >> split(1,4) | # 馬祖, start with 0836, plus 5 digits
10
12
  match(/\A(82)\d{6}\z/) >> split(2,4) | # 金門, start with 082, plus 6 digits
11
13
  match(/\A(89)\d{6}\z/) >> split(2,4) | # 臺東, start with 089, plus 6 digits
14
+ match(/\A(80\d)\d{6}\z/)>> split(3,4) | # Toll-free number
12
15
  match(/\A(8)\d{7}\z/) >> split(3,4) | # 屏東, start with 08, plus 7 digits
13
16
  match(/\A(49)\d{7}\z/) >> split(3,4) | # 南投, start with 049, plus 7 digits
14
17
  one_of(%w(4)) >> matched_split(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Tajikistan (Republic of)
2
4
 
3
5
  ndcs_with_6_subscriber_digits = %w(372)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Turkmenistan
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=TM