phony 2.15.0 → 2.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.textile +35 -7
- data/lib/phony/config.rb +91 -0
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +34 -24
- data/lib/phony/countries/bangladesh.rb +2 -0
- data/lib/phony/countries/belarus.rb +2 -0
- data/lib/phony/countries/brazil.rb +6 -4
- data/lib/phony/countries/cambodia.rb +6 -4
- data/lib/phony/countries/china.rb +7 -2
- data/lib/phony/countries/croatia.rb +13 -16
- data/lib/phony/countries/georgia.rb +6 -4
- 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 +8 -3
- data/lib/phony/countries/ireland.rb +27 -23
- data/lib/phony/countries/italy.rb +30 -17
- 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 +5 -1
- 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 +24 -14
- data/lib/phony/countries/saudi_arabia.rb +40 -0
- data/lib/phony/countries/serbia.rb +10 -4
- data/lib/phony/countries/somalia.rb +5 -1
- data/lib/phony/countries/south_korea.rb +16 -9
- data/lib/phony/countries/sweden.rb +53 -38
- data/lib/phony/countries/taiwan.rb +22 -46
- data/lib/phony/countries/tajikistan.rb +2 -0
- data/lib/phony/countries/turkmenistan.rb +2 -0
- data/lib/phony/countries/ukraine.rb +5 -2
- data/lib/phony/countries/united_kingdom.rb +5 -2
- data/lib/phony/countries/uruguay.rb +2 -0
- data/lib/phony/countries/vietnam.rb +94 -92
- data/lib/phony/countries/zimbabwe.rb +2 -0
- data/lib/phony/countries.rb +210 -98
- data/lib/phony/country.rb +15 -3
- data/lib/phony/country_codes.rb +17 -4
- 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 -4
- data/lib/phony/vanity.rb +1 -1
- data/lib/phony.rb +94 -59
- data/spec/functional/config_spec.rb +44 -0
- data/spec/functional/plausibility_spec.rb +373 -35
- data/spec/lib/phony/countries_spec.rb +295 -63
- data/spec/lib/phony/country_codes_spec.rb +106 -33
- data/spec/lib/phony/country_spec.rb +54 -15
- data/spec/lib/phony/dsl_spec.rb +2 -2
- data/spec/lib/phony/local_splitters/regex_spec.rb +12 -5
- data/spec/lib/phony/national_splitters/default_spec.rb +1 -1
- data/spec/lib/phony/trunk_code_spec.rb +85 -0
- data/spec/lib/phony/vanity_spec.rb +30 -0
- data/spec/lib/phony_spec.rb +70 -0
- metadata +27 -17
@@ -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
|
-
'
|
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
|
+
'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
|
-
'
|
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) |
|