phony 1.9.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/README.textile +1 -1
  2. data/lib/phony.rb +28 -15
  3. data/lib/phony/countries.rb +609 -210
  4. data/lib/phony/countries/austria.rb +6 -1
  5. data/lib/phony/countries/bangladesh.rb +55 -0
  6. data/lib/phony/countries/belarus.rb +130 -0
  7. data/lib/phony/countries/georgia.rb +91 -0
  8. data/lib/phony/countries/germany.rb +20 -6
  9. data/lib/phony/countries/india.rb +50 -0
  10. data/lib/phony/countries/indonesia.rb +50 -0
  11. data/lib/phony/countries/italy.rb +38 -67
  12. data/lib/phony/countries/japan.rb +412 -0
  13. data/lib/phony/countries/kyrgyzstan.rb +118 -0
  14. data/lib/phony/countries/latvia.rb +40 -0
  15. data/lib/phony/countries/libya.rb +114 -0
  16. data/lib/phony/countries/malaysia.rb +7 -5
  17. data/lib/phony/countries/moldova.rb +50 -0
  18. data/lib/phony/countries/montenegro.rb +27 -0
  19. data/lib/phony/countries/namibia.rb +35 -0
  20. data/lib/phony/countries/nepal.rb +71 -0
  21. data/lib/phony/countries/netherlands.rb +3 -2
  22. data/lib/phony/countries/pakistan.rb +119 -0
  23. data/lib/phony/countries/paraguay.rb +145 -0
  24. data/lib/phony/countries/russia_kazakhstan_abhasia_south_osetia.rb +6 -6
  25. data/lib/phony/countries/serbia.rb +34 -0
  26. data/lib/phony/countries/somali.rb +22 -0
  27. data/lib/phony/countries/south_korea.rb +1 -1
  28. data/lib/phony/countries/sweden.rb +1 -1
  29. data/lib/phony/countries/taiwan.rb +51 -0
  30. data/lib/phony/countries/tajikistan.rb +76 -0
  31. data/lib/phony/countries/turkmenistan.rb +73 -0
  32. data/lib/phony/countries/ukraine.rb +614 -0
  33. data/lib/phony/countries/uruguay.rb +51 -0
  34. data/lib/phony/countries/zimbabwe.rb +37 -0
  35. data/lib/phony/country.rb +41 -0
  36. data/lib/phony/country_codes.rb +45 -18
  37. data/lib/phony/dsl.rb +33 -7
  38. data/lib/phony/local_splitters/fixed.rb +14 -1
  39. data/lib/phony/local_splitters/regex.rb +12 -1
  40. data/lib/phony/national_code.rb +7 -3
  41. data/lib/phony/national_splitters/default.rb +13 -1
  42. data/lib/phony/national_splitters/dsl.rb +9 -7
  43. data/lib/phony/national_splitters/fixed.rb +6 -0
  44. data/lib/phony/national_splitters/none.rb +6 -0
  45. data/lib/phony/national_splitters/regex.rb +6 -0
  46. data/lib/phony/national_splitters/variable.rb +7 -1
  47. data/spec/lib/phony/countries_spec.rb +684 -16
  48. data/spec/lib/phony/local_splitters/regex_spec.rb +41 -0
  49. data/spec/lib/phony/validations_spec.rb +542 -10
  50. data/spec/lib/phony_spec.rb +20 -6
  51. metadata +29 -9
  52. data/lib/phony/validator.rb +0 -26
  53. data/lib/phony/validators.rb +0 -88
@@ -41,7 +41,12 @@ mobile = [
41
41
  '666',
42
42
  '667',
43
43
  '668',
44
- '669'
44
+ '669',
45
+ '676',
46
+ '680',
47
+ '681',
48
+ '688',
49
+ '699'
45
50
  ]
46
51
 
47
52
  service = [
@@ -0,0 +1,55 @@
1
+ # Bangladesh (People's Republic of)
2
+ # https://www.numberingplans.com
3
+
4
+ ndcs_with_3_subscriber_numbers = %w(
5
+ 3035 3036 3224 3424 3427 3529 3823 4027 4222 4225 4425 4525 4623 4653 4658
6
+ 5222 5323 5327 5526 6257 7022 7622 8023 8032 8332 8424 8528 8626 9423 9424
7
+ )
8
+
9
+ ndcs_with_4_subscriber_numbers = %w(
10
+ 3020 3022 3023 3024 3025 3026 3027 3028 3029 3032 3033 3034 3035 3036 3221 3222 3223 3225
11
+ 3322 3323 3324 3325 3326 3422 3824 4020 4029 4222 4223 4224 4225 4226 4227 4228
12
+ 4320 4322 4323 4324 4325 4326 4327 4328 4329 4523 4653 4654 4655 4657 4624 4626 4627
13
+ 4953 6024 6622 6655 7323 7324 7325 7327 7328 7522 7523 7524 7525 7526 7527 7528 7529
14
+ 8020 8022 8023 8024 8025 8026 8027 8028 8029 8032 8033 8424 8425 8426 8427 8522 8523 8524 8525 8526 8527
15
+ )
16
+
17
+ ndcs_with_5_subscriber_numbers = {
18
+ 2 => %w(51 71 81 91),
19
+ 3 => %w(321 331 341 351 361 371 381 441 448 421 451 461 471 481 491 468
20
+ 488 498 521 531 541 551 561 571 581 591 628 601 631 641 651 661 668
21
+ 691 731 741 751 761 771 781 791 831 841 851 861 871 921 931 941 951 981),
22
+ 4 => %w(3023 3024 3028 3223 3225 3324 3422 3425 3822
23
+ 4033 4226 4227 4322 4323 4326 4327 4328 4422 4423 4424 4426 4455 4624 4625 4626 4655 4656 4657 4823 4854 4922 4924 4925 4953
24
+ 5020 5023 5024 5028 5029 5224 5225 5227 5323 5325 5326 5329 5424 5426 5526 5653 5724 5826
25
+ 6023 6024 6222 6224 6225 6253 6254 6255 6323 6324 6327 6328 6423 6424 6524 6527 6623 6624 6652 6653 6654 6655
26
+ 6722 6723 6724 6725 6822 6823 6824 6825 6922 6923 6924 6925 6926
27
+ 7225 7227 7228 7229 7324 7326 7327 7329 7425 7426 7522 7525 7526 7528 7529 7724 7823 7825 7923
28
+ 8020 8022 8026 8029 8220 8222 8223 8224 8225 8226 8227 8229 8232 8325 8327 8328 8425 8426 8427 8522 8523 8524
29
+ 8622 8623 8624 8625 8626 8723 8725 8727
30
+ 9020 9022 9024 9025 9027 9028 9032 9033 9222 9223 9225 9226 9227 9228 9229 9232 9233 9424 9426 9428 9524 9525 9528 9529 9824 9827)
31
+ }
32
+
33
+ ndcs_with_6_subscriber_numbers = {2 => %w(31 41), 3 => %w(721 821)}
34
+
35
+ ndcs_with_7_subscriber_numbers = {1 => %w(2), 3 => %w(431)}
36
+
37
+ Phony.define do
38
+ country '880',
39
+ # some ndc have several subscriber number length.
40
+ match(/\A(#{ndcs_with_3_subscriber_numbers.join('|')})\d{3}\z/) >> split(3) |
41
+ match(/\A(#{ndcs_with_4_subscriber_numbers.join('|')})\d{4}\z/) >> split(4) |
42
+ match(/\A(#{ndcs_with_5_subscriber_numbers[4].join('|')})\d{5}\z/) >> split(5) |
43
+ #
44
+ one_of(ndcs_with_3_subscriber_numbers) >> split(3) |
45
+ one_of(ndcs_with_4_subscriber_numbers) >> split(4) |
46
+ one_of(ndcs_with_5_subscriber_numbers[2]) >> split(5) |
47
+ one_of(ndcs_with_5_subscriber_numbers[3]) >> split(5) |
48
+ one_of(ndcs_with_5_subscriber_numbers[4]) >> split(5) |
49
+ one_of(ndcs_with_6_subscriber_numbers[2]) >> split(6) |
50
+ one_of(ndcs_with_6_subscriber_numbers[3]) >> split(6) |
51
+ one_of(ndcs_with_7_subscriber_numbers[1]) >> split(7) |
52
+ one_of(ndcs_with_7_subscriber_numbers[3]) >> split(7) |
53
+ # match(/\A(1[15-9])\d{8}\z/) >> split(8) # mobile
54
+ fixed(2) >> split(8) # mobile
55
+ end
@@ -0,0 +1,130 @@
1
+ # Belarus
2
+ # http://www.eng.beltelecom.by/en/subscribers/phone-codes
3
+ # https://www.numberingplans.com
4
+
5
+ ndcs_with_5_subscriber_digits = %w(
6
+ 1511
7
+ 1512
8
+ 1513
9
+ 1514
10
+ 1515
11
+ 1562
12
+ 1563
13
+ 1564
14
+ 1591
15
+ 1592
16
+ 1593
17
+ 1594
18
+ 1595
19
+ 1596
20
+ 1597
21
+ 1631
22
+ 1632
23
+ 1633
24
+ 1641
25
+ 1642
26
+ 1643
27
+ 1644
28
+ 1645
29
+ 1646
30
+ 1647
31
+ 1651
32
+ 1652
33
+ 1655
34
+ 1713
35
+ 1714
36
+ 1715
37
+ 1716
38
+ 1717
39
+ 1718
40
+ 1719
41
+ 1770
42
+ 1771
43
+ 1772
44
+ 1774
45
+ 1775
46
+ 1776
47
+ 1792
48
+ 1793
49
+ 1794
50
+ 1795
51
+ 1796
52
+ 1797
53
+ 2130
54
+ 2131
55
+ 2132
56
+ 2133
57
+ 2135
58
+ 2136
59
+ 2137
60
+ 2138
61
+ 2139
62
+ 2151
63
+ 2152
64
+ 2153
65
+ 2154
66
+ 2155
67
+ 2156
68
+ 2157
69
+ 2158
70
+ 2159
71
+ 2230
72
+ 2231
73
+ 2232
74
+ 2233
75
+ 2234
76
+ 2235
77
+ 2236
78
+ 2237
79
+ 2238
80
+ 2239
81
+ 2240
82
+ 2241
83
+ 2242
84
+ 2243
85
+ 2244
86
+ 2245
87
+ 2246
88
+ 2247
89
+ 2248
90
+ 2330
91
+ 2332
92
+ 2333
93
+ 2334
94
+ 2336
95
+ 2337
96
+ 2339
97
+ 2340
98
+ 2342
99
+ 2344
100
+ 2345
101
+ 2346
102
+ 2347
103
+ 2350
104
+ 2353
105
+ 2354
106
+ 2355
107
+ 2356
108
+ 2357
109
+ )
110
+
111
+ ndcs_with_6_subscriber_digits = %w(152 154 162 163 165 174 176 177 212 214 216 222 225 232 236 602)
112
+
113
+ ndcs_with_7_subscriber_digits = %w(17 25 29 33 44)
114
+
115
+ Phony.define do
116
+ country '375',
117
+ one_of(ndcs_with_5_subscriber_digits) >> split(5) |
118
+ one_of(ndcs_with_6_subscriber_digits) >> split(6) |
119
+ one_of(ndcs_with_7_subscriber_digits) >> split(7) |
120
+ # not available from abroad
121
+ one_of(%w(600)) >> split(3) |
122
+ one_of(%w(606 777 801 803 805 810 902)) >> split(7) |
123
+ one_of(%w(820)) >> split(8) |
124
+ # Non-geographic number - Home country direct service
125
+ # Assigned to Beltelecom - not available from abroad
126
+ match(/\A(800)\d{3}\z/) >> split(3) |
127
+ match(/\A(800)\d{4}\z/) >> split(4) |
128
+ match(/\A(800)\d{7}\z/) >> split(7)
129
+ end
130
+
@@ -0,0 +1,91 @@
1
+ # Georgia
2
+ # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
+ # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=GE
4
+
5
+ ndcs_with_7_subscirber_digits = %w(32)
6
+ ndcs_with_6_subscirber_digits = %w(
7
+ 341
8
+ 342
9
+ 344
10
+ 345
11
+ 346
12
+ 347
13
+ 348
14
+ 349
15
+ 350
16
+ 351
17
+ 352
18
+ 353
19
+ 354
20
+ 355
21
+ 356
22
+ 357
23
+ 358
24
+ 359
25
+ 360
26
+ 361
27
+ 362
28
+ 363
29
+ 364
30
+ 365
31
+ 366
32
+ 367
33
+ 368
34
+ 369
35
+ 370
36
+ 371
37
+ 372
38
+ 373
39
+ 374
40
+ 410
41
+ 411
42
+ 412
43
+ 413
44
+ 414
45
+ 415
46
+ 416
47
+ 417
48
+ 418
49
+ 419
50
+ 422
51
+ 423
52
+ 424
53
+ 425
54
+ 426
55
+ 427
56
+ 431
57
+ 432
58
+ 433
59
+ 434
60
+ 435
61
+ 436
62
+ 437
63
+ 439
64
+ 442
65
+ 443
66
+ 444
67
+ 445
68
+ 446
69
+ 447
70
+ 448
71
+ 472
72
+ 473
73
+ 474
74
+ 479
75
+ 491
76
+ 492
77
+ 493
78
+ 494
79
+ 495
80
+ 496
81
+ 497
82
+ )
83
+
84
+ Phony.define do
85
+ country '995',
86
+ one_of('220') >> split(3,2) |
87
+ one_of(%w(514 550 551 555 557 558 568 571 574 577 578 579 591 592 593 595 596 597 598 599 770 790)) >> split(3,3) | # mobile
88
+ one_of(ndcs_with_6_subscirber_digits) >> split(3,3) |
89
+ one_of(ndcs_with_7_subscirber_digits) >> split(3,4) |
90
+ fixed(3) >> split(3,3)
91
+ end
@@ -1,9 +1,9 @@
1
- # Germany uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
1
+ # Germany uses a variable-length ndc code, thus we use a separate file to not let countries.rb explode.
2
2
  #
3
3
  # Note: Germany uses a variable ndc format from length 2 to 5.
4
4
  #
5
5
 
6
- ndcs = [
6
+ ndcs2and3 = [
7
7
  '10', # Call-By-Call
8
8
  '11', # formerly Value Added Services
9
9
  '13', # Voting and Lottery Numbers
@@ -104,8 +104,10 @@ ndcs = [
104
104
  '971', # Bad Kissingen
105
105
  '981', # Ansbach
106
106
  '991', # Deggendorf
107
+ ]
107
108
  # 4-digit NDCs from now on.
108
109
  #
110
+ ndcs4 = [
109
111
  '2041',
110
112
  '2043',
111
113
  '2045',
@@ -4065,9 +4067,21 @@ service = [
4065
4067
  '9009',
4066
4068
  ]
4067
4069
 
4070
+ # Note:
4071
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_Germany
4072
+ # http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000510001PDFE.pdf
4073
+ # "Numbers assigned in the past, which are generally grandfathered, may be as short as five digits."
4074
+ #
4075
+
4068
4076
  Phony.define do
4069
- country '49', one_of(service) >> split(3,10) |
4070
- match(/^(1[567]\d)\d*$/) >> split(3,10) | # Mobile
4071
- one_of(ndcs) >> split(3,10) |
4072
- fixed(5) >> split(3,10)
4077
+ country '49', one_of(service) >> split(3,0) |
4078
+ one_of('176') >> split(3,5) |
4079
+ one_of('1609') >> split(3,5) |
4080
+ one_of('1521', '1529', '1570', '1575', '1579') >> split(3,4) |
4081
+ match(/\A(1[57]\d)\d*\z/) >> split(3,4) |
4082
+ match(/\A(16\d)\d*\z/) >> split(3,5) |
4083
+ one_of(ndcs2and3) >> split(3,5) |
4084
+ one_of(ndcs4) >> split(3,4) |
4085
+ fixed(5) >> split(3,3)
4086
+
4073
4087
  end
@@ -0,0 +1,50 @@
1
+ # Indian phone numbers.
2
+ #
3
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_India
4
+ # http://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
5
+ #
6
+ # http://www.dot.gov.in/numbering_plan/numberplanindex.htm
7
+ # http://www.dot.gov.in/numbering_plan/nnp2003.pdf
8
+ # http://www.dot.gov.in/numbering_plan/2012/msc_codes_28092012.pdf
9
+ #
10
+ #
11
+
12
+
13
+ sdca_with_2_digits = %w{ 11 20 22 33 39 40 44 50 60 70 79 80 }
14
+
15
+ sdca_with_3_digits = %w{
16
+ 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
17
+ 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
18
+ 326 341 342 343 353 354 360 361 364 369 370 373 374 376 381 385 389
19
+ 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
20
+ 512 515 532 535 542 548 551 562 565 572 581 595
21
+ 612 621 631 641 651 657 661 663 671 674 680
22
+ 712 721 724 731 733 734 744 751 755 761 747 788
23
+ 816 820 821 824 831 832 836 861 863 866 870 877 878 883 884 891
24
+
25
+
26
+ 140
27
+ 240 249 254 260 270 272
28
+ 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
29
+ 412 419 430 438 439 450 453 458 459 460 464 466 467 468
30
+ 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
31
+ 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
32
+ 730 735 738 740 750 787 789
33
+ 812 814 829 843 860 879 880 887 889 890 895 897 898 899
34
+
35
+ }
36
+
37
+
38
+
39
+ mobile = %w{ 91 92 93 94 97 98 99}
40
+
41
+ pagers = %w{ 96 }
42
+
43
+ Phony.define do
44
+ country '91', one_of(sdca_with_3_digits) >> split(3, 2, 2) |
45
+ one_of(sdca_with_2_digits) >> split(3, 2, 3) |
46
+ one_of(mobile) >> split(3, 2, 3) |
47
+ one_of(pagers) >> split(2, 3, 3) |
48
+ fixed(4) >> split(3, 3) # fallback (4 digit sdca)
49
+
50
+ end
@@ -0,0 +1,50 @@
1
+ # Indonesia (Republic of)
2
+ # http://www.numberingplans.com/?page=dialling&sub=areacodes
3
+ # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=ID
4
+
5
+ Phony.define do
6
+ country '62',
7
+ one_of('21') >> matched_split(
8
+ /\A\d{5}\z/ => [3,2],
9
+ /\A\d+\z/ => [4,4]) |
10
+ one_of(%w(22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 38 39 72)) >> matched_split(
11
+ /\A\d{5}\z/ => [3,2],
12
+ /\A\d+\z/ => [3,4]) |
13
+ one_of('70') >> split(3,3) |
14
+ one_of(%w(71 73 74 75 76 77)) >> matched_split(
15
+ /\A\d{6}\z/ => [3,3],
16
+ /\A\d+\z/ => [3,4]) |
17
+ one_of('13') >> matched_split( # pager
18
+ /\A\d{3}\z/ => [3],
19
+ /\A\d+\z/ => [3,3]) |
20
+ one_of(%w(174 175)) >> matched_split( # satellite
21
+ /\A\d{2}\z/ => [2],
22
+ /\A\d+\z/ => [2,3]) |
23
+ one_of('177') >> matched_split( # satellite
24
+ /\A\d{2}\z/ => [2],
25
+ /\A\d+\z/ => [4,4]) |
26
+ one_of('178') >> matched_split( # satellite
27
+ /\A\d{3}\z/ => [3],
28
+ /\A\d+\z/ => [3,2]) |
29
+ match(/\A(81\d|85\d|86\d|88\d)\d+\z/) >> matched_split( # mobile
30
+ /\A\d{6}\z/ => [3,3],
31
+ /\A\d+\z/ => [4,4]) |
32
+ match(/\A(82\d|83\d)\d+\z/) >> split(3,3) | # mobile
33
+ one_of(%w(870)) >> split(3,2) | # satellite
34
+ one_of(%w(877 878)) >> split(3,3) | # mobile
35
+ one_of(%w(9)) >> matched_split( # geographic
36
+ /\A\d{7}\z/ => [4,3],
37
+ /\A\d+\z/ => [3,3,3]) |
38
+ one_of(%w(4 5)) >> matched_split(
39
+ /\A\d{6}\z/ => [3,3],
40
+ /\A\d+\z/ => [4,4]) |
41
+ one_of('6') >> matched_split(
42
+ /\A\d{7}\z/ => [3,4],
43
+ /\A\d+\z/ => [4,4]) |
44
+ one_of('9') >> matched_split(
45
+ /\A\d{7}\z/ => [3,4],
46
+ /\A\d+\z/ => [4,5]) |
47
+ fixed(2) >> split(4,4)
48
+
49
+ end
50
+
@@ -91,58 +91,54 @@ ndcs = [
91
91
  '099', # Taranto
92
92
  ]
93
93
 
94
+
94
95
  mobile = [
95
96
  '310',
96
- '31100',
97
- '31101',
98
- '31102',
99
- '31103',
100
- '31104',
101
- '31105',
97
+ '311',
102
98
  '313',
103
99
  '319',
104
- ('3200'..'3209').to_a,
100
+ '320',
105
101
  '322',
106
- ('3230'..'3239').to_a,
107
- ('3270'..'3279').to_a,
108
- ('3280'..'3289').to_a,
109
- ('3290'..'3299').to_a,
110
- ('3300'..'3309').to_a,
102
+ '323',
103
+ '327',
104
+ '328',
105
+ '329',
106
+ '330',
111
107
  '331',
112
- ('3330'..'3339').to_a,
113
- ('3340'..'3349').to_a,
114
- ('3350'..'3359').to_a,
115
- ('3360'..'3369').to_a,
116
- ('3370'..'3379').to_a,
117
- ('3380'..'3389').to_a,
118
- ('3390'..'3399').to_a,
119
- ('3400'..'3409').to_a,
108
+ '333',
109
+ '334',
110
+ '335',
111
+ '336',
112
+ '337',
113
+ '338',
114
+ '339',
115
+ '340',
120
116
  '341',
121
- ('3430'..'3439').to_a,
117
+ '343',
122
118
  '345',
123
- ('3460'..'3469').to_a,
124
- ('3470'..'3479').to_a,
125
- ('3480'..'3489').to_a,
126
- ('3490'..'3499').to_a,
119
+ '346',
120
+ '347',
121
+ '348',
122
+ '349',
127
123
  '350',
128
- ('3600'..'3609').to_a,
124
+ '360',
129
125
  '361',
130
126
  '362',
131
- ('3630'..'3639').to_a,
132
- ('3660'..'3669').to_a,
133
- ('3680'..'3689').to_a,
127
+ '363',
128
+ '366',
129
+ '368',
134
130
  '370',
135
131
  '373',
136
132
  '377',
137
- ('3800'..'3809').to_a,
138
- ('3880'..'3889').to_a,
139
- ('3890'..'3899').to_a,
140
- ('3900'..'3909').to_a,
141
- ('3910'..'3919').to_a,
142
- ('3920'..'3929').to_a,
143
- ('3930'..'3939').to_a,
133
+ '380',
134
+ '388',
135
+ '389',
136
+ '390',
137
+ '391',
138
+ '392',
139
+ '393',
144
140
  '397'
145
- ].flatten
141
+ ]
146
142
 
147
143
  service = [ # Not exhaustive.
148
144
  '112',
@@ -155,34 +151,9 @@ service = [ # Not exhaustive.
155
151
  '1530'
156
152
  ]
157
153
 
158
- # TODO Normalize!
159
- #
160
- # country '39', one_of(*service) >> split(3,3) |
161
- # one_of(*mobile) >> split(3,4) |
162
- # one_of(*ndcs, :max_length => 3) >> split(3,4)
163
-
164
- handlers = []
165
- handlers << Phony::NationalCode.new(
166
- Phony::NationalSplitters::Variable.new(nil, service),
167
- Phony::LocalSplitters::Fixed.instance_for([4, 4]),
168
- false
169
- )
170
- handlers << Phony::NationalCode.new(
171
- Phony::NationalSplitters::Variable.new(nil, mobile),
172
- Phony::LocalSplitters::Fixed.instance_for([3, 4]),
173
- false
174
- )
175
- handlers << Phony::NationalCode.new(
176
- Phony::NationalSplitters::Variable.new(nil, ndcs_2digit),
177
- Phony::LocalSplitters::Fixed.instance_for([4, 4]),
178
- false
179
- )
180
- handlers << Phony::NationalCode.new(
181
- Phony::NationalSplitters::Variable.new(3, ndcs),
182
- Phony::LocalSplitters::Fixed.instance_for([3, 4]),
183
- false
184
- )
185
-
186
154
  Phony.define do
187
- country '39', Phony::Country.new(*handlers)
188
- end
155
+ country '39', one_of(*service) >> trunk('0', normalize: false) >> split(3,3) |
156
+ one_of(*mobile) >> trunk('0', normalize: false) >> split(3,4) |
157
+ one_of(*ndcs_2digit) >> trunk('0', normalize: false) >> split(4,4) |
158
+ one_of(*ndcs, :max_length => 3) >> trunk('0', normalize: false) >> split(3,4)
159
+ end