phony 2.16.4 → 2.20.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.textile +34 -6
- data/lib/phony/config.rb +91 -0
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +4 -2
- data/lib/phony/countries/bangladesh.rb +2 -0
- data/lib/phony/countries/belarus.rb +2 -0
- data/lib/phony/countries/brazil.rb +4 -2
- data/lib/phony/countries/cambodia.rb +3 -5
- data/lib/phony/countries/china.rb +7 -2
- data/lib/phony/countries/croatia.rb +2 -0
- data/lib/phony/countries/georgia.rb +2 -0
- data/lib/phony/countries/germany.rb +5 -2
- data/lib/phony/countries/guinea.rb +8 -5
- data/lib/phony/countries/india.rb +2 -0
- data/lib/phony/countries/indonesia.rb +2 -0
- data/lib/phony/countries/ireland.rb +27 -23
- data/lib/phony/countries/italy.rb +40 -18
- data/lib/phony/countries/japan.rb +61 -8
- data/lib/phony/countries/kyrgyzstan.rb +2 -0
- data/lib/phony/countries/latvia.rb +2 -0
- data/lib/phony/countries/libya.rb +3 -1
- data/lib/phony/countries/malaysia.rb +22 -2
- data/lib/phony/countries/moldova.rb +2 -0
- data/lib/phony/countries/montenegro.rb +2 -0
- data/lib/phony/countries/myanmar.rb +2 -0
- data/lib/phony/countries/namibia.rb +2 -0
- data/lib/phony/countries/nepal.rb +2 -0
- data/lib/phony/countries/netherlands.rb +2 -0
- data/lib/phony/countries/pakistan.rb +2 -0
- data/lib/phony/countries/paraguay.rb +2 -0
- data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +22 -13
- data/lib/phony/countries/saudi_arabia.rb +2 -0
- data/lib/phony/countries/serbia.rb +7 -1
- data/lib/phony/countries/somalia.rb +2 -0
- data/lib/phony/countries/south_korea.rb +7 -2
- data/lib/phony/countries/sweden.rb +2 -0
- data/lib/phony/countries/taiwan.rb +3 -0
- data/lib/phony/countries/tajikistan.rb +2 -0
- data/lib/phony/countries/turkmenistan.rb +2 -0
- data/lib/phony/countries/ukraine.rb +3 -0
- data/lib/phony/countries/united_kingdom.rb +5 -2
- data/lib/phony/countries/uruguay.rb +2 -0
- data/lib/phony/countries/vietnam.rb +93 -93
- data/lib/phony/countries/zimbabwe.rb +2 -0
- data/lib/phony/countries.rb +142 -64
- data/lib/phony/country.rb +15 -3
- data/lib/phony/country_codes.rb +16 -3
- data/lib/phony/dsl.rb +5 -3
- data/lib/phony/local_splitters/fixed.rb +2 -0
- data/lib/phony/national_code.rb +1 -1
- data/lib/phony/national_splitters/none.rb +1 -3
- data/lib/phony/trunk_code.rb +5 -5
- data/lib/phony.rb +62 -57
- data/spec/functional/config_spec.rb +44 -0
- data/spec/functional/plausibility_spec.rb +285 -18
- data/spec/lib/phony/countries_spec.rb +140 -39
- data/spec/lib/phony/country_codes_spec.rb +82 -58
- data/spec/lib/phony/country_spec.rb +29 -9
- data/spec/lib/phony/dsl_spec.rb +7 -3
- data/spec/lib/phony/local_splitters/regex_spec.rb +19 -15
- data/spec/lib/phony/national_code_spec.rb +15 -45
- data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -16
- data/spec/lib/phony/national_splitters/none_spec.rb +3 -3
- data/spec/lib/phony/national_splitters/variable_spec.rb +9 -13
- data/spec/lib/phony/trunk_code_spec.rb +85 -0
- data/spec/lib/phony/vanity_spec.rb +4 -4
- data/spec/lib/phony_spec.rb +63 -67
- metadata +13 -8
@@ -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
|
-
|
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
|
-
|
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
|
# Vietnamese phone numbers.
|
2
4
|
#
|
3
5
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Vietnam
|
@@ -8,124 +10,122 @@
|
|
8
10
|
#
|
9
11
|
|
10
12
|
ndcs_with_7_subscriber_digits = [
|
11
|
-
'
|
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
|
-
'
|
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
|
-
'
|
54
|
-
'
|
55
|
-
'
|
56
|
-
'
|
57
|
-
'
|
58
|
-
'
|
59
|
-
'
|
60
|
-
'
|
61
|
-
'
|
62
|
-
'
|
63
|
-
|
64
|
-
'
|
65
|
-
'
|
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', # Hà 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', # Hà 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', # Hà 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', # Cà 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',
|
80
|
-
'
|
77
|
+
'4', # Hà Nội Province
|
78
|
+
'24', # Hà Nội Province
|
79
|
+
'28', # Hồ Chí Minh Province
|
80
|
+
'8', # Hồ Chí Minh Province
|
81
81
|
]
|
82
82
|
|
83
83
|
mobile = [
|
84
|
-
'
|
85
|
-
'
|
86
|
-
'
|
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,
|
87
110
|
'90', # MobiFone
|
88
111
|
'91', # Vinaphone
|
89
112
|
'92', # Vietnamobile (previously known as HT Mobile)
|
90
113
|
'93', # MobiFone
|
91
114
|
'94', # Vinaphone
|
92
|
-
'95', # S-Fone
|
93
115
|
'96', # previously EVN Telecom, now Viettel Mobile
|
94
116
|
'97', # Viettel Mobile
|
95
117
|
'98', # Viettel Mobile
|
96
118
|
'99', # Gmobile (traded as Beeline)
|
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
|
-
'162', # Viettel Mobile
|
108
|
-
'163', # Viettel Mobile
|
109
|
-
'164', # Viettel Mobile
|
110
|
-
'165', # Viettel Mobile
|
111
|
-
'166', # Viettel Mobile
|
112
|
-
'167', # Viettel Mobile
|
113
|
-
'168', # Viettel Mobile
|
114
|
-
'169', # Viettel Mobile
|
115
|
-
'186', # Vietnamobile
|
116
|
-
'188', # Vietnamobile (previously known as HT Mobile)
|
117
|
-
'199', # GTel (traded as Beeline)
|
118
|
-
'868' # GTel (traded as Beeline)
|
119
119
|
]
|
120
120
|
|
121
|
-
mobile_with_trunk = mobile.map{|num| "0#{num}" }
|
121
|
+
mobile_with_trunk = (mobile).map{ |num| "0#{num}" }
|
122
122
|
|
123
123
|
Phony.define do
|
124
124
|
country '84',
|
125
125
|
trunk('0') |
|
126
|
+
one_of(mobile) >> split(4..8)|
|
126
127
|
one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
|
127
128
|
one_of(ndcs_with_8_subscriber_digits) >> split(4,4) |
|
128
|
-
one_of(mobile) >> split(5..8)|
|
129
129
|
one_of(mobile_with_trunk) >> split(5..8)|
|
130
130
|
# Govt reserved
|
131
131
|
fixed(80) >> split(5) |
|