phony 1.9.0 → 2.19.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/README.textile +64 -112
  3. data/lib/phony/config.rb +91 -0
  4. data/lib/phony/countries/argentina.rb +355 -0
  5. data/lib/phony/countries/austria.rb +56 -22
  6. data/lib/phony/countries/bangladesh.rb +57 -0
  7. data/lib/phony/countries/belarus.rb +133 -0
  8. data/lib/phony/countries/brazil.rb +101 -95
  9. data/lib/phony/countries/cambodia.rb +131 -0
  10. data/lib/phony/countries/china.rb +13 -6
  11. data/lib/phony/countries/croatia.rb +23 -0
  12. data/lib/phony/countries/georgia.rb +94 -0
  13. data/lib/phony/countries/germany.rb +66 -42
  14. data/lib/phony/countries/guinea.rb +46 -0
  15. data/lib/phony/countries/india.rb +50 -0
  16. data/lib/phony/countries/indonesia.rb +55 -0
  17. data/lib/phony/countries/ireland.rb +35 -28
  18. data/lib/phony/countries/italy.rb +272 -166
  19. data/lib/phony/countries/japan.rb +468 -0
  20. data/lib/phony/countries/kyrgyzstan.rb +120 -0
  21. data/lib/phony/countries/latvia.rb +43 -0
  22. data/lib/phony/countries/libya.rb +116 -0
  23. data/lib/phony/countries/malaysia.rb +31 -7
  24. data/lib/phony/countries/moldova.rb +53 -0
  25. data/lib/phony/countries/montenegro.rb +30 -0
  26. data/lib/phony/countries/myanmar.rb +55 -0
  27. data/lib/phony/countries/namibia.rb +37 -0
  28. data/lib/phony/countries/nepal.rb +73 -0
  29. data/lib/phony/countries/netherlands.rb +17 -5
  30. data/lib/phony/countries/pakistan.rb +121 -0
  31. data/lib/phony/countries/paraguay.rb +147 -0
  32. data/lib/phony/countries/{russia_kazakhstan_abhasia_south_osetia.rb → russia_kazakhstan_abkhasia_south_ossetia.rb} +35 -24
  33. data/lib/phony/countries/saudi_arabia.rb +40 -0
  34. data/lib/phony/countries/serbia.rb +47 -0
  35. data/lib/phony/countries/somalia.rb +26 -0
  36. data/lib/phony/countries/south_korea.rb +19 -10
  37. data/lib/phony/countries/sweden.rb +58 -38
  38. data/lib/phony/countries/taiwan.rb +28 -0
  39. data/lib/phony/countries/tajikistan.rb +79 -0
  40. data/lib/phony/countries/turkmenistan.rb +76 -0
  41. data/lib/phony/countries/ukraine.rb +630 -0
  42. data/lib/phony/countries/united_kingdom.rb +639 -44
  43. data/lib/phony/countries/uruguay.rb +53 -0
  44. data/lib/phony/countries/vietnam.rb +133 -0
  45. data/lib/phony/countries/zimbabwe.rb +39 -0
  46. data/lib/phony/countries.rb +901 -301
  47. data/lib/phony/country.rb +177 -20
  48. data/lib/phony/country_codes.rb +119 -101
  49. data/lib/phony/dsl.rb +113 -68
  50. data/lib/phony/local_splitters/fixed.rb +25 -1
  51. data/lib/phony/local_splitters/regex.rb +16 -2
  52. data/lib/phony/national_code.rb +7 -7
  53. data/lib/phony/national_splitters/default.rb +35 -3
  54. data/lib/phony/national_splitters/dsl.rb +12 -7
  55. data/lib/phony/national_splitters/fixed.rb +7 -1
  56. data/lib/phony/national_splitters/none.rb +7 -3
  57. data/lib/phony/national_splitters/regex.rb +6 -0
  58. data/lib/phony/national_splitters/variable.rb +13 -9
  59. data/lib/phony/trunk_code.rb +57 -0
  60. data/lib/phony/vanity.rb +3 -3
  61. data/lib/phony.rb +239 -55
  62. data/spec/functional/config_spec.rb +44 -0
  63. data/spec/functional/plausibility_spec.rb +656 -0
  64. data/spec/lib/phony/countries_spec.rb +1207 -119
  65. data/spec/lib/phony/country_codes_spec.rb +99 -81
  66. data/spec/lib/phony/country_spec.rb +54 -14
  67. data/spec/lib/phony/dsl_spec.rb +2 -2
  68. data/spec/lib/phony/local_splitters/fixed_spec.rb +4 -4
  69. data/spec/lib/phony/local_splitters/regex_spec.rb +50 -2
  70. data/spec/lib/phony/national_code_spec.rb +34 -34
  71. data/spec/lib/phony/national_splitters/default_spec.rb +34 -0
  72. data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -6
  73. data/spec/lib/phony/national_splitters/none_spec.rb +13 -3
  74. data/spec/lib/phony/national_splitters/regex_spec.rb +1 -1
  75. data/spec/lib/phony/national_splitters/variable_spec.rb +11 -5
  76. data/spec/lib/phony/trunk_code_spec.rb +85 -0
  77. data/spec/lib/phony/vanity_spec.rb +15 -19
  78. data/spec/lib/phony_spec.rb +59 -277
  79. metadata +67 -34
  80. data/lib/phony/validator.rb +0 -26
  81. data/lib/phony/validators.rb +0 -88
  82. data/spec/lib/phony/validations_spec.rb +0 -109
@@ -1,101 +1,107 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Brazilian phone numbers.
2
4
  #
3
- # http://www.anatel.gov.br/hotsites/CodigosNacionaisLocalidade/TelefoneCelular-CodigosDeArea.htm
4
- #
5
- # Note: São Paulo recently added an extra 9 digit to all mobile phones in the 11 area code
6
5
  #
7
- ndcs = [
8
- '11', #Sao Paulo
9
- '12', #Sao Paulo
10
- '13', #Sao Paulo
11
- '14', #Sao Paulo
12
- '15', #Sao Paulo
13
- '16', #Sao Paulo
14
- '17', #Sao Paulo
15
- '18', #Sao Paulo
16
- '19', #Sao Paulo
17
-
18
- '21', #Rio de Janeiro
19
- '22', #Rio de Janeiro
20
-
21
- '24', #Rio de Janeiro
22
-
23
-
24
- '27', #Espírito Santo
25
- '28', #Espírito Santo
26
-
27
-
28
- '31', #Minas Gerais
29
- '32', #Minas Gerais
30
- '33', #Minas Gerais
31
- '34', #Minas Gerais
32
- '35', #Minas Gerais
33
- '36', #Minas Gerais
34
- '37', #Minas Gerais
35
- '38', #Minas Gerais
36
-
37
-
38
- '41', #Paraná
39
- '42', #Paraná
40
- '43', #Paraná
41
- '44', #Paraná
42
- '45', #Paraná
43
- '46', #Paraná
44
- '47', #Santa Catarina
45
- '48', #Santa Catarina
46
- '49', #Santa Catarina
47
-
48
- '51', #Rio Grande do Sul
49
- '52', #Rio Grande do Sul
50
- '53', #Rio Grande do Sul
51
- '54', #Rio Grande do Sul
52
- '55', #Rio Grande do Sul
53
-
54
- '61', #Distrito Federal
55
- '62', #Goiânia
56
- '63', #Tocantins
57
- '64', #Goiânia
58
- '65', #Mato Grosso
59
- '66', #Mato Grosso
60
- '67', #Mato Grosso do Sul
61
- '68', #Acre
62
- '69', #Rondônia
63
-
64
- '71', #Bahia
65
- '72', #Bahia
66
- '73', #Bahia
67
- '74', #Bahia
68
- '75', #Bahia
69
-
70
- '77', #Bahia
71
- '78', #Bahia
72
- '79', #Sergipe
73
-
74
- '81', #Pernambuco
75
- '82', #Alagoas
76
- '83', #Paraíba
77
- '84', #Rio Grande do Norte
78
- '85', #Ceará
79
- '86', #Piauí
80
- '87', #Pernambuco
81
- '88', #Ceará
82
- '89', #Piauí
83
-
84
- '91', #Pará
85
- '92', #Amazonas
86
- '93', #Pará
87
- '94', #Pará
88
- '95', #Roraima
89
- '96', #Amapá
90
- '97', #Amazonas
91
- '98', #Maranhão
92
- '99', #Maranhão
6
+ # NDC Reference
7
+ # http://www.anatel.gov.br/hotsites/CodigosNacionaisLocalidade/TelefoneCelular-CodigosDeArea.htm
93
8
 
94
- ]
95
- service = %w{ 100, 128, 190 191 192 193 194 197 198 199 } # State specific numbers were not added. See http://www.brasil.gov.br/navegue_por/aplicativos/agenda
9
+ # 11 #Sao Paulo
10
+ # 12 #Sao Paulo
11
+ # 13 #Sao Paulo
12
+ # 14 #Sao Paulo
13
+ # 15 #Sao Paulo
14
+ # 16 #Sao Paulo
15
+ # 17 #Sao Paulo
16
+ # 18 #Sao Paulo
17
+ # 19 #Sao Paulo
18
+ #
19
+ # 21 #Rio de Janeiro
20
+ # 22 #Rio de Janeiro
21
+ #
22
+ # 24 #Rio de Janeiro
23
+ #
24
+ # 27 #Espírito Santo
25
+ # 28 #Espírito Santo
26
+ #
27
+ # 31 #Minas Gerais
28
+ # 32 #Minas Gerais
29
+ # 33 #Minas Gerais
30
+ # 34 #Minas Gerais
31
+ # 35 #Minas Gerais
32
+ # 36 #Minas Gerais
33
+ # 37 #Minas Gerais
34
+ # 38 #Minas Gerais
35
+ #
36
+ # 41 #Paraná
37
+ # 42 #Paraná
38
+ # 43 #Paraná
39
+ # 44 #Paraná
40
+ # 45 #Paraná
41
+ # 46 #Paraná
42
+ # 47 #Santa Catarina
43
+ # 48 #Santa Catarina
44
+ # 49 #Santa Catarina
45
+ #
46
+ # 51 #Rio Grande do Sul
47
+ # 52 #Rio Grande do Sul
48
+ # 53 #Rio Grande do Sul
49
+ # 54 #Rio Grande do Sul
50
+ # 55 #Rio Grande do Sul
51
+ #
52
+ # 61 #Distrito Federal
53
+ # 62 #Goiânia
54
+ # 63 #Tocantins
55
+ # 64 #Goiânia
56
+ # 65 #Mato Grosso
57
+ # 66 #Mato Grosso
58
+ # 67 #Mato Grosso do Sul
59
+ # 68 #Acre
60
+ # 69 #Rondônia
61
+ #
62
+ # 71 #Bahia
63
+ # 72 #Bahia
64
+ # 73 #Bahia
65
+ # 74 #Bahia
66
+ # 75 #Bahia
67
+ #
68
+ # 77 #Bahia
69
+ # 78 #Bahia
70
+ # 79 #Sergipe
71
+ #
72
+ # 81 #Pernambuco
73
+ # 82 #Alagoas
74
+ # 83 #Paraíba
75
+ # 84 #Rio Grande do Norte
76
+ # 85 #Ceará
77
+ # 86 #Piauí
78
+ # 87 #Pernambuco
79
+ # 88 #Ceará
80
+ # 89 #Piauí
81
+ #
82
+ # 91 #Pará
83
+ # 92 #Amazonas
84
+ # 93 #Pará
85
+ # 94 #Pará
86
+ # 95 #Roraima
87
+ # 96 #Amapá
88
+ # 97 #Amazonas
89
+ # 98 #Maranhão
90
+ # 99 #Maranhão
91
+
92
+ ndcs = "(11|12|13|14|15|16|17|18|19|21|22|24|27|28|31|32|33|34|35|36|37|38|41|42|43|44|45|46|47|48|49|51|52|53|54|55|61|62|63|64|65|66|67|68|69|71|72|73|74|75|77|78|79|81|82|83|84|85|86|87|88|89|91|92|93|94|95|96|97|98|99)"
93
+
94
+ service = %w{ 100 128 190 191 192 193 194 197 198 199 } # State specific numbers were not added. See http://www.brasil.gov.br/navegue_por/aplicativos/agenda
95
+
96
+ special_numbers_3_4 = %w{ 0800 }
97
+ special_numbers_4 = %w{ 3003 4003 4004 4020 }
96
98
 
97
99
  Phony.define do
98
- country '55', one_of(service) >> split(3,3) |
99
- one_of(ndcs) >> split(4,4) |
100
- fixed(3) >> split(4,4)
101
- end
100
+ country '55',
101
+ match(/^#{ndcs}9\d{8}$/) >> split(5,4) |
102
+ match(/^#{ndcs}\d{8}$/) >> split(4,4) |
103
+ one_of(special_numbers_3_4) >> split(3,4) |
104
+ one_of(special_numbers_4) >> split(4) |
105
+ one_of(service) >> split(3) |
106
+ fixed(3) >> split(3)
107
+ end
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Cambodia (Kingdom of)
4
+ # http://en.wikipedia.org/wiki/Telecommunications_in_Cambodia#Mobile_networks
5
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_Cambodia
6
+ # http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000230001MSWE.doc
7
+ # http://www.khmerdigitalpost.com/national-numbering-plans-in-cambodia-by-2014/
8
+ # http://www.khmerdigitalpost.com/mobile-operators-in-cambodia-by-2015/
9
+
10
+ ndcs = [
11
+ '23', # Phnom Penh
12
+ '24', # Kandal
13
+ '25', # Kampong Speu
14
+ '26', # Kampong Chhnang
15
+ '32', # Takeo
16
+ '33', # Kampot
17
+ '34', # Preah Sihanouk
18
+ '35', # Koh Kong
19
+ '36', # Kep
20
+ '42', # Kampong Cham
21
+ '43', # Prey Veng
22
+ '44', # Svay Rieng
23
+ '52', # Pursat
24
+ '53', # Battambang
25
+ '54', # Banteay Meanchey
26
+ '55', # Pailin
27
+ '62', # Kampong Thom
28
+ '63', # Siem Reap
29
+ '64', # Preah Vihear
30
+ '65', # Oddar Meanchey
31
+ '72', # Kratie
32
+ '73', # Mondulkiri
33
+ '74', # Stung Treng
34
+ '75', # Ratanakiri
35
+ ]
36
+
37
+ six_digit_mobile_prefixes = [
38
+ '10', # Smart
39
+ '11', # Mobitel
40
+ '13', # qb
41
+ '14', # Mobitel
42
+ '15', # Smart
43
+ '16', # Smart
44
+ '17', # Mobitel
45
+ '60', # Metfone
46
+ '61', # Mobitel
47
+ '66', # Metfone
48
+ '67', # Metfone
49
+ '68', # Metfone
50
+ '69', # Smart
51
+ '70', # Smart
52
+ '77', # Mobitel
53
+ '78', # Mobitel
54
+ '80', # qb
55
+ '81', # Smart
56
+ '83', # qb
57
+ '84', # qb
58
+ '85', # Mobitel
59
+ '86', # Smart
60
+ '87', # Smart
61
+ '89', # Mobitel
62
+ '90', # Metfone
63
+ '93', # Smart
64
+ '95', # Mobitel
65
+ '98', # Smart
66
+ '99', # Mobitel
67
+ ]
68
+
69
+ six_digit_extended_range_mobile_prefixes = [
70
+ '92' # Mobitel
71
+ ]
72
+
73
+ seven_digit_mobile_prefixes = [
74
+ '18', # Seatel
75
+ '31', # Metfone
76
+ '38', # CooTel
77
+ '39', # EMAXX
78
+ '71', # Metfone
79
+ '76', # Mobitel
80
+ '88', # Metfone
81
+ '96', # Smart
82
+ '97', # Metfone
83
+ ]
84
+
85
+ variable_length_extended_range_mobile_prefixes = [
86
+ '12' # Mobitel
87
+ ]
88
+
89
+ six_digit_total_single_digit_fixed_line_prefixes = [
90
+ '2', # Telecom Cambodia
91
+ '3', # Mobitel
92
+ '7', # Telecom Cambodia
93
+ '8', # Telecom Cambodia
94
+ '9', # Camintel
95
+ ]
96
+
97
+ six_digit_total_double_digit_fixed_line_prefixes = [
98
+ '40', # Telecom Cambodia
99
+ '41', # Telecom Cambodia
100
+ '42', # Telecom Cambodia
101
+ '43', # Telecom Cambodia
102
+ '44', # Telecom Cambodia
103
+ ]
104
+
105
+ seven_digit_total_single_digit_fixed_line_prefixes = [
106
+ '6', # Metfone
107
+ ]
108
+
109
+ seven_digit_total_double_digit_fixed_line_prefixes = [
110
+ '45', # Smart
111
+ '46', # Metfone
112
+ '47', # CooTel
113
+ '48', # Excell
114
+ '49', # qb
115
+ '50', # Mobitel
116
+ '51', # Mobitel
117
+ '52', # Mobitel
118
+ '53', # Mobitel
119
+ '54', # Mobitel
120
+ '55', # Mobitel
121
+ '56', # Smart
122
+ ]
123
+
124
+ Phony.define do
125
+ country '855', trunk('0', :normalize => true) |
126
+ one_of(variable_length_extended_range_mobile_prefixes) >> matched_split(/^1/ => [3, 4], /^[2-9]/ => [3, 3]) |
127
+ one_of(six_digit_mobile_prefixes) >> matched_split(/^[2-9]/ => [3, 3]) |
128
+ one_of(six_digit_extended_range_mobile_prefixes) >> matched_split(/^[1-9]/ => [3, 3]) |
129
+ one_of(seven_digit_mobile_prefixes) >> matched_split(/^[2-9]/ => [3, 4]) |
130
+ one_of(ndcs) >> matched_split(/^(#{seven_digit_total_double_digit_fixed_line_prefixes.join('|')})\d{5}$/ => [3, 4], /^(#{seven_digit_total_single_digit_fixed_line_prefixes.join('|')})\d{6}$/ => [3, 4], /^(#{six_digit_total_double_digit_fixed_line_prefixes.join('|')})\d{4}$/ => [3, 3], /^(#{six_digit_total_single_digit_fixed_line_prefixes.join('|')})\d{5}$/ => [3, 3])
131
+ end
@@ -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,12 +19,17 @@ ndcs = [
17
19
  '28', # Chengdu
18
20
  '29', # Xi'an
19
21
  ]
20
- mobile = %w{ 130 131 132 133 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
24
- country '86', one_of(service) >> split(8) |
25
- one_of(mobile) >> split(4,4) |
26
- one_of(ndcs) >> split(4,4) |
27
- fixed(3) >> split(4,4)
28
- end
26
+ country '86',
27
+ trunk('0') |
28
+ one_of(service) >> split(8) |
29
+ one_of(mobile) >> split(4,4) |
30
+ one_of(ndcs) >> split(4,4) |
31
+ fixed(3) >> matched_split(
32
+ /\A\d{7}\z/ => [3,4],
33
+ /\A\d{8}\z/ => [4,4]
34
+ )
35
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Croatia
4
+ #
5
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_Croatia
6
+ # http://dialcode.org/Europe/Croatia/
7
+ # http://www.howtocallabroad.com/croatia/
8
+ # https://github.com/googlei18n/libphonenumber/
9
+ #
10
+
11
+ landline = /^(2[0-3]|3[1-5]|4[02-47-9]|5[1-3])/
12
+
13
+ Phony.define do
14
+ country '385', trunk('0') |
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
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Georgia
4
+ # https://www.numberingplans.com/?page=dialling&sub=areacodes
5
+ # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=GE
6
+
7
+ ndcs_with_7_subscriber_digits = %w(32)
8
+ ndcs_with_6_subscriber_digits = %w(
9
+ 341
10
+ 342
11
+ 344
12
+ 345
13
+ 346
14
+ 347
15
+ 348
16
+ 349
17
+ 350
18
+ 351
19
+ 352
20
+ 353
21
+ 354
22
+ 355
23
+ 356
24
+ 357
25
+ 358
26
+ 359
27
+ 360
28
+ 361
29
+ 362
30
+ 363
31
+ 364
32
+ 365
33
+ 366
34
+ 367
35
+ 368
36
+ 369
37
+ 370
38
+ 371
39
+ 372
40
+ 373
41
+ 374
42
+ 410
43
+ 411
44
+ 412
45
+ 413
46
+ 414
47
+ 415
48
+ 416
49
+ 417
50
+ 418
51
+ 419
52
+ 422
53
+ 423
54
+ 424
55
+ 425
56
+ 426
57
+ 427
58
+ 431
59
+ 432
60
+ 433
61
+ 434
62
+ 435
63
+ 436
64
+ 437
65
+ 439
66
+ 442
67
+ 443
68
+ 444
69
+ 445
70
+ 446
71
+ 447
72
+ 448
73
+ 472
74
+ 473
75
+ 474
76
+ 479
77
+ 491
78
+ 492
79
+ 493
80
+ 494
81
+ 495
82
+ 496
83
+ 497
84
+ )
85
+
86
+ Phony.define do
87
+ country '995',
88
+ trunk('0') |
89
+ one_of('220') >> split(3,2) |
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
91
+ one_of(ndcs_with_6_subscriber_digits) >> split(3,3) |
92
+ one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
93
+ fixed(3) >> split(3,3)
94
+ end
@@ -1,9 +1,10 @@
1
- # Germany uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
1
+ # frozen_string_literal: true
2
+
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.
4
6
  #
5
-
6
- ndcs = [
7
+ ndcs2 = [
7
8
  '10', # Call-By-Call
8
9
  '11', # formerly Value Added Services
9
10
  '13', # Voting and Lottery Numbers
@@ -12,6 +13,8 @@ ndcs = [
12
13
  '40', # Hamburg
13
14
  '69', # Frankfurt am Main
14
15
  '89', # München
16
+ ]
17
+ ndcs3 = [
15
18
  '201', # Essen
16
19
  '202', # Wuppertal
17
20
  '203', # Duisburg
@@ -70,8 +73,6 @@ ndcs = [
70
73
  '661', # Fulda
71
74
  '671', # Bad Kreuznach
72
75
  '681', # Saarbrücken
73
- '700', # Personal Numbers
74
- '701', # Personal Numbers, reserved
75
76
  '711', # Stuttgart
76
77
  '721', # Karlsruhe
77
78
  '731', # Ulm
@@ -81,8 +82,6 @@ ndcs = [
81
82
  '771', # Donaueschingen
82
83
  '781', # Offenburg
83
84
  '791', # Schwäbisch Hall
84
- '800', # Toll-Free Numbers
85
- '801', # Toll-Free Numbers, reserved
86
85
  '811', # Hallbergmoos
87
86
  '821', # Augsburg
88
87
  '831', # Kempten
@@ -91,8 +90,6 @@ ndcs = [
91
90
  '861', # Traunstein
92
91
  '871', # Landshut
93
92
  '881', # Weilheim in Oberbayern
94
- '900', # Premium Rate Numbers
95
- '901', # Premium Rate Numbers, reserved
96
93
  '902', # Replacement for 0137/0138
97
94
  '906', # Donauwörth
98
95
  '911', # Nürnberg
@@ -104,8 +101,10 @@ ndcs = [
104
101
  '971', # Bad Kissingen
105
102
  '981', # Ansbach
106
103
  '991', # Deggendorf
104
+ ]
107
105
  # 4-digit NDCs from now on.
108
106
  #
107
+ ndcs4 = [
109
108
  '2041',
110
109
  '2043',
111
110
  '2045',
@@ -3989,34 +3988,45 @@ ndcs = [
3989
3988
  '9977',
3990
3989
  '9978',
3991
3990
  ]
3992
- # mobile = [
3993
- # '150', # Group3G/Quam
3994
- # '151', # T-Mobile
3995
- # '152', # Vodafone
3996
- # '155', # E-Plus
3997
- # '156', # Mobilcom
3998
- # '157', # E-Plus
3999
- # '159', # O2
4000
- # '160', # T-Mobile
4001
- # '161', # C-Netz
4002
- # '162', # Vodafone
4003
- # '163', # E-Plus
4004
- # '164', # Cityruf
4005
- # '165', # Quix
4006
- # '166', # Telmi
4007
- # '168', # Scall
4008
- # '169', # Cityruf, Scall, Skyper (e*cityruf, e*message, e*skyper)
4009
- # '170', # T-Mobile
4010
- # '171', # T-Mobile
4011
- # '172', # Vodafone
4012
- # '173', # Vodafone
4013
- # '174', # Vodafone
4014
- # '175', # T-Mobile
4015
- # '176', # O2 Germany
4016
- # '177', # E-Plus
4017
- # '178', # E-Plus
4018
- # '179', # O2 Germany
4019
- # ]
3991
+ mobile_3digits = [
3992
+ '150', # Group3G/Quam
3993
+ '151', # T-Mobile
3994
+ '152', # Vodafone
3995
+ '155', # E-Plus
3996
+ '156', # Mobilcom
3997
+ '157', # E-Plus
3998
+ '159', # O2
3999
+ '160', # T-Mobile
4000
+ '161', # C-Netz
4001
+ '162', # Vodafone
4002
+ '163', # E-Plus
4003
+ '164', # Cityruf
4004
+ '165', # Quix
4005
+ '166', # Telmi
4006
+ '168', # Scall
4007
+ '169', # Cityruf, Scall, Skyper (e*cityruf, e*message, e*skyper)
4008
+ '170', # T-Mobile
4009
+ '171', # T-Mobile
4010
+ '172', # Vodafone
4011
+ '173', # Vodafone
4012
+ '174', # Vodafone
4013
+ '175', # T-Mobile
4014
+ '176', # O2 Germany
4015
+ '177', # E-Plus
4016
+ '178', # E-Plus
4017
+ '179', # O2 Germany
4018
+ ]
4019
+
4020
+ mobile_4digits = [
4021
+ '1520', # Vodafone
4022
+ '1521', # Lycamobile
4023
+ '1522', # Vodafone
4024
+ '1523', # Vodafone
4025
+ '1570', # vistream
4026
+ '1577', # E-Plus
4027
+ '1672', # Dolphin Telecom
4028
+ ]
4029
+
4020
4030
  service = [
4021
4031
  '12', # Innovative Services
4022
4032
  '130',
@@ -4065,9 +4075,23 @@ service = [
4065
4075
  '9009',
4066
4076
  ]
4067
4077
 
4078
+ # Note:
4079
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_Germany
4080
+ # http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000510001PDFE.pdf
4081
+ # "Numbers assigned in the past, which are generally grandfathered, may be as short as five digits."
4082
+ #
4083
+ # http://www.bundesnetzagentur.de/cln_1422/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/Rufnummern_node.html
4084
+ #
4085
+ # TODO Define lower end of last part correctly.
4086
+ #
4068
4087
  Phony.define do
4069
- country '49', one_of(service) >> split(3,10) |
4070
- match(/^(1[567]\d)\d*$/) >> split(3,10) | # Mobile
4071
- one_of(ndcs) >> split(3,10) |
4072
- fixed(5) >> split(3,10)
4073
- end
4088
+ country '49',
4089
+ trunk('0', normalize: true) |
4090
+ one_of(*service) >> split(3,1..9) |
4091
+ one_of(*mobile_4digits) >> split(3,4) |
4092
+ one_of(*mobile_3digits) >> split(4,3..4) |
4093
+ one_of(*ndcs2) >> split(3,1..10) |
4094
+ one_of(*ndcs3) >> split(3,1..9) |
4095
+ one_of(*ndcs4) >> split(3,0..8) |
4096
+ fixed(5) >> split(3,0..7)
4097
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Guinea (sometimes Guinea-Conakry; officially Republic of Guinea)
4
+ # http://www.itu.int/oth/T020200005B/en
5
+
6
+ land_ndcs_with_4_digits = [
7
+ '3031', # Boké
8
+ '3046', # Boussoura
9
+ *['3041', '3043', '3045', '3047'], # Conakry
10
+ '3069', # Delaba
11
+ '3081', # Faranah
12
+ '3024', # Fria
13
+ '3097', # Guéckédou
14
+ '3032', # Kamsar
15
+ '3071', # Kankan
16
+ '3061', # Kindia
17
+ '3098', # Kissidougou
18
+ '3051', # Labé
19
+ '3094', # Macenta
20
+ '3068', # Mamou
21
+ '3091', # N'Zérékoré
22
+ '3053', # Pita
23
+ '3042' # Sangoya
24
+ ]
25
+
26
+ land_ndcs_with_5_digits = [
27
+ '30613' # Télimélé
28
+ ]
29
+
30
+ # NOTE We're not using *('660'..'669') since it does not freeze easily.
31
+ mobile_ndcs_with_3_digits = [
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
37
+ ]
38
+
39
+ Phony.define do
40
+ country '224',
41
+ one_of(land_ndcs_with_5_digits) >> split(2, 2) | # 2-2-2-2
42
+ one_of(land_ndcs_with_4_digits) >> split(2, 2) | # 2-2-2-2
43
+ one_of(mobile_ndcs_with_3_digits) >> split(2, 2, 2) | # 3-2-2-2
44
+ match(/^(7\d{2})\d{6}/) >> split(2, 2, 2) | # voip numbers
45
+ fixed(3) >> split(2, 2, 2)
46
+ end