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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Cambodia (Kingdom of)
2
4
  # http://en.wikipedia.org/wiki/Telecommunications_in_Cambodia#Mobile_networks
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Cambodia
@@ -35,7 +37,6 @@ ndcs = [
35
37
  six_digit_mobile_prefixes = [
36
38
  '10', # Smart
37
39
  '11', # Mobitel
38
- '12', # Mobitel
39
40
  '13', # qb
40
41
  '14', # Mobitel
41
42
  '15', # Smart
@@ -70,6 +71,7 @@ six_digit_extended_range_mobile_prefixes = [
70
71
  ]
71
72
 
72
73
  seven_digit_mobile_prefixes = [
74
+ '18', # Seatel
73
75
  '31', # Metfone
74
76
  '38', # CooTel
75
77
  '39', # EMAXX
@@ -80,8 +82,8 @@ seven_digit_mobile_prefixes = [
80
82
  '97', # Metfone
81
83
  ]
82
84
 
83
- mobile_prefixes_with_variable_length = [
84
- '18' # Seatel
85
+ variable_length_extended_range_mobile_prefixes = [
86
+ '12' # Mobitel
85
87
  ]
86
88
 
87
89
  six_digit_total_single_digit_fixed_line_prefixes = [
@@ -121,7 +123,7 @@ seven_digit_total_double_digit_fixed_line_prefixes = [
121
123
 
122
124
  Phony.define do
123
125
  country '855', trunk('0', :normalize => true) |
124
- one_of(mobile_prefixes_with_variable_length) >> matched_split(/^9/ => [3, 4], /^[2-8]/ => [3, 3]) |
126
+ one_of(variable_length_extended_range_mobile_prefixes) >> matched_split(/^1/ => [3, 4], /^[2-9]/ => [3, 3]) |
125
127
  one_of(six_digit_mobile_prefixes) >> matched_split(/^[2-9]/ => [3, 3]) |
126
128
  one_of(six_digit_extended_range_mobile_prefixes) >> matched_split(/^[1-9]/ => [3, 3]) |
127
129
  one_of(seven_digit_mobile_prefixes) >> matched_split(/^[2-9]/ => [3, 4]) |
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Chinese phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_China
@@ -17,7 +19,7 @@ ndcs = [
17
19
  '28', # Chengdu
18
20
  '29', # Xi'an
19
21
  ]
20
- mobile = %w{ 130 131 132 133 134 135 136 137 138 139 145 150 151 152 153 155 156 157 158 159 185 186 187 188 189 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 }
22
+ mobile = %w{ 130 131 132 133 134 135 136 137 138 139 145 146 147 148 149 150 151 152 153 155 156 157 158 159 162 165 166 167 170 171 172 173 174 175 176 177 178 180 181 182 183 184 185 186 187 188 189 190 191 192 193 195 196 197 198 199 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 }
21
23
  service = %w{ 110 114 119 120 122 999 } # Probably not exhaustive. TODO Look at http://www.eoc.com.cn/?action-viewnews-itemid-11493.
22
24
 
23
25
  Phony.define do
@@ -26,5 +28,8 @@ Phony.define do
26
28
  one_of(service) >> split(8) |
27
29
  one_of(mobile) >> split(4,4) |
28
30
  one_of(ndcs) >> split(4,4) |
29
- fixed(3) >> split(4,4)
31
+ fixed(3) >> matched_split(
32
+ /\A\d{7}\z/ => [3,4],
33
+ /\A\d{8}\z/ => [4,4]
34
+ )
30
35
  end
@@ -1,26 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Croatia
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Croatia
4
6
  # http://dialcode.org/Europe/Croatia/
5
7
  # http://www.howtocallabroad.com/croatia/
6
- #
7
- # Landline numbers are composed by a 2 digits area code + 6 fixed digits
8
- # Mobile numbers are composed by a 2 digits prefix + 7 fixed digits
8
+ # https://github.com/googlei18n/libphonenumber/
9
9
  #
10
10
 
11
- mobile = %w(
12
- 91
13
- 92
14
- 95
15
- 97
16
- 977
17
- 98
18
- 99
19
- )
11
+ landline = /^(2[0-3]|3[1-5]|4[02-47-9]|5[1-3])/
20
12
 
21
13
  Phony.define do
22
14
  country '385', trunk('0') |
23
- one_of(mobile) >> split(3, 4) |
24
- one_of('1') >> split(4, 3) | # Zagreb
25
- fixed(2) >> split(3, 3) # 2-digit NDCs
26
- end
15
+ one_of('1') >> split(4, 3) | # Zagreb
16
+ match(/^(80[01])/) >> matched_split(
17
+ /\A\d{4}\z/ => [4],
18
+ /\A\d{6}\z/ => [3,3]) | # Toll free
19
+ match(/^(9\d)/) >> split(3, 3..4) | # Mobile
20
+ match(landline) >> split(3, 3..4) | # Landline
21
+ match(/^(6[01])/) >> split(2,2..3) | # Premium rate
22
+ match(/^([67]\d)/) >> split(3,3..4) # Premium, personal and UAN
23
+ end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Georgia
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=GE
4
6
 
5
- ndcs_with_7_subscirber_digits = %w(32)
6
- ndcs_with_6_subscirber_digits = %w(
7
+ ndcs_with_7_subscriber_digits = %w(32)
8
+ ndcs_with_6_subscriber_digits = %w(
7
9
  341
8
10
  342
9
11
  344
@@ -86,7 +88,7 @@ Phony.define do
86
88
  trunk('0') |
87
89
  one_of('220') >> split(3,2) |
88
90
  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
89
- one_of(ndcs_with_6_subscirber_digits) >> split(3,3) |
90
- one_of(ndcs_with_7_subscirber_digits) >> split(3,4) |
91
+ one_of(ndcs_with_6_subscriber_digits) >> split(3,3) |
92
+ one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
91
93
  fixed(3) >> split(3,3)
92
94
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Germany uses a variable-length ndc code, thus we use a separate file to not let countries.rb explode.
2
4
  #
3
5
  # Note: Germany uses a variable ndc format from length 2 to 5.
@@ -4019,8 +4021,9 @@ mobile_4digits = [
4019
4021
  '1520', # Vodafone
4020
4022
  '1521', # Lycamobile
4021
4023
  '1522', # Vodafone
4024
+ '1523', # Vodafone
4022
4025
  '1570', # vistream
4023
- '1527', # E-Plus
4026
+ '1577', # E-Plus
4024
4027
  '1672', # Dolphin Telecom
4025
4028
  ]
4026
4029
 
@@ -4087,7 +4090,7 @@ Phony.define do
4087
4090
  one_of(*service) >> split(3,1..9) |
4088
4091
  one_of(*mobile_4digits) >> split(3,4) |
4089
4092
  one_of(*mobile_3digits) >> split(4,3..4) |
4090
- one_of(*ndcs2) >> split(3,2..10) |
4093
+ one_of(*ndcs2) >> split(3,1..10) |
4091
4094
  one_of(*ndcs3) >> split(3,1..9) |
4092
4095
  one_of(*ndcs4) >> split(3,0..8) |
4093
4096
  fixed(5) >> split(3,0..7)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Guinea (sometimes Guinea-Conakry; officially Republic of Guinea)
2
4
  # http://www.itu.int/oth/T020200005B/en
3
5
 
@@ -25,12 +27,13 @@ land_ndcs_with_5_digits = [
25
27
  '30613' # Télimélé
26
28
  ]
27
29
 
30
+ # NOTE We're not using *('660'..'669') since it does not freeze easily.
28
31
  mobile_ndcs_with_3_digits = [
29
- *('660'..'669'), # Areeba
30
- *('620'..'629'), # Orange
31
- *('650'..'659'), # Cellcom
32
- *('630'..'639'), # Intercel
33
- *('600'..'609') # Sotelgui
32
+ '600', '601', '602', '603', '604', '605', '606', '607', '608', '609', # Sotelgui
33
+ '620', '621', '622', '623', '624', '625', '626', '627', '628', '629', # Orange
34
+ '650', '651', '652', '653', '654', '655', '656', '657', '658', '659', # Cellcom
35
+ '630', '631', '632', '633', '634', '635', '636', '637', '638', '639', # Intercel
36
+ '660', '661', '662', '663', '664', '665', '666', '667', '668', '669', # Areeba
34
37
  ]
35
38
 
36
39
  Phony.define do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Indian phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_India
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Indonesia (Republic of)
2
4
  # http://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=ID
@@ -11,7 +13,9 @@ Phony.define do
11
13
  /\A\d+\z/ => [4,4]) |
12
14
  one_of(%w(22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 38 39 72)) >> matched_split(
13
15
  /\A\d{5}\z/ => [3,2],
14
- /\A\d+\z/ => [3,4]) |
16
+ /\A\d{7}\z/ => [3,4],
17
+ /\A\d{8}\z/ => [4,4],
18
+ /\A\d{9}\z/ => [3,3,3]) |
15
19
  one_of('70') >> split(3,3) |
16
20
  one_of(%w(71 73 74 75 76 77)) >> matched_split(
17
21
  /\A\d{6}\z/ => [3,3],
@@ -32,7 +36,8 @@ Phony.define do
32
36
  match(/\A(81\d|82\d|83\d|84\d|85\d|86\d|87\d|88\d|89\d)\d+\z/) >> matched_split( # mobile
33
37
  /\A\d{6}\z/ => [3,3],
34
38
  /\A\d{7}\z/ => [3,4],
35
- /\A\d+\z/ => [4,4]) |
39
+ /\A\d{8}\z/ => [4,4],
40
+ /\A\d+\z/ => [4,5]) |
36
41
  one_of(%w(9)) >> matched_split( # geographic
37
42
  /\A\d{7}\z/ => [4,3],
38
43
  /\A\d+\z/ => [3,3,3]) |
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The Republic of Ireland has variable-length NDCs from 2-3 digits in length. Depending on the NDC, the length of the subscriber number varies from 5-7 characters in length. There does not appear to be any pattern that relates NDCs to subscriber number length.
2
4
  #
3
5
  # 7 digit subscriber numbers follow a 3-4 split pattern.
@@ -7,33 +9,30 @@
7
9
  #
8
10
  # References:
9
11
  # http://www.comreg.ie/_fileupload/publications/ComReg03147.pdf (2003)
12
+ # https://www.comreg.ie/media/dlm_uploads/2015/12/ComReg0804.pdf (2008)
10
13
  # http://www.comreg.ie/licensing_and_services/area_code_maps.552.1040.html
11
14
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_the_Republic_of_Ireland
12
15
  #
13
16
  ndcs_with_5_subscriber_digits = [
14
- ('22'..'29').to_a, # Mallow, Bandon, Youghal, Fermoy, Macroom, Bantry, Skibbereen, Kanturk
15
- '402', # Arklow
16
- '404', # Wicklow
17
- '43', # Longford, Granard
18
- '44', # Mullingar, Castlepollard, Tyrellspass
19
- '47', # Monaghan, Clones
20
- '48', # Northern Ireland
21
- '502', # Portlaoise, Abbeyleix
22
- '504', # Thurles
23
- '505', # Roscrea
24
- '506', # Tullamore
25
- '509', # Bin-
26
- '52', # Killenaule
27
- '54', # Legacy Ferns, Enniscorthy
28
- '55', # Legacy Gorey
29
- '62', # Tipperary, Cashel
30
- '63', # Charleville
31
- '64', # Killarney, Rathmore
32
- '67', # Nenagh
33
- '68', # Listowel
34
- '69', # Newcastle West
35
- '93', # Tuam
36
- ('94'..'99').to_a # Castlebar, Castlerea, Claremorris, Clifden, Ballina, Belmullet, Westport, Kilronan
17
+ '22', '24', '25', '26', '27', '28', '29', # Mallow, Youghal, Fermoy, Macroom, Bantry, Skibbereen, Kanturk
18
+ '402', # Arklow
19
+ '404', # Wicklow
20
+ '47', # Monaghan, Clones
21
+ '48', # Northern Ireland
22
+ '502', # Portlaoise, Abbeyleix
23
+ '504', # Thurles
24
+ '505', # Roscrea
25
+ '506', # Tullamore
26
+ '509', # Bin-
27
+ '54', # Legacy Ferns, Enniscorthy
28
+ '55', # Legacy Gorey
29
+ '62', # Tipperary, Cashel
30
+ '63', # Charleville
31
+ '67', # Nenagh
32
+ '68', # Listowel
33
+ '69', # Newcastle West
34
+ '93', # Tuam
35
+ '94', '95', '96', '97', '98', '99' # Castlebar, Castlerea, Claremorris, Clifden, Ballina, Belmullet, Westport, Kilronan
37
36
  ].flatten
38
37
 
39
38
  ndcs_with_6_subscriber_digits = [
@@ -46,14 +45,19 @@ ndcs_with_6_subscriber_digits = [
46
45
  ndcs_with_7_subscriber_digits = [
47
46
  '1', # Dublin
48
47
  '21', # Cork, Coachford, Kinsale
48
+ '23', # Bandon
49
49
  '41', # Ardee
50
50
  '42', # Dundalk, Carrickmacross, Castleblaney
51
+ '43', # Longford, Granard
52
+ '44', # Mullingar, Castlepollard, Tyrellspass
51
53
  '46', # Navan, Kells, Trim, Enfield, Edenderry
52
54
  '49', # Cavan, Cootehill, Oldcastle, Belturbet
55
+ '52', # Killenaule
53
56
  '53', # Wexford, Enniscorthy, Ferns, Gorey, Craanford
54
57
  '56', # Kilkenny, Castlecomer
55
58
  '58', # Dungarvan
56
59
  '59', # Carlow, Muine Bheag, Athy, Baltinglass
60
+ '64', # Killarney, Rathmore
57
61
  '65', # Ennistymon, Kilrush
58
62
  '66', # Tralee, Dingle, Killorglin, Cahirciveen
59
63
  '71', # Sligo, Manorhamilton, Carrick-on-Shannon
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Italian phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Italy
4
- #
6
+ # https://www.itu.int/dms_pub/itu-t/oth/02/02/T020200006B0001PDFE.pdf
5
7
 
6
- ndcs_2digit = [
8
+ ndcs_1digit = [
7
9
  '02', # Milan
8
10
  '06', # Rome (including State of Vatican City) and Aprilia
9
11
  ]
10
12
 
11
- ndcs_3digit = [
13
+ ndcs_2digit = [
12
14
  '010', # Genoa
13
15
  '011', # Turin
14
16
  '015', # Biella
@@ -40,7 +42,7 @@ ndcs_3digit = [
40
42
  '099', # Taranto
41
43
  ]
42
44
 
43
- ndcs_4digit = [
45
+ ndcs_3digit = [
44
46
  '0121', # Pinerolo
45
47
  '0122', # Sestrieres, Bardonecchia and other Susa Valley mountain resorts
46
48
  '0123', # Lanzo Torinese
@@ -249,7 +251,10 @@ ndcs_4digit = [
249
251
 
250
252
  # All 3-- numbers are reserved for mobile phones according to
251
253
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Italy#Mobile_telephones
252
- mobile = (300..399).collect(&:to_s).to_a
254
+ # NOTE was:
255
+ # mobile = ('300'..'399').to_a
256
+ # but this was not frozen so easily.
257
+ mobile = %w(300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399)
253
258
 
254
259
  service = [ # Not exhaustive.
255
260
  '112',
@@ -264,20 +269,28 @@ service = [ # Not exhaustive.
264
269
  ]
265
270
 
266
271
  Phony.define do
267
- country '39', trunk('', :normalize => false) |
272
+ # Note: The 0 does not count towards NDC number length.
273
+ country '39', trunk('', normalize: false) |
268
274
  one_of(*service) >> split(3,3) |
269
275
  one_of(*mobile) >> split(3,4,-1..1) |
270
- one_of(*ndcs_2digit) >> split(4,4) |
271
- one_of(*ndcs_3digit) >> matched_split(
272
- /^1\d{6}$/ => [7],
273
- /^1\d{7}$/ => [8],
274
- /^[^1]\d{5}$/ => [6],
275
- /^[^1]\d{6}$/ => [7]
276
+ one_of(*ndcs_1digit) >> matched_split(
277
+ /\A\d{5}\z/ => [5],
278
+ /\A\d{6}\z/ => [4,2],
279
+ /\A\d{7}\z/ => [4,3],
280
+ /\A\d{8}\z/ => [4,4],
276
281
  ) |
277
- one_of(*ndcs_4digit) >> matched_split(
278
- /^1\d{5}$/ => [6],
279
- /^1\d{6}$/ => [7],
280
- /^[^1]\d{4}$/ => [5],
281
- /^[^1]\d{5}$/ => [3,3]
282
+ one_of(*ndcs_2digit) >> matched_split(
283
+ /\A\d{4}\z/ => [4],
284
+ /\A\d{5}\z/ => [5],
285
+ /\A\d{6}\z/ => [6],
286
+ /\A\d{7}\z/ => [7],
287
+ /\A\d{8}\z/ => [8]
288
+ ) |
289
+ one_of(*ndcs_3digit) >> matched_split(
290
+ /\A\d{4}\z/ => [4],
291
+ /\A1\d{5}\z/ => [6],
292
+ /\A1\d{6}\z/ => [7],
293
+ /\A[^1]\d{4}\z/ => [5],
294
+ /\A[^1]\d{5}\z/ => [3,3]
282
295
  )
283
296
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Japan
2
4
  # http://www.itu.int/oth/T020200006D/en
3
5
 
@@ -164,6 +166,7 @@ ndcs_with_6_subscriber_numbers = %w(
164
166
  422
165
167
  428
166
168
  436
169
+ 438
167
170
  439
168
171
  460
169
172
  463
@@ -279,7 +282,6 @@ ndcs_with_6_subscriber_numbers = %w(
279
282
  846
280
283
  847
281
284
  848
282
- 849
283
285
  852
284
286
  853
285
287
  854
@@ -359,7 +361,6 @@ ndcs_with_5_subscriber_numbers = %w(
359
361
  1374
360
362
  1377
361
363
  1392
362
- 1394
363
364
  1397
364
365
  1398
365
366
  1456
@@ -391,7 +392,6 @@ ndcs_with_5_subscriber_numbers = %w(
391
392
  8477
392
393
  8512
393
394
  8514
394
- 8636
395
395
  9496
396
396
  9802
397
397
  9912
@@ -401,15 +401,68 @@ ndcs_with_5_subscriber_numbers = %w(
401
401
 
402
402
  Phony.define do
403
403
  country '81',
404
- trunk('0') |
405
- one_of('20', '50', '60', '70', '90') >> split(4,4) | # mobile, VoIP telephony
404
+ trunk('0', normalize: true, format: true, split: true) |
405
+ one_of(%w(20 50 60 70 90)) >> split(4,4) | # mobile, VoIP telephony
406
+ match(/\A(597)9[0178]\d+\z/) >> split(2,4) |
406
407
  one_of(ndcs_with_5_subscriber_numbers) >> split(1,4) |
408
+ match(/\A(4)70[019]\d+\z/) >> split(4,4) |
409
+ match(/\A(4)71\d+\z/) >> split(4,4) |
410
+ match(/\A(4)20\d+\z/) >> split(4,4) |
411
+ match(/\A(4)29[02-69]\d+\z/) >> split(4,4) |
412
+ match(/\A(15)4[018]\d+\z/) >> split(3,4) |
413
+ match(/\A(22)3[014-9]\d+\z/) >> split(3,4) |
414
+ match(/\A(25)[04][01]\d+\z/) >> split(3,4) |
415
+ match(/\A(25)5[0-69]\d+\z/) >> split(3,4) |
416
+ match(/\A(25)[68][01]\d+\z/) >> split(3,4) |
417
+ match(/\A(25)7[015-9]\d+\z/) >> split(3,4) |
418
+ match(/\A(25)917\d+\z/) >> split(3,4) |
419
+ match(/\A(25)999\d+\z/) >> split(3,4) |
420
+ match(/\A(26)4[016-9]\d+\z/) >> split(3,4) |
421
+ match(/\A(28)3[0134]\d+\z/) >> split(3,4) |
422
+ match(/\A(28)9[0-5]\d+\z/) >> split(3,4) |
423
+ match(/\A(29)17\d+\z/) >> split(3,4) |
424
+ match(/\A(29)3[015-9]\d+\z/) >> split(3,4) |
425
+ match(/\A(42)21\d+\z/) >> split(3,4) |
426
+ match(/\A(42)8[01456]\d+\z/) >> split(3,4) |
427
+ match(/\A(47)5[019]\d+\z/) >> split(3,4) |
428
+ match(/\A(47)9[019]\d+\z/) >> split(3,4) |
429
+ match(/\A(59)8[019]\d+\z/) >> split(3,4) |
430
+ match(/\A(59)9[01]\d+\z/) >> split(3,4) |
431
+ match(/\A(79)4[0-59]\d+\z/) >> split(3,4) |
432
+ match(/\A(79)5[01569]\d+\z/) >> split(3,4) |
433
+ match(/\A(79)6[0167]\d+\z/) >> split(3,4) |
434
+ match(/\A(82)4[0-39]\d+\z/) >> split(3,4) |
435
+ match(/\A(82)9[019]\d+\z/) >> split(3,4) |
436
+ match(/\A(82)92[1-9]\d+\z/) >> split(3,4) |
437
+ match(/\A(82)94[1-3]\d+\z/) >> split(3,4) |
438
+ match(/\A(82)96[0-47-9]\d+\z/) >> split(3,4) |
439
+ match(/\A(82)965[01346-9]\d+\z/) >> split(3,4) |
440
+ match(/\A(82)966[1-9]\d+\z/) >> split(3,4) |
441
+ match(/\A(83)76[6-8]\d+\z/) >> split(3,4) |
442
+ match(/\A(83)7[01789]\d+\z/) >> split(3,4) |
443
+ match(/\A(83)8[01]\d+\z/) >> split(3,4) |
444
+ match(/\A(86)36[23]\d+\z/) >> split(3,4) |
445
+ match(/\A(86)5[0-389]\d+\z/) >> split(3,4) |
446
+ match(/\A(86)55[23]\d+\z/) >> split(3,4) |
447
+ match(/\A(86)[01]\d+\z/) >> split(3,4) |
448
+ match(/\A(86)9[178]\d+\z/) >> split(3,4) |
449
+ match(/\A(86)72\d+\z/) >> split(3,4) |
450
+ match(/\A(86)8[019]\d+\z/) >> split(3,4) |
451
+ match(/\A(86)9[0145]\d+\z/) >> split(3,4) |
452
+ match(/\A(86)99[014-9]\d+\z/) >> split(3,4) |
453
+ match(/\A(99)331\d+\z/) >> split(3,4) |
454
+ match(/\A(99)34[357]\d+\z/) >> split(3,4) |
455
+ match(/\A(99)4[0178]\d+\z/) >> split(3,4) |
407
456
  one_of(ndcs_with_6_subscriber_numbers) >> split(2,4) |
408
- one_of(%w(120 800)) >> split(3,3) | # freephone
457
+ one_of(%w(120)) >> split(3,3) | # freephone
458
+ one_of(%w(800)) >> split(3,4) | # freephone
459
+ one_of(%w(180 570)) >> split(3,3) | # Tele-gong/Tele-dome, Navi-dial
460
+ one_of(%w(170 990)) >> split(2,4) | # Dengon-dial, Dial Q2 (discontinued)
461
+ one_of(%w(80)) >> split(4,4) | # mobile
409
462
  one_of(ndcs_with_7_subscriber_numbers) >> split(3,4) |
410
463
  one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
411
464
  # TODO: 91(NDC) N(S)N length: 5-13 - Non-geographic number (Direct subscriber telephone service (legacy))
412
465
  fixed(2) >> split(4,4),
413
- :local_space => :- ,
414
- :space => :-
466
+ local_space: :-,
467
+ space: :-
415
468
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Kyrgyz Republic
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=KG
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Latvia
2
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=LV
3
5
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Lybia, https://www.numberingplans.com/?page=dialling&sub=areacodes
2
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=LY
3
5
 
@@ -109,6 +111,6 @@ Phony.define do
109
111
  one_of(ndcs_with_5_subscriber_numbers) >> split(3,2) |
110
112
  one_of(ndcs_with_6_subscriber_numbers) >> split(3,3) |
111
113
  one_of(ndcs_with_7_subscriber_numbers) >> split(4,3) |
112
- one_of(%w(91 92)) >> split(4,3) | # mobile
114
+ one_of(%w(91 92 94 95)) >> split(4,3) | # mobile
113
115
  fixed(2) >> split(3,3)
114
116
  end
@@ -1,19 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Malaysian phone numbers.
2
4
  #
3
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
4
6
  #
5
7
  ndcs = [
6
8
  '2', # Singapore
7
- '3', # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
8
9
  '4', # Kedah, Penang & Perlis
9
10
  '5', # Perak & Cameron Highlands (Pahang)
10
11
  '6', # Melaka, Negeri Sembilan & Muar (Johor)
11
12
  '7', # Johor (except Muar)
12
13
  '9', # Kelantan, Pahang (except Cameron Highlands & Genting Highlands) & Terengganu
13
14
  ]
15
+
16
+ ndcs_two_digits = [
17
+ '80', # Domestic access code from East Malaysia to Brunei
18
+ '81', # Reserved number for future use
19
+ '82', # Sarawak – Kuching, Samarahan and Serian
20
+ '83', # Sarawak – Sri Aman and Betong
21
+ '84', # Sarawak – Sibu, Sarikei, Mukah and Kapit
22
+ '85', # Sarawak – Miri, Limbang and Lawas
23
+ '86', # Sarawak – Bintulu and Belaga
24
+ '87', # Labuan Interior Division, Sabah
25
+ '88', # Sabah – Kota Kinabalu and Kudat
26
+ '89', # Sabah – Lahad Datu, Sandakan and Tawau
27
+ ]
28
+
14
29
  mobile = %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 }
15
30
  # service = %w{ 100 101 102 103 104 108 991 994 995 999 } # Emergeny and Service numbers, only 3 digits long
16
31
  freephone = %w{ 300 700 800 }
32
+ ndcs_eight = [
33
+ '3' # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
34
+ ]
17
35
 
18
36
  Phony.define do
19
37
  country '60',
@@ -21,6 +39,8 @@ Phony.define do
21
39
  one_of(freephone) >> split(2,4) | # Freephone, Tollfree, Forwarding
22
40
  # one_of(service) >> none | # Service
23
41
  one_of(mobile) >> split(3,4..5) | # Mobile
24
- one_of(ndcs) >> split(8) | # 1-digit NDCs
42
+ one_of(ndcs_two_digits) >> split(6) | # 2-digit NDCs
43
+ one_of(ndcs) >> split(7) | # 1-digit NDCs
44
+ one_of(ndcs_eight) >> split(8) | # 1-digit NDCs
25
45
  fixed(2) >> split(8) # 2-digit NDCs (Also, fallback)
26
46
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Moldova
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=MD
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Montenegro
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=ME
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Myanmar: http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000920003PDFE.pdf
2
4
  #
3
5
  # formatting according to Google's libphonenumber library. (r680 7/30/2014)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Namibia
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=NA
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Nepal
2
4
  # https://www.numberingplans.com/?page=dialling&sub=areacodes
3
5
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=NP
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The Netherlands use a variable-length ndc code, thus we use a separate file to not let all_other.rb explode. The
2
4
  # latest version of the numbering plan is available at http://wetten.overheid.nl/BWBR0010198/
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Pakistan (Islamic Republic of)
2
4
  # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=PK
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Paraguay (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=PY