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
@@ -1,20 +1,23 @@
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
15
18
  34940 34948 34949 34992 34993 34994 34995 34996 34997 35130 35131 35133 35134 35138 35139 35140 35141 35142 35143
16
19
  35144 35145 35146 35147 35148 35149 35150 35151 35152 35153 35154 35155 35156 35157 35158 35159 35160 35161 35163
17
- 35164 35165 35166 35167 35168 35169 35190 35191 3522 35230 35231 35232 35233 35234 35235 35236 35237 35238 35239
20
+ 35164 35165 35166 35167 35168 35169 35190 35191 35230 35231 35232 35233 35234 35235 35236 35237 35238 35239
18
21
  35240 35241 35242 35243 35244 35245 35247 35248 35249 35251 35252 35253 35256 35257 35330 35331 35332 35333 35334
19
22
  35335 35336 35337 35338 35339 35341 35342 35344 35345 35346 35347 35348 35349 35351 35352 35354 35355 35356 35357
20
23
  35358 35359 35361 35362 35363 35364 35365 35366 35367 35368 35379 38141 38150 38151 38152 38153 38154 38155 38156
@@ -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,21 +108,26 @@ 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 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 980 981 982 983 984 985 987 988
116
- 989 997
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
120
129
  country '7',
130
+ # trunk('8', normalize: true, split: true) | # TODO Figure out if this is the way to go.
121
131
  trunk('8', normalize: false) |
122
132
  one_of(ndcs_with_5_subscriber_digits) >> split(1, 2, 2) |
123
133
  one_of(ndcs_with_6_subscriber_digits) >> split(2, 2, 2) |
@@ -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
@@ -11,6 +13,7 @@ ndcs_with_7_subscriber_digits = [
11
13
  '17', # Southern regions like Asir, Al-Baha, Jizan, Najran & Khamis Mushait
12
14
  '50', # Mobile: STC
13
15
  '51', # Mobile: Trunking services
16
+ '52', # Mobile: Reserved for future use
14
17
  '53', # Mobile: STC
15
18
  '54', # Mobile: Mobily
16
19
  '55', # Mobile: STC
@@ -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,6 +1,9 @@
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
6
+ # https://en.wikipedia.org/wiki/Telecommunications_in_Somaliland#Telesom
4
7
  country '252',
5
8
  one_of('88216') >> split(3) | # Thuraya Satellite Telecommunications Company
6
9
  one_of(%w(1034 1043)) >> split(3,2) | # Hortel
@@ -10,6 +13,7 @@ Phony.define do
10
13
  one_of(%w(201 204 208 210 214)) >> split(2,2) | # Telcom Somalia
11
14
  one_of(%w(500 501 502 503 504 505 506 507 508 509)) >> split(3,2) | # mobile NationLink Telecom
12
15
  one_of(%w(523 525 526)) >> split(2,2) | # Netco
16
+ match(/\A(61|62|63|64|65|66|67|68|69|90)\d{7}\z/) >> split(3,4) | # mobile Hormuud, Somtel Mogadishu, Telesom, Hormuud, Somtel, Somtel Puntland, Nationlink Mogadishu, Nationlink Mogadishu, Nationlink, Golis
13
17
  one_of(%w(642 643 644 648 649)) >> split(2,2) | # Galcom
14
18
  one_of(%w(33 51 52 54 55 56 57 58 59 68 71 76 78 79 88)) >> split(3,2) |
15
19
  match(/\A(67)\d{5}\z/) >> split(3,2) | # Golis Telecom Somalia
@@ -19,4 +23,4 @@ Phony.define do
19
23
  one_of(%w(67 69)) >> split(4,3) | # mobile NationLink Telecom
20
24
  one_of('1') >> split(3,3) |
21
25
  fixed(1) >> split(3,3)
22
- end
26
+ end
@@ -1,22 +1,29 @@
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
6
+ # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=KR
4
7
  #
5
8
 
6
9
  # TODO 4-digit services, like "unreasonable infringement of livelihood report" number :)
7
10
  #
8
11
 
9
- 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 }
10
- # mobile = ('10'..'19').to_a # Note: Mobile not used as it is (for now) handled by the fixed catchall.
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)
11
17
 
12
18
  Phony.define do
13
19
  country '82',
14
20
  trunk('0') |
15
21
  match(/^(#{special.join("|")})$/) >> split(3,3) | # Special actually don't need to be split – but better err.
16
- one_of('2') >> split(4,4) | # Seoul, also includes "services".
17
- fixed(2) >> split(4,4) # Catchall.
18
-
19
- # See above.
20
- #
21
- # one_of(*mobile) >> split(4,4) |
22
- end
22
+ one_of(*mobile) >> split(4,4) |
23
+ one_of('2') >> matched_split(
24
+ /\A\d{7}\z/ => [3,4],
25
+ /\A\d{8}\z/ => [4,4]) | # Seoul, also includes "services".
26
+ fixed(2) >> matched_split(
27
+ /\A\d{7}\z/ => [3,4],
28
+ /\A\d{8}\z/ => [4,4]) # Rest of cities
29
+ end
@@ -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.
@@ -25,7 +27,6 @@ ndcs = [
25
27
  '35', # Halmstad
26
28
  '36', # Jönköping-Huskvarna
27
29
  '40', # Malmö
28
- '417', # Tomelilla
29
30
  '42', # Helsingborg-Höganäs
30
31
  '44', # Kristianstad
31
32
  '46', # Lund
@@ -33,8 +34,7 @@ ndcs = [
33
34
  '60', # Sundsvall-Timrå
34
35
  '63', # Östersund
35
36
  '90', # Umeå
36
- '522', # Uddevalla
37
- '77', #Dalarna
37
+ '77', # Dalarna
38
38
  ]
39
39
  mobile = [
40
40
  '70', # Mobile
@@ -45,24 +45,36 @@ mobile = [
45
45
  '76', # Mobile
46
46
  '79', # Mobile
47
47
  ]
48
- service = [
49
- '99', # Premium Rate
50
- '112', # Emergency Service
51
- '116', # Psychological Help
52
- '118', # Number enquiries
53
- '900', # Premium Rate
54
- '939', # Premium Rate
55
- '944', # Premium Rate
56
- '1177', # Health Care Advice
57
- '11414', # Police
48
+ services = [
49
+ '112', # Emergency Service
50
+ '1177', # Health Care Advice
51
+ '11414', # Police
52
+ ]
53
+ service_ndcs = [
54
+ '99', # Premium Rate
55
+ '900', # Premium Rate
56
+ '939', # Premium Rate
57
+ '944', # Premium Rate
58
+ ]
59
+ three_digit_service = [
60
+ '116', # Psychological Help (116 xxx)
61
+ '118', # Number enquiries (118 xxx)
58
62
  ]
59
63
 
60
64
  Phony.define do
61
65
  country '46',
62
66
  trunk('0') |
63
- one_of(service) >> split(3,3) |
64
- one_of(ndcs + mobile) >> matched_split(
65
- /^\d{5}$/ => [3, 2], /^\d{6}$/ => [2, 2, 2], /^\d{7}$/ => [3, 2, 2], /^\d{8}$/ => [3, 2, 3]
67
+ match(/^(#{services.join('|')})$/) >> split(0) |
68
+ one_of(service_ndcs) >> split(3,3) |
69
+ match(/^(#{three_digit_service.join('|')})\d{3}$/) >> split(3) |
70
+ one_of(ndcs + mobile) >> matched_split(
71
+ /^\d{5}$/ => [3, 2],
72
+ /^\d{6}$/ => [2, 2, 2],
73
+ /^\d{7}$/ => [3, 2, 2],
74
+ /^\d{8}$/ => [3, 2, 3]
66
75
  ) |
67
- fixed(3) >> split(3,3,2) # catchall
76
+ fixed(3) >> matched_split(
77
+ /^\d{5}$/ => [3, 2],
78
+ /^\d{6}$/ => [2, 2, 2]
79
+ )
68
80
  end
@@ -1,52 +1,28 @@
1
- # Taiwan
2
- # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
- #
4
-
5
- ndcs_with_8_subscriber_numbers = %w(1 2)
6
-
7
- ndcs_with_7_subscriber_numbers = %w(3 4 5 6 7 8)
1
+ # frozen_string_literal: true
8
2
 
9
- ndcs_with_6_subscriber_numbers = %w(
10
- 33
11
- 34
12
- 35
13
- 36
14
- 37
15
- 38
16
- 39
17
- 42
18
- 43
19
- 44
20
- 45
21
- 46
22
- 47
23
- 48
24
- 49
25
- 55
26
- 56
27
- 62
28
- 66
29
- 67
30
- 69
31
- 88
32
- 89
33
- )
34
-
35
- ndcs_with_5_subscriber_numbers = %w(823 826 827)
3
+ # Taiwan
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
5
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Taiwan
36
6
 
37
7
  Phony.define do
38
8
  country '886',
39
9
  trunk('0') |
40
- one_of(ndcs_with_5_subscriber_numbers) >> split(3,2) |
41
- match(/\A(6\d\d)\d{7}\z/) >> split(3,4) | # geographic ; Taipei
42
- one_of(%w(412)) >> split(4) | # VoIP telephony ; Taichung
43
- one_of(ndcs_with_6_subscriber_numbers) >> split(3,3) |
44
- one_of(%w(18)) >> split(3,3) | # freephone
45
- one_of(%w(90 91 92 93 95 96 97 98)) >> matched_split(
46
- /\A\d{6}\z/ => [3,3],
47
- /\A\d+\z/ => [3,4]) | # mobile
48
- one_of(%w(60 70 94 95 99)) >> split(3,3) | # pager
49
- one_of(ndcs_with_7_subscriber_numbers) >> split(3,4) |
50
- one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
51
- fixed(2) >> split(3,3)
10
+ match(/\A(826)\d{5}\z/) >> split(1,4) | # 烏坵, start with 0826, plus 5 digits
11
+ match(/\A(836)\d{5}\z/) >> split(1,4) | # 馬祖, start with 0836, plus 5 digits
12
+ match(/\A(82)\d{6}\z/) >> split(2,4) | # 金門, start with 082, plus 6 digits
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
15
+ match(/\A(8)\d{7}\z/) >> split(3,4) | # 屏東, start with 08, plus 7 digits
16
+ match(/\A(49)\d{7}\z/) >> split(3,4) | # 南投, start with 049, plus 7 digits
17
+ one_of(%w(4)) >> matched_split(
18
+ /\A\d{7}\z/ => [3,4], # 彰化, start with 04, plus 7 digits
19
+ /\A\d+\z/ => [4,4])| # 臺中, start with 04, plus 8 digits
20
+ match(/\A(37)\d{6}\z/) >> split(2,4) | # 苗栗, start with 037, plus 6 digits
21
+ match(/\A(3)\d{7}\z/) >> split(3,4) | # 桃園 新竹 花蓮 宜蘭, start with 03, plus 7 digits
22
+ match(/\A(5)\d{7}\z/) >> split(3,4) | # 嘉義 雲林, start with 05, plus 7 digits
23
+ match(/\A(6)\d{7}\z/) >> split(3,4) | # 臺南 澎湖, start with 06, plus 7 digits
24
+ match(/\A(7)\d{7}\z/) >> split(3,4) | # 高雄, start with 07, plus 7 digits
25
+ match(/\A(2)\d{8}\z/) >> split(4,4) | # 臺北, start with 02, plus 8 digits
26
+ match(/\A(9\d\d)\d{6}\z/) >> split(3,3) | # mobile phone, start with 09, plus 8 digits, but local usually show 4-3-3.
27
+ fixed(2) >> split(4,4) # fallback unknown
52
28
  end
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Ukraine
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
 
@@ -28,6 +30,7 @@ ndcs_with_7_subscriber_numbers = %w(
28
30
  64
29
31
  65
30
32
  69
33
+ 72
31
34
  )
32
35
 
33
36
  ndcs_with_6_subscriber_numbers = %w(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The United Kingdom uses a variable-length NDC code,
2
4
  # thus we use a separate file to not let countries.rb explode.
3
5
  #
@@ -16,9 +18,10 @@
16
18
  mobile_ndc = [
17
19
  # Mobile [4+6].
18
20
  #
19
- *('7100'..'7599'),
21
+ # NOTE We're explicitly denoting this as dynamic strings cannot be frozen.
22
+ *%w(7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599),
20
23
  '7624', # Isle of Man
21
- *('7700'..'7999')
24
+ *%w(7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999)
22
25
  ]
23
26
 
24
27
  two_digit_ndc = [
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Uruguay (Eastern 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=UY
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Vietnamese phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Vietnam
@@ -8,122 +10,122 @@
8
10
  #
9
11
 
10
12
  ndcs_with_7_subscriber_digits = [
11
- '20', # Lào Cai Province
13
+ '203', # Quảng Ninh Province
14
+ '204', # Bắc Giang (From 15 April 2017)
15
+ '205', # Lạng Sơn Province
16
+ '206', # Cao Bằng Province
17
+ '207', # Tuyên Quang Province
18
+ '208', # Thái Nguyên Provine
19
+ '209', # Bắc Kạn Province
12
20
  '210', # Phú Thọ Province
13
21
  '211', # Vĩnh Phúc Province
14
- '218', # Hòa Bình Province (18 before 24 Nov 2007)
15
- '219', # Giang Province (19 before 24 Nov 2007)
16
- '22', # Sơn La Province
17
- '230', # Điện Biên Province (23 before 24 Nov 2007)
18
- '231', # Lai Châu Province (23 before 24 Nov 2007)
19
- '240', # Bắc Giang Province
20
- '241', # Bắc Ninh Province
21
- '25', # Lạng Sơn Province
22
- '26', # Cao Bằng Province
23
- '27', # Tuyên Quang Province
24
- '280', # Thái Nguyên Province
25
- '281', # Bắc Kạn Province
26
- '29', # Yên Bái Province
27
-
28
- '30', # Ninh Bình Province
29
- '31', # Hai Phong city
30
- '320', # Hải Dương Province
31
- '321', # Hưng Yên Province
32
- '33', # Quảng Ninh Province
33
- '350', # Nam Định Province
34
- '351', # Nam Province
35
- '36', # Thái Bình Province
36
- '37', # Thanh Hóa Province
37
- '38', # Nghệ An Province
38
- '39', # Tĩnh Province
39
-
40
- '500', # Đắk Lắk Province (50 before 24 Nov 2007)
41
- '501', # Đắk Nông Province (50 before 24 Nov 2007)
42
- '510', # Quảng Nam Province
43
- '511', # Da Nang city
44
- '52', # Quảng Bình Province
45
- '53', # Quảng Trị Province
46
- '54', # Thừa Thiên–Huế Province
47
- '55', # Quảng Ngãi Province
48
- '56', # Bình Định Province
49
- '57', # Phú Yên Province
50
- '58', # Khánh Hòa Province
51
- '59', # Gia Lai Province
52
-
53
- '60', # Kon Tum Province
54
- '61', # Đồng Nai Province
55
- '62', # Bình Thuận Province
56
- '63', # Lâm Đồng Province
57
- '64', # Rịa–Vũng Tàu Province
58
- '650', # Bình Dương Province
59
- '651', # Bình Phước Province
60
- '66', # Tây Ninh Province
61
- '67', # Đồng Tháp Province
62
- '68', # Ninh Thuận Province
63
-
64
- '70', # Vĩnh Long Province
65
- '710', # Cần Thơ city (71 before 24 Nov 2007)
66
- '711', # Hậu Giang Province (71 before 24 Nov 2007)
67
- '72', # Long An Province
68
- '73', # Tiền Giang Province
69
- '74', # Trà Vinh Province
70
- '75', # Bến Tre Province
71
- '76', # An Giang Province
72
- '77', # Kiên Giang Province
73
- '780', # Cà Mau Province
74
- '781', # Bạc Liêu Province
75
- '79' # Sóc Trăng Province
22
+ '212', # Sơn La Province
23
+ '213', # Lai Châu
24
+ '214', # Lào Cai Province
25
+ '215', # Điện Biên Province
26
+ '216', # Yên Bái Province
27
+ '218', # Hòa Bình Province
28
+ '219', # Giang Province
29
+ '220', # Hải Dương Province
30
+ '221', # Hưng Yên Province
31
+ '222', # Bắc Ninh Province
32
+ '225', # Hải Phòng Province
33
+ '226', # Nam Province
34
+ '227', # Thái Bình Province
35
+ '228', # Nam Định Province
36
+ '229', # Ninh Bình Province
37
+ '232', # Quảng Bình Province
38
+ '233', # Quảng Trị Province
39
+ '234', # Thừa Thiên Huế Province
40
+ '235', # Quảng Nam Province
41
+ '236', # Đà Nẵng Province
42
+ '237', # Thanh Hóa Province
43
+ '238', # Nghệ An Province
44
+ '239', # Tĩnh Province
45
+ '251', # Đồng Nai Province
46
+ '252', # Bình Thuận Province
47
+ '254', # Bà Rịa Vũng Tàu Province
48
+ '255', # Quảng Ngãi Province
49
+ '256', # Bình Định Province
50
+ '257', # Phú Yên Province
51
+ '258', # Khánh Hòa Province
52
+ '259', # Ninh Thuận Province
53
+ '260', # Kon Tum Province
54
+ '261', # Đăk Nông Province
55
+ '262', # Đăk Lăk Province
56
+ '263', # Lâm Đồng Province
57
+ '269', # Gia Lai Province
58
+ '270', # Vĩnh Long Province
59
+ '271', # Bình Phước Province
60
+ '272', # Long An Province
61
+ '273', # Tiền Giang Province
62
+ '274', # Bình Dương Province
63
+ '275', # Bến Tre Province
64
+ '276', # Tây Ninh Province
65
+ '277', # Đồng Tháp Province
66
+ '290', # Mau Province
67
+ '291', # Bạc Liêu Province
68
+ '292', # Cần Thơ Province
69
+ '293', # Hậu Giang Province
70
+ '294', # Trà Vinh Province
71
+ '296', # An Giang Province
72
+ '297', # Kiên Giang Province
73
+ '299', # Sóc Trăng Province
76
74
  ]
77
75
 
78
76
  ndcs_with_8_subscriber_digits = [
79
- '4', # Hanoi
80
- '8' # Ho Chi Minh City
77
+ '4', # Hà Nội Province
78
+ '24', # Nội Province
79
+ '28', # Hồ Chí Minh Province
80
+ '8', # Hồ Chí Minh Province
81
81
  ]
82
82
 
83
83
  mobile = [
84
+ '32', # Viettel Mobile
85
+ '33', # Viettel Mobile
86
+ '34', # Viettel Mobile
87
+ '35', # Viettel Mobile
88
+ '36', # Viettel Mobile
89
+ '37', # Viettel Mobile
90
+ '38', # Viettel Mobile
91
+ '39', # Viettel Mobile
92
+ '52', # Vietnammobile
93
+ '56', # Vietnamobile
94
+ '58', # Vietnamobile (previously known as HT Mobile)
95
+ '59', # GTel (traded as Beeline)
96
+ '70', # MobiFone
97
+ '76', # MobiFone
98
+ '77', # MobiFone
99
+ '78', # MobiFone
100
+ '79', # MobiFone
101
+ '81', # Vinaphone
102
+ '82', # Vinaphone
103
+ '83', # Vinaphone
104
+ '84', # Vinaphone
105
+ '85', # Vinaphone
106
+ '86', # Viettel
107
+ '87', # Itelecom
108
+ '88', # Vinaphone
109
+ '89', # MobiFone,
84
110
  '90', # MobiFone
85
111
  '91', # Vinaphone
86
112
  '92', # Vietnamobile (previously known as HT Mobile)
87
113
  '93', # MobiFone
88
114
  '94', # Vinaphone
89
- '95', # S-Fone
90
115
  '96', # previously EVN Telecom, now Viettel Mobile
91
116
  '97', # Viettel Mobile
92
117
  '98', # Viettel Mobile
93
- '996', # Gmobile (traded as Beeline)
94
- '997', # Gmobile (traded as Beeline)
95
- '998', # Indochina Telecom
96
- '999', # Indochina Telecom
97
- '120', # MobiFone
98
- '121', # MobiFone
99
- '122', # MobiFone
100
- '123', # Vinaphone
101
- '124', # Vinaphone
102
- '125', # Vinaphone
103
- '126', # MobiFone
104
- '127', # Vinaphone
105
- '128', # MobiFone
106
- '129', # Vinaphone
107
- '163', # Viettel Mobile
108
- '164', # Viettel Mobile
109
- '165', # Viettel Mobile
110
- '166', # Viettel Mobile
111
- '167', # Viettel Mobile
112
- '168', # Viettel Mobile
113
- '169', # Viettel Mobile
114
- '186', # Vietnamobile
115
- '188', # Vietnamobile (previously known as HT Mobile)
116
- '199' # GTel (traded as Beeline)
118
+ '99', # Gmobile (traded as Beeline)
117
119
  ]
118
120
 
119
- mobile_with_trunk = mobile.map{|num| "0#{num}" }
121
+ mobile_with_trunk = (mobile).map{ |num| "0#{num}" }
120
122
 
121
123
  Phony.define do
122
124
  country '84',
123
125
  trunk('0') |
126
+ one_of(mobile) >> split(4..8)|
124
127
  one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
125
128
  one_of(ndcs_with_8_subscriber_digits) >> split(4,4) |
126
- one_of(mobile) >> split(5..8)|
127
129
  one_of(mobile_with_trunk) >> split(5..8)|
128
130
  # Govt reserved
129
131
  fixed(80) >> split(5) |
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Zimbabwe, https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=ZW
2
4
  # http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000E90002PDFE.pdf
3
5