phony 2.15.0 → 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 +34 -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 +8 -3
  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 +5 -1
  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 +40 -0
  34. data/lib/phony/countries/serbia.rb +10 -4
  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 +53 -38
  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 +5 -2
  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 +210 -98
  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 -59
  56. data/spec/functional/config_spec.rb +44 -0
  57. data/spec/functional/plausibility_spec.rb +373 -35
  58. data/spec/lib/phony/countries_spec.rb +295 -63
  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 +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
- '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