phony 2.20.13 → 2.20.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phony/config.rb +25 -26
- data/lib/phony/countries/argentina.rb +311 -314
- data/lib/phony/countries/austria.rb +71 -72
- data/lib/phony/countries/bangladesh.rb +27 -28
- data/lib/phony/countries/belarus.rb +110 -111
- data/lib/phony/countries/brazil.rb +92 -92
- data/lib/phony/countries/cambodia.rb +9 -9
- data/lib/phony/countries/china.rb +22 -21
- data/lib/phony/countries/croatia.rb +6 -5
- data/lib/phony/countries/georgia.rb +84 -84
- data/lib/phony/countries/germany.rb +4067 -4068
- data/lib/phony/countries/guinea.rb +8 -8
- data/lib/phony/countries/india.rb +31 -34
- data/lib/phony/countries/indonesia.rb +57 -46
- data/lib/phony/countries/ireland.rb +4 -5
- data/lib/phony/countries/italy.rb +54 -53
- data/lib/phony/countries/japan.rb +456 -456
- data/lib/phony/countries/kyrgyzstan.rb +109 -109
- data/lib/phony/countries/latvia.rb +34 -34
- data/lib/phony/countries/libya.rb +106 -106
- data/lib/phony/countries/malaysia.rb +12 -12
- data/lib/phony/countries/moldova.rb +42 -42
- data/lib/phony/countries/montenegro.rb +24 -20
- data/lib/phony/countries/myanmar.rb +39 -39
- data/lib/phony/countries/namibia.rb +35 -29
- data/lib/phony/countries/nepal.rb +60 -62
- data/lib/phony/countries/netherlands.rb +13 -13
- data/lib/phony/countries/pakistan.rb +135 -111
- data/lib/phony/countries/paraguay.rb +135 -135
- data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +125 -128
- data/lib/phony/countries/saudi_arabia.rb +5 -5
- data/lib/phony/countries/serbia.rb +47 -39
- data/lib/phony/countries/somalia.rb +18 -18
- data/lib/phony/countries/south_korea.rb +16 -13
- data/lib/phony/countries/sweden.rb +28 -28
- data/lib/phony/countries/taiwan.rb +20 -19
- data/lib/phony/countries/tajikistan.rb +70 -70
- data/lib/phony/countries/turkmenistan.rb +65 -65
- data/lib/phony/countries/ukraine.rb +607 -607
- data/lib/phony/countries/united_kingdom.rb +66 -66
- data/lib/phony/countries/uruguay.rb +40 -41
- data/lib/phony/countries/vietnam.rb +18 -17
- data/lib/phony/countries/zimbabwe.rb +31 -31
- data/lib/phony/countries.rb +440 -443
- data/lib/phony/country.rb +42 -44
- data/lib/phony/country_codes.rb +61 -60
- data/lib/phony/dsl.rb +23 -26
- data/lib/phony/local_splitters/fixed.rb +20 -29
- data/lib/phony/local_splitters/regex.rb +28 -31
- data/lib/phony/national_code.rb +7 -10
- data/lib/phony/national_splitters/default.rb +9 -11
- data/lib/phony/national_splitters/dsl.rb +8 -18
- data/lib/phony/national_splitters/fixed.rb +11 -14
- data/lib/phony/national_splitters/none.rb +7 -11
- data/lib/phony/national_splitters/regex.rb +13 -17
- data/lib/phony/national_splitters/variable.rb +36 -38
- data/lib/phony/trunk_code.rb +16 -18
- data/lib/phony/vanity.rb +12 -13
- data/lib/phony.rb +84 -84
- metadata +5 -39
- data/spec/functional/config_spec.rb +0 -44
- data/spec/functional/plausibility_spec.rb +0 -689
- data/spec/lib/phony/countries_spec.rb +0 -1459
- data/spec/lib/phony/country_codes_spec.rb +0 -227
- data/spec/lib/phony/country_spec.rb +0 -104
- data/spec/lib/phony/dsl_spec.rb +0 -28
- data/spec/lib/phony/local_splitters/fixed_spec.rb +0 -56
- data/spec/lib/phony/local_splitters/regex_spec.rb +0 -94
- data/spec/lib/phony/national_code_spec.rb +0 -61
- data/spec/lib/phony/national_splitters/default_spec.rb +0 -34
- data/spec/lib/phony/national_splitters/fixed_spec.rb +0 -45
- data/spec/lib/phony/national_splitters/none_spec.rb +0 -28
- data/spec/lib/phony/national_splitters/regex_spec.rb +0 -23
- data/spec/lib/phony/national_splitters/variable_spec.rb +0 -35
- data/spec/lib/phony/trunk_code_spec.rb +0 -85
- data/spec/lib/phony/vanity_spec.rb +0 -30
- data/spec/lib/phony_spec.rb +0 -70
@@ -6,7 +6,7 @@
|
|
6
6
|
land_ndcs_with_4_digits = [
|
7
7
|
'3031', # Boké
|
8
8
|
'3046', # Boussoura
|
9
|
-
|
9
|
+
'3041', '3043', '3045', '3047', # Conakry
|
10
10
|
'3069', # Delaba
|
11
11
|
'3081', # Faranah
|
12
12
|
'3024', # Fria
|
@@ -27,20 +27,20 @@ land_ndcs_with_5_digits = [
|
|
27
27
|
'30613' # Télimélé
|
28
28
|
]
|
29
29
|
|
30
|
-
# NOTE We're not using *('660'..'669') since it does not freeze easily.
|
30
|
+
# NOTE: We're not using *('660'..'669') since it does not freeze easily.
|
31
31
|
mobile_ndcs_with_3_digits = [
|
32
32
|
'600', '601', '602', '603', '604', '605', '606', '607', '608', '609', # Sotelgui
|
33
33
|
'620', '621', '622', '623', '624', '625', '626', '627', '628', '629', # Orange
|
34
34
|
'650', '651', '652', '653', '654', '655', '656', '657', '658', '659', # Cellcom
|
35
35
|
'630', '631', '632', '633', '634', '635', '636', '637', '638', '639', # Intercel
|
36
|
-
'660', '661', '662', '663', '664', '665', '666', '667', '668', '669'
|
36
|
+
'660', '661', '662', '663', '664', '665', '666', '667', '668', '669' # Areeba
|
37
37
|
]
|
38
38
|
|
39
39
|
Phony.define do
|
40
40
|
country '224',
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
one_of(land_ndcs_with_5_digits) >> split(2, 2) | # 2-2-2-2
|
42
|
+
one_of(land_ndcs_with_4_digits) >> split(2, 2) | # 2-2-2-2
|
43
|
+
one_of(mobile_ndcs_with_3_digits) >> split(2, 2, 2) | # 3-2-2-2
|
44
|
+
match(/^(7\d{2})\d{6}/) >> split(2, 2, 2) | # voip numbers
|
45
|
+
fixed(3) >> split(2, 2, 2)
|
46
46
|
end
|
@@ -11,40 +11,37 @@
|
|
11
11
|
#
|
12
12
|
#
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
mobile = %w{ 91 92 93 94 97 98 99 }
|
39
|
-
|
40
|
-
pagers = %w{ 96 }
|
14
|
+
sdca_with_2_digits = %w[11 20 22 33 39 40 44 50 60 70 79 80]
|
15
|
+
|
16
|
+
sdca_with_3_digits = %w[
|
17
|
+
120 121 122 124 129 130 131 132 135 141 144 145 151 154 160 161 164 171 172 175 177 180 181 183 184 186 191 194
|
18
|
+
210 212 217 230 231 233 239 240 241 249 250 251 254 257 260 261 265 268 270 272 278 281 285 286 288 291 294
|
19
|
+
326 341 342 343 353 354 360 361 364 369 370 373 374 376 381 385 389
|
20
|
+
413 416 421 423 424 427 431 435 451 452 461 462 469 470 471 474 475 476 477 478 479 480 481 483 484 485 487 490 491 494 495 496 497
|
21
|
+
512 515 532 535 542 548 551 562 565 572 581 595
|
22
|
+
612 621 631 641 651 657 661 663 671 674 680
|
23
|
+
712 721 724 731 733 734 744 751 755 761 747 788
|
24
|
+
816 820 821 824 831 832 836 861 863 866 870 877 878 883 884 891
|
25
|
+
140
|
26
|
+
240 249 254 260 270 272
|
27
|
+
300 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 318 320 327 328 329 340 344 349 350 357 388
|
28
|
+
412 419 430 438 439 450 453 458 459 460 464 466 467 468
|
29
|
+
510 513 520 523 529 530 537 538 539 540 543 547 550 553 557 558 559 560 563 570 575 576 577 578 579 580 589 590 593 597 598 599
|
30
|
+
610 614 616 617 619 620 623 626 628 629 630 635 636 637 638 639 640 644 648 649 650 660 669 670 677 687 688 689
|
31
|
+
730 735 738 740 750 787 789
|
32
|
+
812 814 829 843 860 879 880 887 889 890 895 897 898 899
|
33
|
+
]
|
34
|
+
|
35
|
+
mobile = %w[91 92 93 94 97 98 99]
|
36
|
+
|
37
|
+
pagers = %w[96]
|
41
38
|
|
42
39
|
Phony.define do
|
43
40
|
country '91',
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
41
|
+
trunk('0') |
|
42
|
+
one_of(sdca_with_3_digits) >> split(3, 2, 2) |
|
43
|
+
one_of(sdca_with_2_digits) >> split(3, 2, 3) |
|
44
|
+
one_of(mobile) >> split(3, 2, 3) |
|
45
|
+
one_of(pagers) >> split(2, 3, 3) |
|
46
|
+
fixed(4) >> split(3, 3) # fallback (4 digit sdca)
|
47
|
+
end
|
@@ -6,50 +6,61 @@
|
|
6
6
|
|
7
7
|
Phony.define do
|
8
8
|
country '62',
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
9
|
+
trunk('0') |
|
10
|
+
one_of('21') >> matched_split(
|
11
|
+
/\A\d{5}\z/ => [3, 2],
|
12
|
+
/\A\d{7}\z/ => [3, 4],
|
13
|
+
/\A\d+\z/ => [4, 4]
|
14
|
+
) |
|
15
|
+
one_of(%w[22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 38 39 72]) >> matched_split(
|
16
|
+
/\A\d{5}\z/ => [3, 2],
|
17
|
+
/\A\d{7}\z/ => [3, 4],
|
18
|
+
/\A\d{8}\z/ => [4, 4],
|
19
|
+
/\A\d{9}\z/ => [3, 3, 3]
|
20
|
+
) |
|
21
|
+
one_of('70') >> split(3, 3) |
|
22
|
+
one_of(%w[71 73 74 75 76 77]) >> matched_split(
|
23
|
+
/\A\d{6}\z/ => [3, 3],
|
24
|
+
/\A\d+\z/ => [3, 4]
|
25
|
+
) |
|
26
|
+
one_of('13') >> matched_split( # pager
|
27
|
+
/\A\d{3}\z/ => [3],
|
28
|
+
/\A\d+\z/ => [3, 3]
|
29
|
+
) |
|
30
|
+
one_of(%w[174 175]) >> matched_split( # satellite
|
31
|
+
/\A\d{2}\z/ => [2],
|
32
|
+
/\A\d+\z/ => [2, 3]
|
33
|
+
) |
|
34
|
+
one_of('177') >> matched_split( # satellite
|
35
|
+
/\A\d{2}\z/ => [2],
|
36
|
+
/\A\d+\z/ => [4, 4]
|
37
|
+
) |
|
38
|
+
one_of('178') >> matched_split( # satellite
|
39
|
+
/\A\d{3}\z/ => [3],
|
40
|
+
/\A\d+\z/ => [3, 2]
|
41
|
+
) |
|
42
|
+
one_of(%w[870]) >> split(3, 2) | # satellite
|
43
|
+
match(/\A(81\d|82\d|83\d|84\d|85\d|86\d|87\d|88\d|89\d)\d+\z/) >> matched_split( # mobile
|
44
|
+
/\A\d{6}\z/ => [3, 3],
|
45
|
+
/\A\d{7}\z/ => [3, 4],
|
46
|
+
/\A\d{8}\z/ => [4, 4],
|
47
|
+
/\A\d+\z/ => [4, 5]
|
48
|
+
) |
|
49
|
+
one_of(%w[9]) >> matched_split( # geographic
|
50
|
+
/\A\d{7}\z/ => [4, 3],
|
51
|
+
/\A\d+\z/ => [3, 3, 3]
|
52
|
+
) |
|
53
|
+
one_of(%w[4 5]) >> matched_split(
|
54
|
+
/\A\d{6}\z/ => [3, 3],
|
55
|
+
/\A\d+\z/ => [4, 4]
|
56
|
+
) |
|
57
|
+
one_of('6') >> matched_split(
|
58
|
+
/\A\d{7}\z/ => [3, 4],
|
59
|
+
/\A\d+\z/ => [4, 4]
|
60
|
+
) |
|
61
|
+
one_of('9') >> matched_split(
|
62
|
+
/\A\d{7}\z/ => [3, 4],
|
63
|
+
/\A\d+\z/ => [4, 5]
|
64
|
+
) |
|
65
|
+
fixed(2) >> split(4, 4)
|
54
66
|
end
|
55
|
-
|
@@ -39,7 +39,7 @@ ndcs_with_6_subscriber_digits = [
|
|
39
39
|
'45', # Naas, Kildare, Curragh
|
40
40
|
'51', # Waterford, Carrick-on-Suir, New Ross, Kilmacthomas
|
41
41
|
'61', # Limerick, Scariff
|
42
|
-
'91'
|
42
|
+
'91' # Galway, GOrt, Loughrea
|
43
43
|
]
|
44
44
|
|
45
45
|
ndcs_with_7_subscriber_digits = [
|
@@ -73,11 +73,10 @@ freefone = [
|
|
73
73
|
|
74
74
|
Phony.define do
|
75
75
|
country '353', trunk('0') |
|
76
|
-
one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
|
76
|
+
one_of(ndcs_with_7_subscriber_digits) >> split(3, 4) |
|
77
77
|
one_of(ndcs_with_5_subscriber_digits) >> split(5) |
|
78
78
|
one_of(ndcs_with_6_subscriber_digits) >> split(6) |
|
79
79
|
one_of(freefone) >> split(6) |
|
80
|
-
match(/^(8\d).+$/) >> split(3,4) | # mobile
|
81
|
-
fixed(3) >> split(6)
|
82
|
-
|
80
|
+
match(/^(8\d).+$/) >> split(3, 4) | # mobile
|
81
|
+
fixed(3) >> split(6) # Fallback
|
83
82
|
end
|
@@ -7,39 +7,39 @@
|
|
7
7
|
|
8
8
|
ndcs_1digit = [
|
9
9
|
'02', # Milan
|
10
|
-
'06'
|
10
|
+
'06' # Rome (including State of Vatican City) and Aprilia
|
11
11
|
]
|
12
12
|
|
13
13
|
ndcs_2digit = [
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
14
|
+
'010', # Genoa
|
15
|
+
'011', # Turin
|
16
|
+
'015', # Biella
|
17
|
+
'019', # Savona
|
18
|
+
'030', # Brescia
|
19
|
+
'031', # Como
|
20
|
+
'035', # Bergamo
|
21
|
+
'039', # Monza
|
22
|
+
'040', # Trieste
|
23
|
+
'041', # Venice
|
24
|
+
'045', # Verona
|
25
|
+
'049', # Padua
|
26
|
+
'050', # Pisa
|
27
|
+
'051', # Bologna
|
28
|
+
'055', # Florence
|
29
|
+
'059', # Modena
|
30
|
+
'070', # Cagliari
|
31
|
+
'071', # Ancona
|
32
|
+
'075', # Perugia
|
33
|
+
'079', # Sassari
|
34
|
+
'080', # Bari
|
35
|
+
'081', # Naples
|
36
|
+
'085', # Pescara
|
37
|
+
'089', # Salerno
|
38
|
+
'090', # Messina
|
39
|
+
'091', # Palermo
|
40
|
+
'092', # Agrigento
|
41
|
+
'095', # Catania
|
42
|
+
'099' # Taranto
|
43
43
|
]
|
44
44
|
|
45
45
|
ndcs_3digit = [
|
@@ -246,7 +246,7 @@ ndcs_3digit = [
|
|
246
246
|
'0982', # Paola
|
247
247
|
'0983', # Rossano
|
248
248
|
'0984', # Cosenza
|
249
|
-
'0985'
|
249
|
+
'0985' # Scalea
|
250
250
|
]
|
251
251
|
|
252
252
|
# All 3-- numbers are reserved for mobile phones according to
|
@@ -254,40 +254,41 @@ ndcs_3digit = [
|
|
254
254
|
# NOTE was:
|
255
255
|
# mobile = ('300'..'399').to_a
|
256
256
|
# but this was not frozen so easily.
|
257
|
-
mobile = %w
|
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
|
258
|
+
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
259
|
|
259
260
|
# Not exhaustive.
|
260
|
-
service = [
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
261
|
+
service = %w[
|
262
|
+
112
|
263
|
+
113
|
264
|
+
115
|
265
|
+
116
|
266
|
+
117
|
267
|
+
118
|
268
|
+
1515
|
269
|
+
1518
|
270
|
+
1530
|
270
271
|
]
|
271
272
|
|
272
273
|
# Not exhaustive. Unused below - just for info purposes.
|
273
|
-
free_of_charge_services = [
|
274
|
-
|
275
|
-
|
274
|
+
free_of_charge_services = %w[
|
275
|
+
800
|
276
|
+
803
|
276
277
|
]
|
277
278
|
|
278
279
|
Phony.define do
|
279
|
-
#
|
280
|
+
# NOTE: The 0 does not count towards NDC number length.
|
280
281
|
country '39', trunk('', normalize: false) |
|
281
|
-
one_of(*service) >> split(3,3) |
|
282
|
-
one_of(*mobile) >> split(3,4
|
282
|
+
one_of(*service) >> split(3, 3) |
|
283
|
+
one_of(*mobile) >> split(3, 4, -1..1) |
|
283
284
|
match(/^(800)\d{6}$/) >> split(6) | # 3-6, Special handling for 800 numbers.
|
284
285
|
match(/^(803)\d{3}$/) >> split(3) | # 3-3, Special handling for 803 numbers.
|
285
286
|
one_of(*ndcs_1digit) >> matched_split(
|
286
287
|
/\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],
|
290
|
-
/\A\d{9}\z/ => [4,5]
|
288
|
+
/\A\d{6}\z/ => [4, 2],
|
289
|
+
/\A\d{7}\z/ => [4, 3],
|
290
|
+
/\A\d{8}\z/ => [4, 4],
|
291
|
+
/\A\d{9}\z/ => [4, 5]
|
291
292
|
) |
|
292
293
|
one_of(*ndcs_2digit) >> matched_split(
|
293
294
|
/\A\d{4}\z/ => [4],
|
@@ -301,6 +302,6 @@ Phony.define do
|
|
301
302
|
/\A1\d{5}\z/ => [6],
|
302
303
|
/\A1\d{6}\z/ => [7],
|
303
304
|
/\A[^1]\d{4}\z/ => [5],
|
304
|
-
/\A[^1]\d{5}\z/ => [3,3]
|
305
|
+
/\A[^1]\d{5}\z/ => [3, 3]
|
305
306
|
)
|
306
307
|
end
|