phony 2.19.1 → 2.20.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbadf1b4b8c2d79d7f32c069ee47175e879d57eaf582c93a6098efb068860945
4
- data.tar.gz: 644bf8449040256b95af0a1d47bcc15ce0ff35b8dfbc0ee36dd72bdaec20bc4c
3
+ metadata.gz: a9beecb3c5ba9d3ca599f0a3284aa82305bb5512d479f0fc55c10467e1e5e3b2
4
+ data.tar.gz: b704cd453f22ebd0ca35e838895f706ee662882001c133f1f970d7b8a65338f3
5
5
  SHA512:
6
- metadata.gz: 994d683a1954d9136d9ee1fe9086e328c14b547c12db01beaf004c81beafa5625ae02f131269cfe6c945fb9666d544318663fa34b35f9d40a611066025583a82
7
- data.tar.gz: 43de3b0bf711cae8010b8b61c7c96b1ec89c88730044ae16acc68a6d866725e937811b33891a9663069f1f039d0c269fd1d1930413a168bce13957354694eba6
6
+ metadata.gz: c611f80164333973c6f3193f8997aaffefb492eb7417dc8a603d7adcfd5183d8c474806e1cd85e521f97078e36adecc3cbb43c50ee8062f40f994400324212aa
7
+ data.tar.gz: 2fd3068506fa93bba120e6c62eb49055bad27fee5725dc665c10112d1c8b1a1bbab148347dbda0e3d6d9e60885f4df8df56c173e56966a34544dd36cab5d5021
data/README.textile CHANGED
@@ -104,7 +104,11 @@ For example, when just loading the NANP CC, the retained memory usage is ~63kB.
104
104
 
105
105
  h2. List of Handled Countries
106
106
 
107
- Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
107
+ Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mauritian, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
108
+
109
+ h2. Proud Sponsors
110
+
111
+ * Renuo AG (July 22 –): "Github":https://github.com/renuo, "Homepage":https://www.renuo.ch
108
112
 
109
113
  h2. License
110
114
 
@@ -4,7 +4,7 @@
4
4
  #
5
5
  #
6
6
  # NDC Reference
7
- # http://www.anatel.gov.br/hotsites/CodigosNacionaisLocalidade/TelefoneCelular-CodigosDeArea.htm
7
+ # https://www.gov.br/anatel/pt-br/regulado/numeracao/plano-de-numeracao-brasileiro
8
8
 
9
9
  # 11 #Sao Paulo
10
10
  # 12 #Sao Paulo
@@ -99,7 +99,7 @@ special_numbers_4 = %w{ 3003 4003 4004 4020 }
99
99
  Phony.define do
100
100
  country '55',
101
101
  match(/^#{ndcs}9\d{8}$/) >> split(5,4) |
102
- match(/^#{ndcs}\d{8}$/) >> split(4,4) |
102
+ match(/^#{ndcs}[2-5]\d{7}$/) >> split(4,4) |
103
103
  one_of(special_numbers_3_4) >> split(3,4) |
104
104
  one_of(special_numbers_4) >> split(4) |
105
105
  one_of(service) >> split(3) |
@@ -3,14 +3,14 @@
3
3
  # Italian phone numbers.
4
4
  #
5
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Italy
6
- #
6
+ # https://www.itu.int/dms_pub/itu-t/oth/02/02/T020200006B0001PDFE.pdf
7
7
 
8
- ndcs_2digit = [
8
+ ndcs_1digit = [
9
9
  '02', # Milan
10
10
  '06', # Rome (including State of Vatican City) and Aprilia
11
11
  ]
12
12
 
13
- ndcs_3digit = [
13
+ ndcs_2digit = [
14
14
  '010', # Genoa
15
15
  '011', # Turin
16
16
  '015', # Biella
@@ -42,7 +42,7 @@ ndcs_3digit = [
42
42
  '099', # Taranto
43
43
  ]
44
44
 
45
- ndcs_4digit = [
45
+ ndcs_3digit = [
46
46
  '0121', # Pinerolo
47
47
  '0122', # Sestrieres, Bardonecchia and other Susa Valley mountain resorts
48
48
  '0123', # Lanzo Torinese
@@ -256,7 +256,8 @@ ndcs_4digit = [
256
256
  # but this was not frozen so easily.
257
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)
258
258
 
259
- service = [ # Not exhaustive.
259
+ # Not exhaustive.
260
+ service = [
260
261
  '112',
261
262
  '113',
262
263
  '115',
@@ -268,21 +269,37 @@ service = [ # Not exhaustive.
268
269
  '1530'
269
270
  ]
270
271
 
272
+ # Not exhaustive. Unused below - just for info purposes.
273
+ free_of_charge_services = [
274
+ '800',
275
+ '803'
276
+ ]
277
+
271
278
  Phony.define do
279
+ # Note: The 0 does not count towards NDC number length.
272
280
  country '39', trunk('', normalize: false) |
273
281
  one_of(*service) >> split(3,3) |
274
282
  one_of(*mobile) >> split(3,4,-1..1) |
275
- one_of(*ndcs_2digit) >> split(4, 2..4) |
276
- one_of(*ndcs_3digit) >> matched_split(
277
- /^1\d{6}$/ => [7],
278
- /^1\d{7}$/ => [8],
279
- /^[^1]\d{5}$/ => [6],
280
- /^[^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],
281
290
  ) |
282
- one_of(*ndcs_4digit) >> matched_split(
283
- /^1\d{5}$/ => [6],
284
- /^1\d{6}$/ => [7],
285
- /^[^1]\d{4}$/ => [5],
286
- /^[^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]
287
304
  )
288
305
  end
@@ -403,7 +403,56 @@ Phony.define do
403
403
  country '81',
404
404
  trunk('0', normalize: true, format: true, split: true) |
405
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
457
  one_of(%w(120)) >> split(3,3) | # freephone
409
458
  one_of(%w(800)) >> split(3,4) | # freephone
@@ -414,6 +463,6 @@ Phony.define do
414
463
  one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
415
464
  # TODO: 91(NDC) N(S)N length: 5-13 - Non-geographic number (Direct subscriber telephone service (legacy))
416
465
  fixed(2) >> split(4,4),
417
- :local_space => :- ,
418
- :space => :-
466
+ local_space: :-,
467
+ space: :-
419
468
  end
@@ -111,6 +111,6 @@ Phony.define do
111
111
  one_of(ndcs_with_5_subscriber_numbers) >> split(3,2) |
112
112
  one_of(ndcs_with_6_subscriber_numbers) >> split(3,3) |
113
113
  one_of(ndcs_with_7_subscriber_numbers) >> split(4,3) |
114
- one_of(%w(91 92)) >> split(4,3) | # mobile
114
+ one_of(%w(91 92 94 95)) >> split(4,3) | # mobile
115
115
  fixed(2) >> split(3,3)
116
116
  end
@@ -11,6 +11,7 @@ Phony.define do
11
11
  match(/\A(836)\d{5}\z/) >> split(1,4) | # 馬祖, start with 0836, plus 5 digits
12
12
  match(/\A(82)\d{6}\z/) >> split(2,4) | # 金門, start with 082, plus 6 digits
13
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
14
15
  match(/\A(8)\d{7}\z/) >> split(3,4) | # 屏東, start with 08, plus 7 digits
15
16
  match(/\A(49)\d{7}\z/) >> split(3,4) | # 南投, start with 049, plus 7 digits
16
17
  one_of(%w(4)) >> matched_split(
@@ -96,15 +96,16 @@ Phony.define do
96
96
  # Belgium.
97
97
  #
98
98
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Belgium
99
+ # https://www.bipt.be/operators/publication/national-numbering-plan
99
100
  #
100
101
  country '32', trunk('0') |
101
- match(/^(7[08])\d+$/) >> split(3,3) | # Premium and national rate Services
102
- match(/^(800|90\d)\d+$/) >> split(2,3) | # Toll free service and premium numbers
103
- match(/^(46[05678])\d{6}$/) >> split(2,2,2) | # Mobile (Lycamobile, Telenet, Join Experience, Proximus 0460)
104
- match(/^(4[789]\d)\d{6}$/) >> split(2,2,2) | # Mobile
105
- match(/^(45[56])\d{6}$/) >> split(2,2,2) | # Mobile Vikings and Voo
106
- one_of('2','3','4','9') >> split(3,2,2) | # Short NDCs
107
- fixed(2) >> split(2,2,2) # 2-digit NDCs
102
+ match(/^(7[08])\d+$/) >> split(3,3) | # Premium and national rate Services
103
+ match(/^(800|90\d)\d+$/) >> split(2,3) | # Toll free service and premium numbers
104
+ match(/^(46[056789])\d{6}$/) >> split(2,2,2) | # Mobile (Lycamobile, Telenet, Join Experience, Proximus 0460)
105
+ match(/^(4[789]\d)\d{6}$/) >> split(2,2,2) | # Mobile
106
+ match(/^(45[56])\d{6}$/) >> split(2,2,2) | # Mobile Vikings and Voo
107
+ one_of('2','3','4','9') >> split(3,2,2) | # Short NDCs
108
+ fixed(2) >> split(2,2,2) # 2-digit NDCs
108
109
 
109
110
  # France.
110
111
  #
@@ -154,6 +155,7 @@ Phony.define do
154
155
  #
155
156
  country '41',
156
157
  trunk('0', normalize: true) |
158
+ match(/^(860)\d+$/) >> split(2, 3, 2, 2) | # Voice Mail access
157
159
  match(/^(8(?:00|4[0248]))\d+$/) >> split(3,3) | # Freecall/Shared Cost
158
160
  match(/^(90[016])\d+$/) >> split(3,3) | # Business
159
161
  fixed(2) >> split(3,2,2)
@@ -230,6 +232,7 @@ Phony.define do
230
232
  # http://www.itu.int/oth/T020200002C/en
231
233
  country '57',
232
234
  match(/\A(3\d\d)\d+\z/) >> split(3,4) | # mobile (300 310 311 312 313 315 316)
235
+ match(/\A(60\d)\d+\z/) >> split(3,4) |
233
236
  fixed(1) >> split(3,4)
234
237
 
235
238
  # Venezuela (Bolivarian Republic of)
@@ -360,12 +363,29 @@ Phony.define do
360
363
  trunk('', :normalize => false) |
361
364
  fixed(2) >> split(2,2,2,2)
362
365
 
363
- country '226', none >> split(4,4) # Burkina Faso http://www.wtng.info/wtng-226-bf.html
366
+ # Burkina Faso
367
+ # http://www.wtng.info/wtng-226-bf.html
368
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Burkina_Faso
369
+ #
370
+ # There is no trunk code for this country and several of the mobile prefixes start with 0
371
+ country '226',
372
+ trunk('', normalize: false) |
373
+ none >> split(2,2,2,2)
374
+
364
375
  country '227', none >> split(4,4) # Niger http://www.wtng.info/wtng-227-ne.html
365
376
  country '228', none >> split(4,4) # Togolese Republic http://www.wtng.info/wtng-228-tg.html
366
377
  country '229', none >> split(4,4) # Benin http://www.itu.int/oth/T0202000017/en
367
378
 
368
- country '230', none >> split(4,4) # Mauritius http://www.wtng.info/wtng-230-mu.html
379
+ # Mauritius
380
+ # http://www.wtng.info/wtng-230-mu.html
381
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Mauritius
382
+ #
383
+ # There is no trunk code for this country.
384
+ country '230',
385
+ none >> matched_split(
386
+ /^5\d{7}$/ => [1,3,4], # Mobile
387
+ /^[246]\d{6}$/ => [3,4], # Landline
388
+ )
369
389
 
370
390
  # Liberia
371
391
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=LR
@@ -485,27 +505,32 @@ Phony.define do
485
505
  # Zambia
486
506
  # http://www.wtng.info/wtng-260-zm.html
487
507
  # https://github.com/googlei18n/libphonenumber/
508
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Zambia
509
+
488
510
  country '260',
489
- match(/^(9(5[034589]|[67]\d))/) >> split(6) | # Mobile
490
- match(/^(800)/) >> split(3,3) | # Toll free
491
- match(/^(21[1-8])/) >> split(6) # Fixed
511
+ trunk('0') |
512
+ match(/^(75|76|77|94|95|96|97)/) >> split(3, 4) | # Mobile
513
+ match(/^(800)/) >> split(3,3) | # Toll free
514
+ match(/^(21[1-8])/) >> split(6) # Fixed
492
515
 
493
- # Madagascar http://www.wtng.info/wtng-261-mg.html
516
+ # Madagascar
517
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Madagascar
494
518
  # http://www.itu.int/oth/T020200007F/en
495
519
  country '261',
496
- none >> matched_split(
497
- /\A200\d+\z/ => [2,3,3,3], # Telecom Malagasy (Telma)
498
- /\A20\d+\z/ => [2,3,4], # Telecom Malagasy (Telma)
499
- /\A23\d+\z/ => [2,3,4], # Digitel
500
- /\A30\d+\z/ => [2,3,4], # mobile Madamobil (CDMA2000)
501
- /\A31\d+\z/ => [2,3,4], # mobile Airtel Madagascar
502
- /\A32\d+\z/ => [2,3,4], # mobile Orange Madagascar
503
- /\A33\d+\z/ => [2,3,4], # mobile Airtel Madagascar
504
- /\A34\d+\z/ => [2,3,4], # mobile Telecom Malagasy (Telma)
505
- /\A5\d+\z/ => [3,3,3], # pager
506
- /\A22\d+\z/ => [3,3,3], # satellite GULFSAT Téléphonie
507
- /\A6\d+\z/ => [3,3,3] # satellite
508
- )
520
+ # none >> matched_split(
521
+ # /\A20\d+\z/ => [2,2,3,2], # Telecom Malagasy (Telma)
522
+ # /\A32\d+\z/ => [2,2,3,2], # mobile Orange Madagascar
523
+ # /\A33\d+\z/ => [2,2,3,2], # mobile Airtel Madagascar
524
+ # /\A34\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
525
+ # /\A38\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
526
+ # /\A39\d+\z => [2,2,3,2] # mobile Blueline
527
+ # ),
528
+ match(/\A(20)\d+\z/) >> split(2,3,2) | # fix Telecom Malagasy (Telma)
529
+ match(/\A(32)\d+\z/) >> split(2,3,2) | # mobile Orange Madagascar
530
+ match(/\A(33)\d+\z/) >> split(2,3,2) | # mobile Airtel Madagascar
531
+ match(/\A(34)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
532
+ match(/\A(38)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
533
+ match(/\A(39)\d+\z/) >> split(2,3,2) # mobile Blueline Madagascar
509
534
 
510
535
  country '262', # Reunion / Mayotte (new) http://www.wtng.info/wtng-262-fr.html
511
536
  trunk('0') |
@@ -904,7 +929,14 @@ Phony.define do
904
929
  )
905
930
 
906
931
  country '671', todo # Spare code
907
- country '672', todo # Australian External Territories
932
+
933
+ # Australian External Territories https://en.wikipedia.org/wiki/Telephone_numbers_in_Norfolk_Island
934
+ # Norfolk Island
935
+ country '672',
936
+ fixed(1) >> split(2,3) |
937
+ match(/^(2\d+)$/) >> split(3) | # Fixed
938
+ match(/^(5\d+)$/) >> split(3) # Mobile
939
+
908
940
  country '673', fixed(1) >> split(3, 3) # Brunei Darussalam http://www.wtng.info/wtng-673-bn.html
909
941
  country '674', none >> split(3, 4) # Nauru (Republic of) http://www.wtng.info/wtng-674-nr.html
910
942
 
@@ -971,12 +1003,12 @@ Phony.define do
971
1003
  /\A800\d+\z/ => [3,3], # freephone
972
1004
  /\A830\d+\z/ => [3,3], # shared cost
973
1005
  /\A60\d+\z/ => [3,3], # wireless geographic
974
- /\A(72|75|76|77)\d+\z/ => [3,4], # mobile
1006
+ /\A(71|72|75|76|77)\d+\z/ => [3,4], # mobile
975
1007
  /\A84\d+\z/ => [3,4], # wireless geographic
976
1008
  /\A\d+\z/ => [2,3] # geographic
977
1009
  )
978
1010
 
979
- country '686', none >> split(2,3) # Kiribati (Republic of) http://www.wtng.info/wtng-686-ki.html
1011
+ country '686', none >> split(8) # Kiribati (Republic of) https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=KI
980
1012
  country '687', none >> split(3,3) # New Caledonia (Territoire français d'outre-mer) http://www.wtng.info/wtng-687-nc.html
981
1013
  country '688', none >> split(5) # Tuvalu http://www.wtng.info/wtng-688-tv.html
982
1014
  country '689', none >> split(2,2,2,2) # French Polynesia (Territoire français d'outre-mer) http://www.wtng.info/wtng-689-pf.html
@@ -992,7 +1024,10 @@ Phony.define do
992
1024
  country '698', todo # -
993
1025
  country '699', todo # -
994
1026
 
995
- country '800', todo # International Freephone Service
1027
+ # International Freephone Service
1028
+ # https://www.itu.int/en/ITU-T/inr/unum/Pages/uifn.aspx
1029
+ country '800', none >> split(8)
1030
+
996
1031
  country '801', todo # -
997
1032
  country '802', todo # -
998
1033
  country '803', todo # -
@@ -1000,7 +1035,7 @@ Phony.define do
1000
1035
  country '805', todo # -
1001
1036
  country '806', todo # -
1002
1037
  country '807', todo # -
1003
- country '808', todo # International Shared Cost Service (ISCS)
1038
+ country '808', none >> split(12) # International Shared Cost Service (ISCS)
1004
1039
  country '809', todo # -
1005
1040
 
1006
1041
  country '830', todo # -
@@ -1044,6 +1079,7 @@ Phony.define do
1044
1079
 
1045
1080
  # Lao People's Democratic Republic http://www.wtng.info/wtng-856-la.html, https://www.numberingplans.com
1046
1081
  country '856',
1082
+ trunk('0') |
1047
1083
  one_of('30') >> split(3,4) | # geographic
1048
1084
  one_of('20') >> split(4,4) | # mobile
1049
1085
  fixed(2) >> split(3,3) # geographic
data/lib/phony/country.rb CHANGED
@@ -97,6 +97,9 @@ module Phony
97
97
  end
98
98
  end
99
99
  def format_cc_ndc trunk, ndc, local, type, space, parentheses, use_trunk
100
+ # Note: We mark NDCs that are of type "none" with false (nil trips plausible?). This would result in false being printed.
101
+ # Therefore we set NDC to nil when formatting.
102
+ ndc = nil if ndc == false
100
103
  case type
101
104
  when String
102
105
  trunk &&= trunk.format(space, use_trunk)
@@ -125,6 +128,7 @@ module Phony
125
128
  end
126
129
  end
127
130
  def format_ndc ndc, parentheses
131
+ ndc = nil if ndc == false # TODO
128
132
  parentheses ? "(#{ndc})" : ndc
129
133
  end
130
134
  def format_with_ndc format, cc, ndc, local, space
@@ -97,9 +97,20 @@ module Phony
97
97
 
98
98
  # False if it fails the basic check.
99
99
  #
100
- return false unless (4..16) === normalized.size
100
+ return false unless (4..16) === normalized.size # unless hints[:check_length] == false
101
101
 
102
102
  country, cc, rest = partial_split normalized
103
+
104
+ # Was a country calling code given?
105
+ #
106
+ if ccc = hints[:ccc]
107
+ cc, ndc, *local = split ccc
108
+
109
+ raise ArgumentError.new("The provided ccc option is too long and includes more than a cc ('#{cc}') and ndc ('#{ndc}'). It also includes '#{local.join}'.") unless local.size == 1 && local[0].empty?
110
+
111
+ hints[:cc] = cc
112
+ hints[:ndc] = ndc
113
+ end
103
114
 
104
115
  # Country code plausible?
105
116
  #
@@ -109,6 +120,8 @@ module Phony
109
120
  # Country specific tests.
110
121
  #
111
122
  country.plausible? rest, hints
123
+ rescue ArgumentError
124
+ raise
112
125
  rescue StandardError
113
126
  return false
114
127
  end
@@ -62,6 +62,8 @@ module Phony
62
62
  #
63
63
  #
64
64
  def plausible? rest, hints = {}
65
+ return true if hints[:check_length] == false
66
+
65
67
  @length === rest.inject(0) { |total, part| total + part.size }
66
68
  end
67
69
 
@@ -31,9 +31,7 @@ module Phony
31
31
  # since using nil is dangerous and breaks
32
32
  # abstraction)
33
33
  #
34
- # Note: Actually, it might stay in.
35
- #
36
- # TODO Flip nil/false?
34
+ # Note: Decided it stays in. When formatting, it's turned into nil.
37
35
  #
38
36
  def split national_number
39
37
  [nil, false, national_number]
@@ -18,27 +18,27 @@ describe 'Phony::Config' do
18
18
  it 'does not fail when loading all' do
19
19
  Phony::Config.load
20
20
 
21
- Phony.split('15551115511').should == ['1', '555', '111', '5511']
21
+ expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
22
22
  end
23
23
  it 'raises when a CC is used that has not been loaded.' do
24
24
  Phony::Config.load('41')
25
25
 
26
- expect { Phony.split('15551115511') }.to raise_error
26
+ expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
27
27
  end
28
28
  it 'raises when a CC is used that has not been loaded.' do
29
29
  Phony::Config.load(only: ['41'])
30
30
 
31
- expect { Phony.split('15551115511') }.to raise_error
31
+ expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
32
32
  end
33
33
  it 'raises when a CC is used that has not been loaded.' do
34
34
  Phony::Config.load(except: ['1'])
35
35
 
36
- expect { Phony.split('15551115511') }.to raise_error
36
+ expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
37
37
  end
38
38
  it 'does not raise when a CC is used that has been loaded.' do
39
39
  Phony::Config.load(except: ['41'])
40
40
 
41
- Phony.split('15551115511').should == ['1', '555', '111', '5511']
41
+ expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
42
42
  end
43
43
  end
44
44
  end