phony 2.18.3 → 2.20.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +5 -1
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +2 -2
- data/lib/phony/countries/cambodia.rb +1 -5
- data/lib/phony/countries/china.rb +5 -2
- data/lib/phony/countries/germany.rb +1 -1
- data/lib/phony/countries/ireland.rb +6 -4
- data/lib/phony/countries/italy.rb +34 -17
- data/lib/phony/countries/japan.rb +58 -8
- data/lib/phony/countries/libya.rb +1 -1
- data/lib/phony/countries/serbia.rb +5 -1
- data/lib/phony/countries/taiwan.rb +1 -0
- data/lib/phony/countries/vietnam.rb +1 -0
- data/lib/phony/countries.rb +83 -53
- data/lib/phony/country.rb +8 -2
- data/lib/phony/country_codes.rb +15 -2
- data/lib/phony/dsl.rb +2 -2
- 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 +1 -0
- data/spec/functional/config_spec.rb +5 -5
- data/spec/functional/plausibility_spec.rb +82 -16
- data/spec/lib/phony/countries_spec.rb +86 -23
- 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 +6 -2
- data/spec/lib/phony/local_splitters/regex_spec.rb +12 -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
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 443ce0ac52dcde0ab0b419d6c49123ac60fdb6525ce56df52c09102b2a1b79af
|
4
|
+
data.tar.gz: 3db5d454a9c112ad429b1c0986379bae3230685bcc795aaedf5c0f7feba2a902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0081748a294e804a1e1870dc40bc9e4359733f25f54e73dbbf2ad7fd01661af91e6724fa550dc61a29f4ff0c2f3b2b9161160657c852493e63afbdc839f7ae7
|
7
|
+
data.tar.gz: 0f371abf103cd53b85093973e96cbf3ae91d9d44b3e4e1b7db51826ce2a9f818252d9774cdd81abcdcf5f893dd696cf2649b70a0e7960164e8f02b4ca8618088
|
data/README.textile
CHANGED
@@ -104,7 +104,11 @@ For example, when just loading the NANP CC, the retained memory usage is ~63kB.
|
|
104
104
|
|
105
105
|
h2. List of Handled Countries
|
106
106
|
|
107
|
-
Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
|
107
|
+
Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
|
108
|
+
|
109
|
+
h2. Proud Sponsors
|
110
|
+
|
111
|
+
* Renuo AG (July 22 –): "Github":https://github.com/renuo, "Homepage":https://www.renuo.ch
|
108
112
|
|
109
113
|
h2. License
|
110
114
|
|
@@ -0,0 +1,355 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Argentinian numbers are all ten digits long.
|
4
|
+
# Information taken from:
|
5
|
+
# https://www.enacom.gob.ar/multimedia/normativas/1997/Resolucion%2046_97.pdf
|
6
|
+
# http://www.wtng.info/wtng-54-ar.html
|
7
|
+
# https://en.wikipedia.org/wiki/Telephone_numbers_in_Argentina
|
8
|
+
# Area codes collected from https://www.enacom.gob.ar/indicativos-interurbanos_p366 (06/27/19)
|
9
|
+
|
10
|
+
|
11
|
+
# Landline
|
12
|
+
area_codes_2digits = [
|
13
|
+
'11',
|
14
|
+
]
|
15
|
+
|
16
|
+
area_codes_3digits = [
|
17
|
+
'220',
|
18
|
+
'221',
|
19
|
+
'223',
|
20
|
+
'230',
|
21
|
+
'236',
|
22
|
+
'237',
|
23
|
+
'249',
|
24
|
+
'260',
|
25
|
+
'261',
|
26
|
+
'263',
|
27
|
+
'264',
|
28
|
+
'266',
|
29
|
+
'280',
|
30
|
+
'291',
|
31
|
+
'294',
|
32
|
+
'297',
|
33
|
+
'298',
|
34
|
+
'299',
|
35
|
+
'336',
|
36
|
+
'341',
|
37
|
+
'342',
|
38
|
+
'343',
|
39
|
+
'345',
|
40
|
+
'348',
|
41
|
+
'351',
|
42
|
+
'353',
|
43
|
+
'358',
|
44
|
+
'362',
|
45
|
+
'364',
|
46
|
+
'370',
|
47
|
+
'376',
|
48
|
+
'379',
|
49
|
+
'380',
|
50
|
+
'381',
|
51
|
+
'383',
|
52
|
+
'385',
|
53
|
+
'387',
|
54
|
+
'388',
|
55
|
+
]
|
56
|
+
|
57
|
+
area_codes_4digits = [
|
58
|
+
'2202',
|
59
|
+
'2221',
|
60
|
+
'2223',
|
61
|
+
'2224',
|
62
|
+
'2225',
|
63
|
+
'2226',
|
64
|
+
'2227',
|
65
|
+
'2229',
|
66
|
+
'2241',
|
67
|
+
'2242',
|
68
|
+
'2243',
|
69
|
+
'2244',
|
70
|
+
'2245',
|
71
|
+
'2246',
|
72
|
+
'2252',
|
73
|
+
'2254',
|
74
|
+
'2255',
|
75
|
+
'2257',
|
76
|
+
'2261',
|
77
|
+
'2262',
|
78
|
+
'2264',
|
79
|
+
'2265',
|
80
|
+
'2266',
|
81
|
+
'2267',
|
82
|
+
'2268',
|
83
|
+
'2271',
|
84
|
+
'2272',
|
85
|
+
'2273',
|
86
|
+
'2274',
|
87
|
+
'2281',
|
88
|
+
'2283',
|
89
|
+
'2284',
|
90
|
+
'2285',
|
91
|
+
'2286',
|
92
|
+
'2291',
|
93
|
+
'2292',
|
94
|
+
'2296',
|
95
|
+
'2297',
|
96
|
+
'2302',
|
97
|
+
'2314',
|
98
|
+
'2316',
|
99
|
+
'2317',
|
100
|
+
'2320',
|
101
|
+
'2323',
|
102
|
+
'2324',
|
103
|
+
'2325',
|
104
|
+
'2326',
|
105
|
+
'2331',
|
106
|
+
'2333',
|
107
|
+
'2334',
|
108
|
+
'2335',
|
109
|
+
'2336',
|
110
|
+
'2337',
|
111
|
+
'2338',
|
112
|
+
'2342',
|
113
|
+
'2343',
|
114
|
+
'2344',
|
115
|
+
'2345',
|
116
|
+
'2346',
|
117
|
+
'2352',
|
118
|
+
'2353',
|
119
|
+
'2354',
|
120
|
+
'2355',
|
121
|
+
'2356',
|
122
|
+
'2357',
|
123
|
+
'2358',
|
124
|
+
'2392',
|
125
|
+
'2393',
|
126
|
+
'2394',
|
127
|
+
'2395',
|
128
|
+
'2396',
|
129
|
+
'2473',
|
130
|
+
'2474',
|
131
|
+
'2475',
|
132
|
+
'2477',
|
133
|
+
'2478',
|
134
|
+
'2622',
|
135
|
+
'2624',
|
136
|
+
'2625',
|
137
|
+
'2626',
|
138
|
+
'2646',
|
139
|
+
'2647',
|
140
|
+
'2648',
|
141
|
+
'2651',
|
142
|
+
'2655',
|
143
|
+
'2656',
|
144
|
+
'2657',
|
145
|
+
'2658',
|
146
|
+
'2901',
|
147
|
+
'2902',
|
148
|
+
'2903',
|
149
|
+
'2920',
|
150
|
+
'2921',
|
151
|
+
'2922',
|
152
|
+
'2923',
|
153
|
+
'2924',
|
154
|
+
'2925',
|
155
|
+
'2926',
|
156
|
+
'2927',
|
157
|
+
'2928',
|
158
|
+
'2929',
|
159
|
+
'2931',
|
160
|
+
'2932',
|
161
|
+
'2933',
|
162
|
+
'2934',
|
163
|
+
'2935',
|
164
|
+
'2936',
|
165
|
+
'2940',
|
166
|
+
'2942',
|
167
|
+
'2945',
|
168
|
+
'2946',
|
169
|
+
'2948',
|
170
|
+
'2952',
|
171
|
+
'2953',
|
172
|
+
'2954',
|
173
|
+
'2962',
|
174
|
+
'2963',
|
175
|
+
'2964',
|
176
|
+
'2966',
|
177
|
+
'2972',
|
178
|
+
'2982',
|
179
|
+
'2983',
|
180
|
+
'3327',
|
181
|
+
'3329',
|
182
|
+
'3382',
|
183
|
+
'3385',
|
184
|
+
'3387',
|
185
|
+
'3388',
|
186
|
+
'3400',
|
187
|
+
'3401',
|
188
|
+
'3402',
|
189
|
+
'3404',
|
190
|
+
'3405',
|
191
|
+
'3406',
|
192
|
+
'3407',
|
193
|
+
'3408',
|
194
|
+
'3409',
|
195
|
+
'3435',
|
196
|
+
'3436',
|
197
|
+
'3437',
|
198
|
+
'3438',
|
199
|
+
'3442',
|
200
|
+
'3444',
|
201
|
+
'3445',
|
202
|
+
'3446',
|
203
|
+
'3447',
|
204
|
+
'3454',
|
205
|
+
'3455',
|
206
|
+
'3456',
|
207
|
+
'3458',
|
208
|
+
'3460',
|
209
|
+
'3462',
|
210
|
+
'3463',
|
211
|
+
'3464',
|
212
|
+
'3465',
|
213
|
+
'3466',
|
214
|
+
'3467',
|
215
|
+
'3468',
|
216
|
+
'3469',
|
217
|
+
'3471',
|
218
|
+
'3472',
|
219
|
+
'3476',
|
220
|
+
'3482',
|
221
|
+
'3483',
|
222
|
+
'3487',
|
223
|
+
'3489',
|
224
|
+
'3491',
|
225
|
+
'3492',
|
226
|
+
'3493',
|
227
|
+
'3496',
|
228
|
+
'3497',
|
229
|
+
'3498',
|
230
|
+
'3521',
|
231
|
+
'3522',
|
232
|
+
'3524',
|
233
|
+
'3525',
|
234
|
+
'3532',
|
235
|
+
'3533',
|
236
|
+
'3537',
|
237
|
+
'3541',
|
238
|
+
'3542',
|
239
|
+
'3543',
|
240
|
+
'3544',
|
241
|
+
'3546',
|
242
|
+
'3547',
|
243
|
+
'3548',
|
244
|
+
'3549',
|
245
|
+
'3562',
|
246
|
+
'3563',
|
247
|
+
'3564',
|
248
|
+
'3571',
|
249
|
+
'3572',
|
250
|
+
'3573',
|
251
|
+
'3574',
|
252
|
+
'3575',
|
253
|
+
'3576',
|
254
|
+
'3582',
|
255
|
+
'3583',
|
256
|
+
'3584',
|
257
|
+
'3585',
|
258
|
+
'3711',
|
259
|
+
'3715',
|
260
|
+
'3716',
|
261
|
+
'3718',
|
262
|
+
'3721',
|
263
|
+
'3725',
|
264
|
+
'3731',
|
265
|
+
'3734',
|
266
|
+
'3735',
|
267
|
+
'3741',
|
268
|
+
'3743',
|
269
|
+
'3751',
|
270
|
+
'3754',
|
271
|
+
'3755',
|
272
|
+
'3756',
|
273
|
+
'3757',
|
274
|
+
'3758',
|
275
|
+
'3772',
|
276
|
+
'3773',
|
277
|
+
'3774',
|
278
|
+
'3775',
|
279
|
+
'3777',
|
280
|
+
'3781',
|
281
|
+
'3782',
|
282
|
+
'3786',
|
283
|
+
'3821',
|
284
|
+
'3825',
|
285
|
+
'3826',
|
286
|
+
'3827',
|
287
|
+
'3832',
|
288
|
+
'3835',
|
289
|
+
'3837',
|
290
|
+
'3838',
|
291
|
+
'3841',
|
292
|
+
'3843',
|
293
|
+
'3844',
|
294
|
+
'3845',
|
295
|
+
'3846',
|
296
|
+
'3854',
|
297
|
+
'3855',
|
298
|
+
'3856',
|
299
|
+
'3857',
|
300
|
+
'3858',
|
301
|
+
'3861',
|
302
|
+
'3862',
|
303
|
+
'3863',
|
304
|
+
'3865',
|
305
|
+
'3867',
|
306
|
+
'3868',
|
307
|
+
'3869',
|
308
|
+
'3873',
|
309
|
+
'3876',
|
310
|
+
'3877',
|
311
|
+
'3878',
|
312
|
+
'3885',
|
313
|
+
'3886',
|
314
|
+
'3887',
|
315
|
+
'3888',
|
316
|
+
'3891',
|
317
|
+
'3892',
|
318
|
+
'3894',
|
319
|
+
]
|
320
|
+
|
321
|
+
# Mobile
|
322
|
+
# Mobile phone numbers in Argentina are assigned the same geographic area codes as fixed lines,
|
323
|
+
# according to the subscriber's choice or residence, and can be 6, 7 or 8 digits long, just as
|
324
|
+
# landline numbers are. The difference with landline numbers is that a prefix 15, never used for
|
325
|
+
# landlines, must be dialed.
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
# International: +54 + 9 + area code + subscriber number (without '15' prefix)
|
330
|
+
# Domestic: area code + 15 + subscriber number
|
331
|
+
# Mobile numbers in Argentina may be listed as 15-xxxxxxx. However, the leading '15'
|
332
|
+
# is a domestic prefix which must be omitted when calling these from outside Argentina,
|
333
|
+
# with the xxxxxxx being the actual subscriber number portion.
|
334
|
+
|
335
|
+
# Non-geographic numbers 0ppp-nnn-nnnn
|
336
|
+
special_numbers = [
|
337
|
+
'800', # toll-free telephone numbers
|
338
|
+
'810', # calls from any area chargeable at local rate
|
339
|
+
'822', # toll-free numbers used for calling card access
|
340
|
+
'600', # premium-rate telephone numbers
|
341
|
+
'609', # premium, fixed-rate gaming numbers
|
342
|
+
'610', # dial-up Internet access numbers, usually cheaper than a local call, less frequently used as dial-up Internet access decreased
|
343
|
+
'605', # premium-rate telephone numbers for charity donations
|
344
|
+
]
|
345
|
+
|
346
|
+
Phony.define do
|
347
|
+
country '54', trunk('0') |
|
348
|
+
one_of(area_codes_4digits) >> split(2, 4) | # landline
|
349
|
+
one_of(area_codes_3digits) >> split(3, 4) | # landline
|
350
|
+
one_of(area_codes_2digits) >> split(4, 4) | # landline
|
351
|
+
one_of(area_codes_2digits.map{|x| "9#{x}" }) >> split(4, 4) | # mobile
|
352
|
+
one_of(area_codes_3digits.map{|x| "9#{x}" }) >> split(3, 4) | # mobile
|
353
|
+
one_of(area_codes_4digits.map{|x| "9#{x}" }) >> split(2, 4) | # mobile
|
354
|
+
one_of(special_numbers) >> split(3, 4)
|
355
|
+
end
|
@@ -85,7 +85,7 @@ service = [
|
|
85
85
|
'939'
|
86
86
|
]
|
87
87
|
|
88
|
-
# https://www.rtr.at/en/tk/E129/
|
88
|
+
# https://www.rtr.at/en/tk/E129/Austrian_Numbering_Plan_2011-03-30.pdf
|
89
89
|
#
|
90
90
|
# TODO Add more details.
|
91
91
|
#
|
@@ -97,7 +97,7 @@ Phony.define do
|
|
97
97
|
one_of('800') >> split(6..10) | # Free number length is 9..13
|
98
98
|
one_of(corporate_2digit) >> split(3..11) | # Corporate number length is 5..13
|
99
99
|
one_of(corporate) >> split(2..10) | # Corporate number length is 5..13
|
100
|
-
one_of(ndcs) >> split(
|
100
|
+
one_of(ndcs) >> split(5..10) |
|
101
101
|
one_of('663') >> split(6..8) | # 6..8 digit mobile.
|
102
102
|
one_of(mobile) >> split(4,3..9) |
|
103
103
|
one_of(mobile_2digit) >> split(7..7) | # Separate as mobile contains 676 - 67 violates the prefix rule.
|
@@ -71,6 +71,7 @@ six_digit_extended_range_mobile_prefixes = [
|
|
71
71
|
]
|
72
72
|
|
73
73
|
seven_digit_mobile_prefixes = [
|
74
|
+
'18', # Seatel
|
74
75
|
'31', # Metfone
|
75
76
|
'38', # CooTel
|
76
77
|
'39', # EMAXX
|
@@ -85,10 +86,6 @@ variable_length_extended_range_mobile_prefixes = [
|
|
85
86
|
'12' # Mobitel
|
86
87
|
]
|
87
88
|
|
88
|
-
mobile_prefixes_with_variable_length = [
|
89
|
-
'18' # Seatel
|
90
|
-
]
|
91
|
-
|
92
89
|
six_digit_total_single_digit_fixed_line_prefixes = [
|
93
90
|
'2', # Telecom Cambodia
|
94
91
|
'3', # Mobitel
|
@@ -126,7 +123,6 @@ seven_digit_total_double_digit_fixed_line_prefixes = [
|
|
126
123
|
|
127
124
|
Phony.define do
|
128
125
|
country '855', trunk('0', :normalize => true) |
|
129
|
-
one_of(mobile_prefixes_with_variable_length) >> matched_split(/^9/ => [3, 4], /^[2-8]/ => [3, 3]) |
|
130
126
|
one_of(variable_length_extended_range_mobile_prefixes) >> matched_split(/^1/ => [3, 4], /^[2-9]/ => [3, 3]) |
|
131
127
|
one_of(six_digit_mobile_prefixes) >> matched_split(/^[2-9]/ => [3, 3]) |
|
132
128
|
one_of(six_digit_extended_range_mobile_prefixes) >> matched_split(/^[1-9]/ => [3, 3]) |
|
@@ -19,7 +19,7 @@ ndcs = [
|
|
19
19
|
'28', # Chengdu
|
20
20
|
'29', # Xi'an
|
21
21
|
]
|
22
|
-
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 }
|
23
23
|
service = %w{ 110 114 119 120 122 999 } # Probably not exhaustive. TODO Look at http://www.eoc.com.cn/?action-viewnews-itemid-11493.
|
24
24
|
|
25
25
|
Phony.define do
|
@@ -28,5 +28,8 @@ Phony.define do
|
|
28
28
|
one_of(service) >> split(8) |
|
29
29
|
one_of(mobile) >> split(4,4) |
|
30
30
|
one_of(ndcs) >> split(4,4) |
|
31
|
-
fixed(3) >>
|
31
|
+
fixed(3) >> matched_split(
|
32
|
+
/\A\d{7}\z/ => [3,4],
|
33
|
+
/\A\d{8}\z/ => [4,4]
|
34
|
+
)
|
32
35
|
end
|
@@ -4090,7 +4090,7 @@ Phony.define do
|
|
4090
4090
|
one_of(*service) >> split(3,1..9) |
|
4091
4091
|
one_of(*mobile_4digits) >> split(3,4) |
|
4092
4092
|
one_of(*mobile_3digits) >> split(4,3..4) |
|
4093
|
-
one_of(*ndcs2) >> split(3,
|
4093
|
+
one_of(*ndcs2) >> split(3,1..10) |
|
4094
4094
|
one_of(*ndcs3) >> split(3,1..9) |
|
4095
4095
|
one_of(*ndcs4) >> split(3,0..8) |
|
4096
4096
|
fixed(5) >> split(3,0..7)
|
@@ -9,14 +9,14 @@
|
|
9
9
|
#
|
10
10
|
# References:
|
11
11
|
# http://www.comreg.ie/_fileupload/publications/ComReg03147.pdf (2003)
|
12
|
+
# https://www.comreg.ie/media/dlm_uploads/2015/12/ComReg0804.pdf (2008)
|
12
13
|
# http://www.comreg.ie/licensing_and_services/area_code_maps.552.1040.html
|
13
14
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_the_Republic_of_Ireland
|
14
15
|
#
|
15
16
|
ndcs_with_5_subscriber_digits = [
|
16
|
-
'22', '
|
17
|
+
'22', '24', '25', '26', '27', '28', '29', # Mallow, Youghal, Fermoy, Macroom, Bantry, Skibbereen, Kanturk
|
17
18
|
'402', # Arklow
|
18
19
|
'404', # Wicklow
|
19
|
-
'43', # Longford, Granard
|
20
20
|
'47', # Monaghan, Clones
|
21
21
|
'48', # Northern Ireland
|
22
22
|
'502', # Portlaoise, Abbeyleix
|
@@ -24,12 +24,10 @@ ndcs_with_5_subscriber_digits = [
|
|
24
24
|
'505', # Roscrea
|
25
25
|
'506', # Tullamore
|
26
26
|
'509', # Bin-
|
27
|
-
'52', # Killenaule
|
28
27
|
'54', # Legacy Ferns, Enniscorthy
|
29
28
|
'55', # Legacy Gorey
|
30
29
|
'62', # Tipperary, Cashel
|
31
30
|
'63', # Charleville
|
32
|
-
'64', # Killarney, Rathmore
|
33
31
|
'67', # Nenagh
|
34
32
|
'68', # Listowel
|
35
33
|
'69', # Newcastle West
|
@@ -47,15 +45,19 @@ ndcs_with_6_subscriber_digits = [
|
|
47
45
|
ndcs_with_7_subscriber_digits = [
|
48
46
|
'1', # Dublin
|
49
47
|
'21', # Cork, Coachford, Kinsale
|
48
|
+
'23', # Bandon
|
50
49
|
'41', # Ardee
|
51
50
|
'42', # Dundalk, Carrickmacross, Castleblaney
|
51
|
+
'43', # Longford, Granard
|
52
52
|
'44', # Mullingar, Castlepollard, Tyrellspass
|
53
53
|
'46', # Navan, Kells, Trim, Enfield, Edenderry
|
54
54
|
'49', # Cavan, Cootehill, Oldcastle, Belturbet
|
55
|
+
'52', # Killenaule
|
55
56
|
'53', # Wexford, Enniscorthy, Ferns, Gorey, Craanford
|
56
57
|
'56', # Kilkenny, Castlecomer
|
57
58
|
'58', # Dungarvan
|
58
59
|
'59', # Carlow, Muine Bheag, Athy, Baltinglass
|
60
|
+
'64', # Killarney, Rathmore
|
59
61
|
'65', # Ennistymon, Kilrush
|
60
62
|
'66', # Tralee, Dingle, Killorglin, Cahirciveen
|
61
63
|
'71', # Sligo, Manorhamilton, Carrick-on-Shannon
|
@@ -3,14 +3,14 @@
|
|
3
3
|
# Italian phone numbers.
|
4
4
|
#
|
5
5
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Italy
|
6
|
-
#
|
6
|
+
# https://www.itu.int/dms_pub/itu-t/oth/02/02/T020200006B0001PDFE.pdf
|
7
7
|
|
8
|
-
|
8
|
+
ndcs_1digit = [
|
9
9
|
'02', # Milan
|
10
10
|
'06', # Rome (including State of Vatican City) and Aprilia
|
11
11
|
]
|
12
12
|
|
13
|
-
|
13
|
+
ndcs_2digit = [
|
14
14
|
'010', # Genoa
|
15
15
|
'011', # Turin
|
16
16
|
'015', # Biella
|
@@ -42,7 +42,7 @@ ndcs_3digit = [
|
|
42
42
|
'099', # Taranto
|
43
43
|
]
|
44
44
|
|
45
|
-
|
45
|
+
ndcs_3digit = [
|
46
46
|
'0121', # Pinerolo
|
47
47
|
'0122', # Sestrieres, Bardonecchia and other Susa Valley mountain resorts
|
48
48
|
'0123', # Lanzo Torinese
|
@@ -256,7 +256,8 @@ ndcs_4digit = [
|
|
256
256
|
# but this was not frozen so easily.
|
257
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)
|
258
258
|
|
259
|
-
|
259
|
+
# Not exhaustive.
|
260
|
+
service = [
|
260
261
|
'112',
|
261
262
|
'113',
|
262
263
|
'115',
|
@@ -268,21 +269,37 @@ service = [ # Not exhaustive.
|
|
268
269
|
'1530'
|
269
270
|
]
|
270
271
|
|
272
|
+
# Not exhaustive. Unused below - just for info purposes.
|
273
|
+
free_of_charge_services = [
|
274
|
+
'800',
|
275
|
+
'803'
|
276
|
+
]
|
277
|
+
|
271
278
|
Phony.define do
|
272
|
-
|
279
|
+
# Note: The 0 does not count towards NDC number length.
|
280
|
+
country '39', trunk('', normalize: false) |
|
273
281
|
one_of(*service) >> split(3,3) |
|
274
282
|
one_of(*mobile) >> split(3,4,-1..1) |
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
283
|
+
match(/^(800)\d{6}$/) >> split(6) | # 3-6, Special handling for 800 numbers.
|
284
|
+
match(/^(803)\d{3}$/) >> split(3) | # 3-3, Special handling for 803 numbers.
|
285
|
+
one_of(*ndcs_1digit) >> matched_split(
|
286
|
+
/\A\d{5}\z/ => [5],
|
287
|
+
/\A\d{6}\z/ => [4,2],
|
288
|
+
/\A\d{7}\z/ => [4,3],
|
289
|
+
/\A\d{8}\z/ => [4,4],
|
281
290
|
) |
|
282
|
-
one_of(*
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
291
|
+
one_of(*ndcs_2digit) >> matched_split(
|
292
|
+
/\A\d{4}\z/ => [4],
|
293
|
+
/\A\d{5}\z/ => [5],
|
294
|
+
/\A\d{6}\z/ => [6],
|
295
|
+
/\A\d{7}\z/ => [7],
|
296
|
+
/\A\d{8}\z/ => [8]
|
297
|
+
) |
|
298
|
+
one_of(*ndcs_3digit) >> matched_split(
|
299
|
+
/\A\d{4}\z/ => [4],
|
300
|
+
/\A1\d{5}\z/ => [6],
|
301
|
+
/\A1\d{6}\z/ => [7],
|
302
|
+
/\A[^1]\d{4}\z/ => [5],
|
303
|
+
/\A[^1]\d{5}\z/ => [3,3]
|
287
304
|
)
|
288
305
|
end
|