phony 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/phony.rb +2 -1
- data/lib/phony/countries.rb +280 -280
- data/lib/phony/country_codes.rb +10 -2
- data/lib/phony/dsl.rb +4 -1
- data/lib/phony/national_splitters/default.rb +17 -0
- data/spec/lib/phony_spec.rb +20 -1
- metadata +4 -3
data/lib/phony.rb
CHANGED
@@ -8,6 +8,7 @@ require File.expand_path '../phony/national_splitters/fixed', __FILE__
|
|
8
8
|
require File.expand_path '../phony/national_splitters/variable', __FILE__
|
9
9
|
require File.expand_path '../phony/national_splitters/regex', __FILE__
|
10
10
|
require File.expand_path '../phony/national_splitters/none', __FILE__
|
11
|
+
require File.expand_path '../phony/national_splitters/default', __FILE__
|
11
12
|
require File.expand_path '../phony/national_code', __FILE__
|
12
13
|
require File.expand_path '../phony/country', __FILE__
|
13
14
|
require File.expand_path '../phony/country_codes', __FILE__
|
@@ -96,4 +97,4 @@ module Phony
|
|
96
97
|
|
97
98
|
end
|
98
99
|
|
99
|
-
end
|
100
|
+
end
|
data/lib/phony/countries.rb
CHANGED
@@ -150,7 +150,7 @@ Phony.define do
|
|
150
150
|
|
151
151
|
# TODO Colombia.
|
152
152
|
#
|
153
|
-
country '57',
|
153
|
+
country '57', default
|
154
154
|
|
155
155
|
# Venezuela (Bolivarian Republic of)
|
156
156
|
#
|
@@ -162,8 +162,8 @@ Phony.define do
|
|
162
162
|
#
|
163
163
|
country '61', match(/^(4\d\d)\d+$/) >> split(3,3) | # Mobile
|
164
164
|
fixed(1) >> split(4,4) # Rest
|
165
|
-
country '62',
|
166
|
-
country '63',
|
165
|
+
country '62', default # TODO Indonesia (Republic of)
|
166
|
+
country '63', default # TODO Philippines (Republic of the)
|
167
167
|
|
168
168
|
# New Zealand.
|
169
169
|
#
|
@@ -171,14 +171,14 @@ Phony.define do
|
|
171
171
|
#
|
172
172
|
country '64', fixed(1) >> split(3,4)
|
173
173
|
|
174
|
-
country '65',
|
175
|
-
country '66',
|
174
|
+
country '65', default # TODO Singapore (Republic of)
|
175
|
+
country '66', default # TODO Thailand
|
176
176
|
|
177
|
-
country '81',
|
177
|
+
country '81', default # TODO Japan
|
178
178
|
|
179
179
|
# country '82' # SouthKorea, see special file.
|
180
180
|
|
181
|
-
country '84',
|
181
|
+
country '84', default # TODO Viet Nam (Socialist Republic of)
|
182
182
|
|
183
183
|
# country '86' # China, see special file.
|
184
184
|
|
@@ -186,8 +186,8 @@ Phony.define do
|
|
186
186
|
#
|
187
187
|
country '90', fixed(3) >> split(3,4) # Wiki says 7, but the examples say 3, 4.
|
188
188
|
|
189
|
-
country '91',
|
190
|
-
country '92',
|
189
|
+
country '91', default # TODO India (Republic of)
|
190
|
+
country '92', default # TODO Pakistan (Islamic Republic of), http://en.wikipedia.org/wiki/Telephone_numbers_in_Pakistan, NDC 2-5
|
191
191
|
|
192
192
|
# Afghanistan.
|
193
193
|
#
|
@@ -199,95 +199,95 @@ Phony.define do
|
|
199
199
|
country '95', fixed(2) >> split(3,2,2) # TODO Myanmar (Union of)
|
200
200
|
country '98', fixed(2) >> split(3,2,2) # TODO Iran (Islamic Republic of)
|
201
201
|
|
202
|
-
country '210',
|
203
|
-
country '211',
|
204
|
-
country '212',
|
202
|
+
country '210', default # -
|
203
|
+
country '211', default # -
|
204
|
+
country '212', default # Morocco
|
205
205
|
country '213', fixed(2) >> split(3,4) # Algeria
|
206
|
-
country '214',
|
207
|
-
country '215',
|
206
|
+
country '214', default # -
|
207
|
+
country '215', default # -
|
208
208
|
country '216', fixed(1) >> split(3,4) # Tunisia
|
209
|
-
country '217',
|
210
|
-
country '218',
|
211
|
-
country '219',
|
212
|
-
|
213
|
-
country '220',
|
214
|
-
country '221',
|
215
|
-
country '222',
|
216
|
-
country '223',
|
217
|
-
country '224',
|
218
|
-
country '225',
|
219
|
-
country '226',
|
220
|
-
country '227',
|
221
|
-
country '228',
|
222
|
-
country '229',
|
223
|
-
|
224
|
-
country '230',
|
225
|
-
country '231',
|
226
|
-
country '232',
|
227
|
-
country '233',
|
228
|
-
country '234',
|
229
|
-
country '235',
|
230
|
-
country '236',
|
231
|
-
country '237',
|
232
|
-
country '238',
|
233
|
-
country '239',
|
234
|
-
|
235
|
-
country '240',
|
236
|
-
country '241',
|
237
|
-
country '242',
|
238
|
-
country '243',
|
239
|
-
country '244',
|
240
|
-
country '245',
|
241
|
-
country '246',
|
242
|
-
country '247',
|
243
|
-
country '248',
|
244
|
-
country '249',
|
245
|
-
|
246
|
-
country '250',
|
247
|
-
country '251',
|
248
|
-
country '252',
|
249
|
-
country '253',
|
250
|
-
country '254',
|
251
|
-
country '255',
|
252
|
-
country '256',
|
253
|
-
country '257',
|
254
|
-
country '258',
|
255
|
-
country '259',
|
256
|
-
|
257
|
-
country '260',
|
258
|
-
country '261',
|
259
|
-
country '262',
|
260
|
-
country '263',
|
261
|
-
country '264',
|
262
|
-
country '265',
|
263
|
-
country '266',
|
264
|
-
country '267',
|
265
|
-
country '268',
|
266
|
-
country '269',
|
267
|
-
|
268
|
-
country '280',
|
269
|
-
country '281',
|
270
|
-
country '282',
|
271
|
-
country '283',
|
272
|
-
country '284',
|
273
|
-
country '285',
|
274
|
-
country '286',
|
275
|
-
country '287',
|
276
|
-
country '288',
|
277
|
-
country '289',
|
278
|
-
country '290',
|
279
|
-
|
280
|
-
country '291',
|
281
|
-
country '292',
|
282
|
-
country '293',
|
283
|
-
country '294',
|
284
|
-
country '295',
|
285
|
-
country '296',
|
286
|
-
country '297',
|
287
|
-
country '298',
|
288
|
-
country '299',
|
289
|
-
|
290
|
-
country '350',
|
209
|
+
country '217', default # -
|
210
|
+
country '218', default # Lybia
|
211
|
+
country '219', default # -
|
212
|
+
|
213
|
+
country '220', default # Gambia
|
214
|
+
country '221', default # Senegal
|
215
|
+
country '222', default # Mauritania
|
216
|
+
country '223', default # Mali
|
217
|
+
country '224', default # Guinea
|
218
|
+
country '225', default # Côte d'Ivoire
|
219
|
+
country '226', default # Burkina Faso
|
220
|
+
country '227', default # Niger
|
221
|
+
country '228', default # Togolese Republic
|
222
|
+
country '229', default # Benin
|
223
|
+
|
224
|
+
country '230', default # Mauritius
|
225
|
+
country '231', default # Liberia
|
226
|
+
country '232', default # Sierra Leone
|
227
|
+
country '233', default # Ghana
|
228
|
+
country '234', default # Nigeria
|
229
|
+
country '235', default # Chad
|
230
|
+
country '236', default # Central African Republic
|
231
|
+
country '237', default # Cameroon
|
232
|
+
country '238', default # Cape Verde
|
233
|
+
country '239', default # Sao Tome and Principe
|
234
|
+
|
235
|
+
country '240', default # Equatorial Guinea
|
236
|
+
country '241', default # Gabonese Republic
|
237
|
+
country '242', default # Congo
|
238
|
+
country '243', default # Democratic Republic of the Congo
|
239
|
+
country '244', default # Angola
|
240
|
+
country '245', default # Guinea-Bissau
|
241
|
+
country '246', default # Diego Garcia
|
242
|
+
country '247', default # Ascension
|
243
|
+
country '248', default # Seychelles
|
244
|
+
country '249', default # Sudan
|
245
|
+
|
246
|
+
country '250', default # Rwanda
|
247
|
+
country '251', default # Ethiopia
|
248
|
+
country '252', default # Somali Democratic Republic
|
249
|
+
country '253', default # Djibouti
|
250
|
+
country '254', default # Kenya
|
251
|
+
country '255', default # Tanzania
|
252
|
+
country '256', default # Uganda
|
253
|
+
country '257', default # Burundi
|
254
|
+
country '258', default # Mozambique
|
255
|
+
country '259', default # -
|
256
|
+
|
257
|
+
country '260', default # Zambia
|
258
|
+
country '261', default # Madagascar
|
259
|
+
country '262', default # Reunion / Mayotte (new)
|
260
|
+
country '263', default # Zimbabwe
|
261
|
+
country '264', default # Namibia
|
262
|
+
country '265', default # Malawi
|
263
|
+
country '266', default # Lesotho
|
264
|
+
country '267', default # Botswana
|
265
|
+
country '268', default # Swaziland
|
266
|
+
country '269', default # Comoros
|
267
|
+
|
268
|
+
country '280', default # -
|
269
|
+
country '281', default # -
|
270
|
+
country '282', default # -
|
271
|
+
country '283', default # -
|
272
|
+
country '284', default # -
|
273
|
+
country '285', default # -
|
274
|
+
country '286', default # -
|
275
|
+
country '287', default # -
|
276
|
+
country '288', default # -
|
277
|
+
country '289', default # -
|
278
|
+
country '290', default # Saint Helena
|
279
|
+
|
280
|
+
country '291', default # Eritrea
|
281
|
+
country '292', default # -
|
282
|
+
country '293', default # -
|
283
|
+
country '294', default # -
|
284
|
+
country '295', default # -
|
285
|
+
country '296', default # -
|
286
|
+
country '297', default # Aruba
|
287
|
+
country '298', default # Faroe Islands
|
288
|
+
country '299', default # Greenland
|
289
|
+
|
290
|
+
country '350', default # Gibraltar
|
291
291
|
|
292
292
|
# Portugal.
|
293
293
|
#
|
@@ -296,12 +296,12 @@ Phony.define do
|
|
296
296
|
one_of('21', '22') >> split(3,4) | # Lisboa & Porto
|
297
297
|
fixed(3) >> split(3,4) # 3-digit NDCs
|
298
298
|
|
299
|
-
country '352',
|
300
|
-
country '353',
|
301
|
-
country '354', none
|
302
|
-
country '355',
|
303
|
-
country '356',
|
304
|
-
country '357',
|
299
|
+
country '352', default # Luxembourg
|
300
|
+
country '353', default # Ireland (0-3-4)
|
301
|
+
country '354', none >> split(3,4) # Iceland
|
302
|
+
country '355', default # Albania
|
303
|
+
country '356', default # Malta
|
304
|
+
country '357', default # Cyprus
|
305
305
|
|
306
306
|
# Finland.
|
307
307
|
#
|
@@ -319,21 +319,21 @@ Phony.define do
|
|
319
319
|
one_of('37','41') >> split(2,2,2) | # Kaunas, Šiauliai
|
320
320
|
fixed(3) >> split(1,2,2) # 3-digit NDCs.
|
321
321
|
|
322
|
-
country '371',
|
323
|
-
country '372',
|
324
|
-
country '373',
|
325
|
-
country '374',
|
326
|
-
country '375',
|
327
|
-
country '376',
|
328
|
-
country '377',
|
329
|
-
country '378',
|
330
|
-
country '379',
|
331
|
-
|
332
|
-
country '380',
|
333
|
-
country '381',
|
334
|
-
country '382',
|
335
|
-
country '383',
|
336
|
-
country '384',
|
322
|
+
country '371', default # Latvia
|
323
|
+
country '372', default # Estonia
|
324
|
+
country '373', default # Moldova
|
325
|
+
country '374', default # Armenia
|
326
|
+
country '375', default # Belarus
|
327
|
+
country '376', default # Andorra
|
328
|
+
country '377', default # Monaco
|
329
|
+
country '378', default # San Marino
|
330
|
+
country '379', default # Vatican City State
|
331
|
+
|
332
|
+
country '380', default # Ukraine
|
333
|
+
country '381', default # Serbia and Montenegro
|
334
|
+
country '382', default # -
|
335
|
+
country '383', default # -
|
336
|
+
country '384', default # -
|
337
337
|
|
338
338
|
# Croatia.
|
339
339
|
#
|
@@ -353,166 +353,166 @@ Phony.define do
|
|
353
353
|
one_of('2') >> split(8) | # Bratislava
|
354
354
|
fixed(2) >> split(7) # 2-digit NDCs
|
355
355
|
|
356
|
-
country '422',
|
357
|
-
country '423', none
|
358
|
-
country '424',
|
359
|
-
country '425',
|
360
|
-
country '426',
|
361
|
-
country '427',
|
362
|
-
country '428',
|
363
|
-
country '429',
|
364
|
-
|
365
|
-
country '500',
|
366
|
-
country '501',
|
367
|
-
country '502',
|
368
|
-
country '503',
|
369
|
-
country '504',
|
370
|
-
country '505',
|
371
|
-
country '506',
|
372
|
-
country '507',
|
373
|
-
country '508',
|
374
|
-
country '509',
|
375
|
-
|
376
|
-
country '590',
|
377
|
-
country '591',
|
378
|
-
country '592',
|
379
|
-
country '593',
|
380
|
-
country '594',
|
381
|
-
country '595',
|
382
|
-
country '596',
|
383
|
-
country '597',
|
384
|
-
country '598',
|
385
|
-
country '599',
|
386
|
-
|
387
|
-
country '670',
|
388
|
-
country '671',
|
389
|
-
country '672',
|
390
|
-
country '673',
|
391
|
-
country '674',
|
392
|
-
country '675',
|
393
|
-
country '676',
|
394
|
-
country '677',
|
395
|
-
country '678',
|
396
|
-
country '679',
|
397
|
-
|
398
|
-
country '680',
|
399
|
-
country '681',
|
400
|
-
country '682',
|
401
|
-
country '683',
|
402
|
-
country '684',
|
403
|
-
country '685',
|
404
|
-
country '686',
|
405
|
-
country '687',
|
406
|
-
country '688',
|
407
|
-
country '689',
|
408
|
-
|
409
|
-
country '690',
|
410
|
-
country '691',
|
411
|
-
country '692',
|
412
|
-
country '693',
|
413
|
-
country '694',
|
414
|
-
country '695',
|
415
|
-
country '696',
|
416
|
-
country '697',
|
417
|
-
country '698',
|
418
|
-
country '699',
|
419
|
-
|
420
|
-
country '800',
|
421
|
-
country '801',
|
422
|
-
country '802',
|
423
|
-
country '803',
|
424
|
-
country '804',
|
425
|
-
country '805',
|
426
|
-
country '806',
|
427
|
-
country '807',
|
428
|
-
country '808',
|
429
|
-
country '809',
|
430
|
-
|
431
|
-
country '830',
|
432
|
-
country '831',
|
433
|
-
country '832',
|
434
|
-
country '833',
|
435
|
-
country '834',
|
436
|
-
country '835',
|
437
|
-
country '836',
|
438
|
-
country '837',
|
439
|
-
country '838',
|
440
|
-
country '839',
|
441
|
-
|
442
|
-
country '850',
|
443
|
-
country '851',
|
444
|
-
country '852',
|
445
|
-
country '853',
|
446
|
-
country '854',
|
447
|
-
country '855',
|
448
|
-
country '856',
|
449
|
-
country '857',
|
450
|
-
country '858',
|
451
|
-
country '859',
|
452
|
-
|
453
|
-
country '870',
|
454
|
-
country '871',
|
455
|
-
country '872',
|
456
|
-
country '873',
|
457
|
-
country '874',
|
458
|
-
country '875',
|
459
|
-
country '876',
|
460
|
-
country '877',
|
461
|
-
country '878',
|
462
|
-
country '879',
|
463
|
-
|
464
|
-
country '880',
|
465
|
-
country '881',
|
466
|
-
country '882',
|
467
|
-
country '883',
|
468
|
-
country '884',
|
469
|
-
country '885',
|
470
|
-
country '886',
|
471
|
-
country '887',
|
472
|
-
country '888',
|
473
|
-
country '889',
|
474
|
-
|
475
|
-
country '890',
|
476
|
-
country '891',
|
477
|
-
country '892',
|
478
|
-
country '893',
|
479
|
-
country '894',
|
480
|
-
country '895',
|
481
|
-
country '896',
|
482
|
-
country '897',
|
483
|
-
country '898',
|
484
|
-
country '899',
|
485
|
-
|
486
|
-
country '960',
|
487
|
-
country '961',
|
488
|
-
country '962',
|
489
|
-
country '963',
|
490
|
-
country '964',
|
491
|
-
country '965',
|
492
|
-
country '966',
|
493
|
-
country '967',
|
494
|
-
country '968',
|
495
|
-
country '969',
|
496
|
-
|
497
|
-
country '970',
|
498
|
-
country '971',
|
499
|
-
country '972',
|
500
|
-
country '973',
|
501
|
-
country '974',
|
502
|
-
country '975',
|
503
|
-
country '976',
|
504
|
-
country '977',
|
505
|
-
country '978',
|
506
|
-
country '979',
|
507
|
-
|
508
|
-
country '990',
|
509
|
-
country '991',
|
510
|
-
country '992',
|
511
|
-
country '993',
|
512
|
-
country '994',
|
513
|
-
country '995',
|
514
|
-
country '996',
|
515
|
-
country '997',
|
516
|
-
country '998',
|
517
|
-
country '999',
|
518
|
-
end
|
356
|
+
country '422', default # Spare code
|
357
|
+
country '423', none >> split(3,2,2) # Liechtenstein (Principality of)
|
358
|
+
country '424', default # -
|
359
|
+
country '425', default # -
|
360
|
+
country '426', default # -
|
361
|
+
country '427', default # -
|
362
|
+
country '428', default # -
|
363
|
+
country '429', default # -
|
364
|
+
|
365
|
+
country '500', default # Falkland Islands (Malvinas)
|
366
|
+
country '501', default # Belize
|
367
|
+
country '502', default # Guatemala (Republic of)
|
368
|
+
country '503', default # El Salvador (Republic of)
|
369
|
+
country '504', default # Honduras (Republic of)
|
370
|
+
country '505', default # Nicaragua
|
371
|
+
country '506', default # Costa Rica
|
372
|
+
country '507', default # Panama (Republic of)
|
373
|
+
country '508', default # Saint Pierre and Miquelon (Collectivité territoriale de la République française)
|
374
|
+
country '509', default # Haiti (Republic of)
|
375
|
+
|
376
|
+
country '590', default # Guadeloupe (French Department of)
|
377
|
+
country '591', default # Bolivia (Republic of)
|
378
|
+
country '592', default # Guyana
|
379
|
+
country '593', default # Ecuador
|
380
|
+
country '594', default # French Guiana (French Department of)
|
381
|
+
country '595', default # Paraguay (Republic of)
|
382
|
+
country '596', default # Martinique (French Department of)
|
383
|
+
country '597', default # Suriname (Republic of)
|
384
|
+
country '598', default # Uruguay (Eastern Republic of)
|
385
|
+
country '599', default # Netherlands Antilles
|
386
|
+
|
387
|
+
country '670', default # Democratic Republic of Timor-Leste
|
388
|
+
country '671', default # Spare code
|
389
|
+
country '672', default # Australian External Territories
|
390
|
+
country '673', default # Brunei Darussalam
|
391
|
+
country '674', default # Nauru (Republic of)
|
392
|
+
country '675', default # Papua New Guinea
|
393
|
+
country '676', default # Tonga (Kingdom of)
|
394
|
+
country '677', default # Solomon Islands
|
395
|
+
country '678', default # Vanuatu (Republic of)
|
396
|
+
country '679', default # Fiji (Republic of)
|
397
|
+
|
398
|
+
country '680', default # Palau (Republic of)
|
399
|
+
country '681', default # Wallis and Futuna (Territoire français d'outre-mer)
|
400
|
+
country '682', default # Cook Islands
|
401
|
+
country '683', default # Niue
|
402
|
+
country '684', default # -
|
403
|
+
country '685', default # Samoa (Independent State of)
|
404
|
+
country '686', default # Kiribati (Republic of)
|
405
|
+
country '687', default # New Caledonia (Territoire français d'outre-mer)
|
406
|
+
country '688', default # Tuvalu
|
407
|
+
country '689', default # French Polynesia (Territoire français d'outre-mer)
|
408
|
+
|
409
|
+
country '690', default # Tokelau
|
410
|
+
country '691', default # Micronesia (Federated States of)
|
411
|
+
country '692', default # Marshall Islands (Republic of the)
|
412
|
+
country '693', default # -
|
413
|
+
country '694', default # -
|
414
|
+
country '695', default # -
|
415
|
+
country '696', default # -
|
416
|
+
country '697', default # -
|
417
|
+
country '698', default # -
|
418
|
+
country '699', default # -
|
419
|
+
|
420
|
+
country '800', default # International Freephone Service
|
421
|
+
country '801', default # -
|
422
|
+
country '802', default # -
|
423
|
+
country '803', default # -
|
424
|
+
country '804', default # -
|
425
|
+
country '805', default # -
|
426
|
+
country '806', default # -
|
427
|
+
country '807', default # -
|
428
|
+
country '808', default # International Shared Cost Service (ISCS)
|
429
|
+
country '809', default # -
|
430
|
+
|
431
|
+
country '830', default # -
|
432
|
+
country '831', default # -
|
433
|
+
country '832', default # -
|
434
|
+
country '833', default # -
|
435
|
+
country '834', default # -
|
436
|
+
country '835', default # -
|
437
|
+
country '836', default # -
|
438
|
+
country '837', default # -
|
439
|
+
country '838', default # -
|
440
|
+
country '839', default # -
|
441
|
+
|
442
|
+
country '850', default # Democratic People's Republic of Korea
|
443
|
+
country '851', default # Spare code
|
444
|
+
country '852', default # Hong Kong, China
|
445
|
+
country '853', default # Macao, China
|
446
|
+
country '854', default # Spare code
|
447
|
+
country '855', default # Cambodia (Kingdom of)
|
448
|
+
country '856', default # Lao People's Democratic Republic
|
449
|
+
country '857', default # Spare code
|
450
|
+
country '858', default # Spare code
|
451
|
+
country '859', default # Spare code
|
452
|
+
|
453
|
+
country '870', default # Inmarsat SNAC
|
454
|
+
country '871', default # Inmarsat (Atlantic Ocean-East)
|
455
|
+
country '872', default # Inmarsat (Pacific Ocean)
|
456
|
+
country '873', default # Inmarsat (Indian Ocean)
|
457
|
+
country '874', default # Inmarsat (Atlantic Ocean-West)
|
458
|
+
country '875', default # Reserved - Maritime Mobile Service Applications
|
459
|
+
country '876', default # Reserved - Maritime Mobile Service Applications
|
460
|
+
country '877', default # Reserved - Maritime Mobile Service Applications
|
461
|
+
country '878', default # Universal Personal Telecommunication Service (UPT)
|
462
|
+
country '879', default # Reserved for national non-commercial purposes
|
463
|
+
|
464
|
+
country '880', default # Bangladesh (People's Republic of)
|
465
|
+
country '881', default # International Mobile, shared code
|
466
|
+
country '882', default # International Networks, shared code
|
467
|
+
country '883', default # -
|
468
|
+
country '884', default # -
|
469
|
+
country '885', default # -
|
470
|
+
country '886', default # Reserved
|
471
|
+
country '887', default # -
|
472
|
+
country '888', default # Reserved for future global service
|
473
|
+
country '889', default # -
|
474
|
+
|
475
|
+
country '890', default # -
|
476
|
+
country '891', default # -
|
477
|
+
country '892', default # -
|
478
|
+
country '893', default # -
|
479
|
+
country '894', default # -
|
480
|
+
country '895', default # -
|
481
|
+
country '896', default # -
|
482
|
+
country '897', default # -
|
483
|
+
country '898', default # -
|
484
|
+
country '899', default # -
|
485
|
+
|
486
|
+
country '960', default # Maldives (Republic of)
|
487
|
+
country '961', default # Lebanon
|
488
|
+
country '962', default # Jordan (Hashemite Kingdom of)
|
489
|
+
country '963', default # Syrian Arab Republic
|
490
|
+
country '964', default # Iraq (Republic of)
|
491
|
+
country '965', default # Kuwait (State of)
|
492
|
+
country '966', default # Saudi Arabia (Kingdom of)
|
493
|
+
country '967', default # Yemen (Republic of)
|
494
|
+
country '968', default # Oman (Sultanate of)
|
495
|
+
country '969', default # Reserved - reservation currently under investigation
|
496
|
+
|
497
|
+
country '970', default # Reserved
|
498
|
+
country '971', default # United Arab Emirates
|
499
|
+
country '972', default # Israel (State of)
|
500
|
+
country '973', default # Bahrain (Kingdom of)
|
501
|
+
country '974', default # Qatar (State of)
|
502
|
+
country '975', default # Bhutan (Kingdom of)
|
503
|
+
country '976', default # Mongolia
|
504
|
+
country '977', default # Nepal
|
505
|
+
country '978', default # -
|
506
|
+
country '979', default # International Premium Rate Service (IPRS)
|
507
|
+
|
508
|
+
country '990', default # Spare code
|
509
|
+
country '991', default # Trial of a proposed new international telecommunication public correspondence service, shared code
|
510
|
+
country '992', default # Tajikistan (Republic of)
|
511
|
+
country '993', default # Turkmenistan
|
512
|
+
country '994', default # Azerbaijani Republic
|
513
|
+
country '995', default # Georgia
|
514
|
+
country '996', default # Kyrgyz Republic
|
515
|
+
country '997', default # Spare code
|
516
|
+
country '998', default # Uzbekistan (Republic of)
|
517
|
+
country '999', default # Reserved for possible future use within the Telecommunications for Disaster Relief (TDR) concept
|
518
|
+
end
|
data/lib/phony/country_codes.rb
CHANGED
@@ -43,7 +43,15 @@ module Phony
|
|
43
43
|
# Formats country code and national destination code.
|
44
44
|
#
|
45
45
|
def format_cc_ndc_local format, space, cc, ndc, *parts
|
46
|
-
|
46
|
+
cc_ndc = format_cc_ndc(format, space, cc, ndc)
|
47
|
+
local = \
|
48
|
+
if parts.empty?
|
49
|
+
cc_ndc = cc_ndc.slice 0...cc_ndc.rindex(space.to_s)
|
50
|
+
EMPTY_STRING
|
51
|
+
else
|
52
|
+
format_local(space, parts) unless parts.empty?
|
53
|
+
end
|
54
|
+
"#{cc_ndc}#{local}"
|
47
55
|
end
|
48
56
|
def format_cc_ndc format, space, cc, ndc
|
49
57
|
case format
|
@@ -119,4 +127,4 @@ module Phony
|
|
119
127
|
|
120
128
|
end
|
121
129
|
|
122
|
-
end
|
130
|
+
end
|
data/lib/phony/dsl.rb
CHANGED
@@ -73,6 +73,9 @@ module Phony
|
|
73
73
|
def match regex, options = {}
|
74
74
|
NationalSplitters::Regex.instance_for regex, options[:on_fail_take]
|
75
75
|
end
|
76
|
+
def default
|
77
|
+
none >> NationalSplitters::Default.instance_for
|
78
|
+
end
|
76
79
|
|
77
80
|
# Local splitters.
|
78
81
|
#
|
@@ -88,4 +91,4 @@ module Phony
|
|
88
91
|
|
89
92
|
end
|
90
93
|
|
91
|
-
end
|
94
|
+
end
|
data/spec/lib/phony_spec.rb
CHANGED
@@ -127,6 +127,20 @@ describe Phony do
|
|
127
127
|
Phony.format('4233841148', :format => :international_relative, :spaces => :-).should == '00423-384-11-48'
|
128
128
|
end
|
129
129
|
end
|
130
|
+
describe '"unsupported" countries' do
|
131
|
+
it 'should format as a single block' do
|
132
|
+
Phony.format('88032155605220').should == '+880 32155605220'
|
133
|
+
end
|
134
|
+
it 'should format as a single block, regardless of format' do
|
135
|
+
Phony.format('8801819372205', :format => :international).should == '+880 1819372205'
|
136
|
+
end
|
137
|
+
it 'should format as a single block, respecting custom spaces' do
|
138
|
+
Phony.format('8801819372205', :spaces => :-).should == '+880-1819372205'
|
139
|
+
end
|
140
|
+
it 'should format as a single block, even without spaces' do
|
141
|
+
Phony.format('8801819372205', :spaces => '').should == '+8801819372205'
|
142
|
+
end
|
143
|
+
end
|
130
144
|
end
|
131
145
|
describe "national" do
|
132
146
|
it "should format swiss numbers" do
|
@@ -179,6 +193,11 @@ describe Phony do
|
|
179
193
|
Phony.format('414436435').should == '+41 44 364 35'
|
180
194
|
end
|
181
195
|
end
|
196
|
+
context '"unsupported" countries' do
|
197
|
+
it 'handles normalizing, then formatting' do
|
198
|
+
Phony.format(Phony.normalize('+880-321 5560 5220')).should == '+880 32155605220'
|
199
|
+
end
|
200
|
+
end
|
182
201
|
end
|
183
202
|
|
184
203
|
context "speed" do
|
@@ -238,4 +257,4 @@ describe Phony do
|
|
238
257
|
end
|
239
258
|
end
|
240
259
|
|
241
|
-
end
|
260
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: phony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.4.
|
5
|
+
version: 1.4.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Florian Hanke
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-07-16 00:00:00 +10:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/phony/local_splitters/fixed.rb
|
40
40
|
- lib/phony/local_splitters/regex.rb
|
41
41
|
- lib/phony/national_code.rb
|
42
|
+
- lib/phony/national_splitters/default.rb
|
42
43
|
- lib/phony/national_splitters/dsl.rb
|
43
44
|
- lib/phony/national_splitters/fixed.rb
|
44
45
|
- lib/phony/national_splitters/none.rb
|
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
requirements: []
|
84
85
|
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.6.2
|
87
88
|
signing_key:
|
88
89
|
specification_version: 3
|
89
90
|
summary: Fast international phone number (E164 standard) normalizing, splitting and formatting.
|