phony 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -150,7 +150,7 @@ Phony.define do
150
150
 
151
151
  # TODO Colombia.
152
152
  #
153
- country '57', fixed(2) >> split(3,2,2)
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', fixed(2) >> split(3,2,2) # TODO Indonesia (Republic of)
166
- country '63', fixed(2) >> split(3,2,2) # TODO Philippines (Republic of the)
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', fixed(2) >> split(3,2,2) # TODO Singapore (Republic of)
175
- country '66', fixed(2) >> split(3,2,2) # TODO Thailand
174
+ country '65', default # TODO Singapore (Republic of)
175
+ country '66', default # TODO Thailand
176
176
 
177
- country '81', fixed(2) >> split(3,2,2) # TODO Japan
177
+ country '81', default # TODO Japan
178
178
 
179
179
  # country '82' # SouthKorea, see special file.
180
180
 
181
- country '84', fixed(2) >> split(3,2,2) # TODO Viet Nam (Socialist Republic of)
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', fixed(2) >> split(3,2,2) # TODO India (Republic of)
190
- country '92', fixed(2) >> split(3,2,2) # TODO Pakistan (Islamic Republic of), http://en.wikipedia.org/wiki/Telephone_numbers_in_Pakistan, NDC 2-5
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', fixed(2) >> split(3,2,2) # -
203
- country '211', fixed(2) >> split(3,2,2) # -
204
- country '212', fixed(2) >> split(3,2,2) # Morocco
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', fixed(2) >> split(3,2,2) # -
207
- country '215', fixed(2) >> split(3,2,2) # -
206
+ country '214', default # -
207
+ country '215', default # -
208
208
  country '216', fixed(1) >> split(3,4) # Tunisia
209
- country '217', fixed(2) >> split(3,2,2) # -
210
- country '218', fixed(2) >> split(3,2,2) # Lybia
211
- country '219', fixed(2) >> split(3,2,2) # -
212
-
213
- country '220', fixed(2) >> split(3,2,2) # Gambia
214
- country '221', fixed(2) >> split(3,2,2) # Senegal
215
- country '222', fixed(2) >> split(3,2,2) # Mauritania
216
- country '223', fixed(2) >> split(3,2,2) # Mali
217
- country '224', fixed(2) >> split(3,2,2) # Guinea
218
- country '225', fixed(2) >> split(3,2,2) # Côte d'Ivoire
219
- country '226', fixed(2) >> split(3,2,2) # Burkina Faso
220
- country '227', fixed(2) >> split(3,2,2) # Niger
221
- country '228', fixed(2) >> split(3,2,2) # Togolese Republic
222
- country '229', fixed(2) >> split(3,2,2) # Benin
223
-
224
- country '230', fixed(2) >> split(3,2,2) # Mauritius
225
- country '231', fixed(2) >> split(3,2,2) # Liberia
226
- country '232', fixed(2) >> split(3,2,2) # Sierra Leone
227
- country '233', fixed(2) >> split(3,2,2) # Ghana
228
- country '234', fixed(2) >> split(3,2,2) # Nigeria
229
- country '235', fixed(2) >> split(3,2,2) # Chad
230
- country '236', fixed(2) >> split(3,2,2) # Central African Republic
231
- country '237', fixed(2) >> split(3,2,2) # Cameroon
232
- country '238', fixed(2) >> split(3,2,2) # Cape Verde
233
- country '239', fixed(2) >> split(3,2,2) # Sao Tome and Principe
234
-
235
- country '240', fixed(2) >> split(3,2,2) # Equatorial Guinea
236
- country '241', fixed(2) >> split(3,2,2) # Gabonese Republic
237
- country '242', fixed(2) >> split(3,2,2) # Congo
238
- country '243', fixed(2) >> split(3,2,2) # Democratic Republic of the Congo
239
- country '244', fixed(2) >> split(3,2,2) # Angola
240
- country '245', fixed(2) >> split(3,2,2) # Guinea-Bissau
241
- country '246', fixed(2) >> split(3,2,2) # Diego Garcia
242
- country '247', fixed(2) >> split(3,2,2) # Ascension
243
- country '248', fixed(2) >> split(3,2,2) # Seychelles
244
- country '249', fixed(2) >> split(3,2,2) # Sudan
245
-
246
- country '250', fixed(2) >> split(3,2,2) # Rwanda
247
- country '251', fixed(2) >> split(3,2,2) # Ethiopia
248
- country '252', fixed(2) >> split(3,2,2) # Somali Democratic Republic
249
- country '253', fixed(2) >> split(3,2,2) # Djibouti
250
- country '254', fixed(2) >> split(3,2,2) # Kenya
251
- country '255', fixed(2) >> split(3,2,2) # Tanzania
252
- country '256', fixed(2) >> split(3,2,2) # Uganda
253
- country '257', fixed(2) >> split(3,2,2) # Burundi
254
- country '258', fixed(2) >> split(3,2,2) # Mozambique
255
- country '259', fixed(2) >> split(3,2,2) # -
256
-
257
- country '260', fixed(2) >> split(3,2,2) # Zambia
258
- country '261', fixed(2) >> split(3,2,2) # Madagascar
259
- country '262', fixed(3) >> split(3,2,2) # Reunion / Mayotte (new)
260
- country '263', fixed(2) >> split(3,2,2) # Zimbabwe
261
- country '264', fixed(2) >> split(3,2,2) # Namibia
262
- country '265', fixed(2) >> split(3,2,2) # Malawi
263
- country '266', fixed(2) >> split(3,2,2) # Lesotho
264
- country '267', fixed(2) >> split(3,2,2) # Botswana
265
- country '268', fixed(2) >> split(3,2,2) # Swaziland
266
- country '269', fixed(2) >> split(3,2,2) # Comoros
267
-
268
- country '280', fixed(2) >> split(3,2,2) # -
269
- country '281', fixed(2) >> split(3,2,2) # -
270
- country '282', fixed(2) >> split(3,2,2) # -
271
- country '283', fixed(2) >> split(3,2,2) # -
272
- country '284', fixed(2) >> split(3,2,2) # -
273
- country '285', fixed(2) >> split(3,2,2) # -
274
- country '286', fixed(2) >> split(3,2,2) # -
275
- country '287', fixed(2) >> split(3,2,2) # -
276
- country '288', fixed(2) >> split(3,2,2) # -
277
- country '289', fixed(2) >> split(3,2,2) # -
278
- country '290', fixed(2) >> split(3,2,2) # Saint Helena
279
-
280
- country '291', fixed(2) >> split(3,2,2) # Eritrea
281
- country '292', fixed(2) >> split(3,2,2) # -
282
- country '293', fixed(2) >> split(3,2,2) # -
283
- country '294', fixed(2) >> split(3,2,2) # -
284
- country '295', fixed(2) >> split(3,2,2) # -
285
- country '296', fixed(2) >> split(3,2,2) # -
286
- country '297', fixed(2) >> split(3,2,2) # Aruba
287
- country '298', fixed(2) >> split(3,2,2) # Faroe Islands
288
- country '299', fixed(2) >> split(3,2,2) # Greenland
289
-
290
- country '350', fixed(2) >> split(3,2,2) # Gibraltar
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', fixed(2) >> split(3,2,2) # Luxembourg
300
- country '353', fixed(2) >> split(3,2,2) # Ireland (0-3-4)
301
- country '354', none >> split(3,4) # Iceland
302
- country '355', fixed(2) >> split(3,2,2) # Albania
303
- country '356', fixed(2) >> split(3,2,2) # Malta
304
- country '357', fixed(2) >> split(3,2,2) # Cyprus
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', fixed(2) >> split(3,2,2) # Latvia
323
- country '372', fixed(2) >> split(3,2,2) # Estonia
324
- country '373', fixed(2) >> split(3,2,2) # Moldova
325
- country '374', fixed(2) >> split(3,2,2) # Armenia
326
- country '375', fixed(2) >> split(3,2,2) # Belarus
327
- country '376', fixed(2) >> split(3,2,2) # Andorra
328
- country '377', fixed(2) >> split(3,2,2) # Monaco
329
- country '378', fixed(2) >> split(3,2,2) # San Marino
330
- country '379', fixed(2) >> split(3,2,2) # Vatican City State
331
-
332
- country '380', fixed(2) >> split(3,2,2) # Ukraine
333
- country '381', fixed(2) >> split(3,2,2) # Serbia and Montenegro
334
- country '382', fixed(2) >> split(3,2,2) # -
335
- country '383', fixed(2) >> split(3,2,2) # -
336
- country '384', fixed(2) >> split(3,2,2) # -
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', fixed(2) >> split(3,2,2) # Spare code
357
- country '423', none >> split(3,2,2) # Liechtenstein (Principality of)
358
- country '424', fixed(2) >> split(3,2,2) # -
359
- country '425', fixed(2) >> split(3,2,2) # -
360
- country '426', fixed(2) >> split(3,2,2) # -
361
- country '427', fixed(2) >> split(3,2,2) # -
362
- country '428', fixed(2) >> split(3,2,2) # -
363
- country '429', fixed(2) >> split(3,2,2) # -
364
-
365
- country '500', fixed(2) >> split(3,2,2) # Falkland Islands (Malvinas)
366
- country '501', fixed(2) >> split(3,2,2) # Belize
367
- country '502', fixed(2) >> split(3,2,2) # Guatemala (Republic of)
368
- country '503', fixed(2) >> split(3,2,2) # El Salvador (Republic of)
369
- country '504', fixed(2) >> split(3,2,2) # Honduras (Republic of)
370
- country '505', fixed(2) >> split(3,2,2) # Nicaragua
371
- country '506', fixed(2) >> split(3,2,2) # Costa Rica
372
- country '507', fixed(2) >> split(3,2,2) # Panama (Republic of)
373
- country '508', fixed(2) >> split(3,2,2) # Saint Pierre and Miquelon (Collectivité territoriale de la République française)
374
- country '509', fixed(2) >> split(3,2,2) # Haiti (Republic of)
375
-
376
- country '590', fixed(3) >> split(3,2,2) # Guadeloupe (French Department of)
377
- country '591', fixed(2) >> split(3,2,2) # Bolivia (Republic of)
378
- country '592', fixed(2) >> split(3,2,2) # Guyana
379
- country '593', fixed(2) >> split(3,2,2) # Ecuador
380
- country '594', fixed(3) >> split(3,2,2) # French Guiana (French Department of)
381
- country '595', fixed(2) >> split(3,2,2) # Paraguay (Republic of)
382
- country '596', fixed(3) >> split(3,2,2) # Martinique (French Department of)
383
- country '597', fixed(2) >> split(3,2,2) # Suriname (Republic of)
384
- country '598', fixed(2) >> split(3,2,2) # Uruguay (Eastern Republic of)
385
- country '599', fixed(2) >> split(3,2,2) # Netherlands Antilles
386
-
387
- country '670', fixed(2) >> split(3,2,2) # Democratic Republic of Timor-Leste
388
- country '671', fixed(2) >> split(3,2,2) # Spare code
389
- country '672', fixed(2) >> split(3,2,2) # Australian External Territories
390
- country '673', fixed(2) >> split(3,2,2) # Brunei Darussalam
391
- country '674', fixed(2) >> split(3,2,2) # Nauru (Republic of)
392
- country '675', fixed(2) >> split(3,2,2) # Papua New Guinea
393
- country '676', fixed(2) >> split(3,2,2) # Tonga (Kingdom of)
394
- country '677', fixed(2) >> split(3,2,2) # Solomon Islands
395
- country '678', fixed(2) >> split(3,2,2) # Vanuatu (Republic of)
396
- country '679', fixed(2) >> split(3,2,2) # Fiji (Republic of)
397
-
398
- country '680', fixed(2) >> split(3,2,2) # Palau (Republic of)
399
- country '681', fixed(2) >> split(3,2,2) # Wallis and Futuna (Territoire français d'outre-mer)
400
- country '682', fixed(2) >> split(3,2,2) # Cook Islands
401
- country '683', fixed(2) >> split(3,2,2) # Niue
402
- country '684', fixed(2) >> split(3,2,2) # -
403
- country '685', fixed(2) >> split(3,2,2) # Samoa (Independent State of)
404
- country '686', fixed(2) >> split(3,2,2) # Kiribati (Republic of)
405
- country '687', fixed(2) >> split(3,2,2) # New Caledonia (Territoire français d'outre-mer)
406
- country '688', fixed(2) >> split(3,2,2) # Tuvalu
407
- country '689', fixed(2) >> split(3,2,2) # French Polynesia (Territoire français d'outre-mer)
408
-
409
- country '690', fixed(2) >> split(3,2,2) # Tokelau
410
- country '691', fixed(2) >> split(3,2,2) # Micronesia (Federated States of)
411
- country '692', fixed(2) >> split(3,2,2) # Marshall Islands (Republic of the)
412
- country '693', fixed(2) >> split(3,2,2) # -
413
- country '694', fixed(2) >> split(3,2,2) # -
414
- country '695', fixed(2) >> split(3,2,2) # -
415
- country '696', fixed(2) >> split(3,2,2) # -
416
- country '697', fixed(2) >> split(3,2,2) # -
417
- country '698', fixed(2) >> split(3,2,2) # -
418
- country '699', fixed(2) >> split(3,2,2) # -
419
-
420
- country '800', fixed(2) >> split(3,2,2) # International Freephone Service
421
- country '801', fixed(2) >> split(3,2,2) # -
422
- country '802', fixed(2) >> split(3,2,2) # -
423
- country '803', fixed(2) >> split(3,2,2) # -
424
- country '804', fixed(2) >> split(3,2,2) # -
425
- country '805', fixed(2) >> split(3,2,2) # -
426
- country '806', fixed(2) >> split(3,2,2) # -
427
- country '807', fixed(2) >> split(3,2,2) # -
428
- country '808', fixed(2) >> split(3,2,2) # International Shared Cost Service (ISCS)
429
- country '809', fixed(2) >> split(3,2,2) # -
430
-
431
- country '830', fixed(2) >> split(3,2,2) # -
432
- country '831', fixed(2) >> split(3,2,2) # -
433
- country '832', fixed(2) >> split(3,2,2) # -
434
- country '833', fixed(2) >> split(3,2,2) # -
435
- country '834', fixed(2) >> split(3,2,2) # -
436
- country '835', fixed(2) >> split(3,2,2) # -
437
- country '836', fixed(2) >> split(3,2,2) # -
438
- country '837', fixed(2) >> split(3,2,2) # -
439
- country '838', fixed(2) >> split(3,2,2) # -
440
- country '839', fixed(2) >> split(3,2,2) # -
441
-
442
- country '850', fixed(2) >> split(3,2,2) # Democratic People's Republic of Korea
443
- country '851', fixed(2) >> split(3,2,2) # Spare code
444
- country '852', fixed(2) >> split(3,2,2) # Hong Kong, China
445
- country '853', fixed(2) >> split(3,2,2) # Macao, China
446
- country '854', fixed(2) >> split(3,2,2) # Spare code
447
- country '855', fixed(2) >> split(3,2,2) # Cambodia (Kingdom of)
448
- country '856', fixed(2) >> split(3,2,2) # Lao People's Democratic Republic
449
- country '857', fixed(2) >> split(3,2,2) # Spare code
450
- country '858', fixed(2) >> split(3,2,2) # Spare code
451
- country '859', fixed(2) >> split(3,2,2) # Spare code
452
-
453
- country '870', fixed(2) >> split(3,2,2) # Inmarsat SNAC
454
- country '871', fixed(2) >> split(3,2,2) # Inmarsat (Atlantic Ocean-East)
455
- country '872', fixed(2) >> split(3,2,2) # Inmarsat (Pacific Ocean)
456
- country '873', fixed(2) >> split(3,2,2) # Inmarsat (Indian Ocean)
457
- country '874', fixed(2) >> split(3,2,2) # Inmarsat (Atlantic Ocean-West)
458
- country '875', fixed(2) >> split(3,2,2) # Reserved - Maritime Mobile Service Applications
459
- country '876', fixed(2) >> split(3,2,2) # Reserved - Maritime Mobile Service Applications
460
- country '877', fixed(2) >> split(3,2,2) # Reserved - Maritime Mobile Service Applications
461
- country '878', fixed(2) >> split(3,2,2) # Universal Personal Telecommunication Service (UPT)
462
- country '879', fixed(2) >> split(3,2,2) # Reserved for national non-commercial purposes
463
-
464
- country '880', fixed(2) >> split(3,2,2) # Bangladesh (People's Republic of)
465
- country '881', fixed(2) >> split(3,2,2) # International Mobile, shared code
466
- country '882', fixed(2) >> split(3,2,2) # International Networks, shared code
467
- country '883', fixed(2) >> split(3,2,2) # -
468
- country '884', fixed(2) >> split(3,2,2) # -
469
- country '885', fixed(2) >> split(3,2,2) # -
470
- country '886', fixed(2) >> split(3,2,2) # Reserved
471
- country '887', fixed(2) >> split(3,2,2) # -
472
- country '888', fixed(2) >> split(3,2,2) # Reserved for future global service
473
- country '889', fixed(2) >> split(3,2,2) # -
474
-
475
- country '890', fixed(2) >> split(3,2,2) # -
476
- country '891', fixed(2) >> split(3,2,2) # -
477
- country '892', fixed(2) >> split(3,2,2) # -
478
- country '893', fixed(2) >> split(3,2,2) # -
479
- country '894', fixed(2) >> split(3,2,2) # -
480
- country '895', fixed(2) >> split(3,2,2) # -
481
- country '896', fixed(2) >> split(3,2,2) # -
482
- country '897', fixed(2) >> split(3,2,2) # -
483
- country '898', fixed(2) >> split(3,2,2) # -
484
- country '899', fixed(2) >> split(3,2,2) # -
485
-
486
- country '960', fixed(2) >> split(3,2,2) # Maldives (Republic of)
487
- country '961', fixed(2) >> split(3,2,2) # Lebanon
488
- country '962', fixed(2) >> split(3,2,2) # Jordan (Hashemite Kingdom of)
489
- country '963', fixed(2) >> split(3,2,2) # Syrian Arab Republic
490
- country '964', fixed(2) >> split(3,2,2) # Iraq (Republic of)
491
- country '965', fixed(2) >> split(3,2,2) # Kuwait (State of)
492
- country '966', fixed(2) >> split(3,2,2) # Saudi Arabia (Kingdom of)
493
- country '967', fixed(2) >> split(3,2,2) # Yemen (Republic of)
494
- country '968', fixed(2) >> split(3,2,2) # Oman (Sultanate of)
495
- country '969', fixed(2) >> split(3,2,2) # Reserved - reservation currently under investigation
496
-
497
- country '970', fixed(2) >> split(3,2,2) # Reserved
498
- country '971', fixed(2) >> split(3,2,2) # United Arab Emirates
499
- country '972', fixed(2) >> split(3,2,2) # Israel (State of)
500
- country '973', fixed(2) >> split(3,2,2) # Bahrain (Kingdom of)
501
- country '974', fixed(2) >> split(3,2,2) # Qatar (State of)
502
- country '975', fixed(2) >> split(3,2,2) # Bhutan (Kingdom of)
503
- country '976', fixed(2) >> split(3,2,2) # Mongolia
504
- country '977', fixed(2) >> split(3,2,2) # Nepal
505
- country '978', fixed(2) >> split(3,2,2) # -
506
- country '979', fixed(2) >> split(3,2,2) # International Premium Rate Service (IPRS)
507
-
508
- country '990', fixed(2) >> split(3,2,2) # Spare code
509
- country '991', fixed(2) >> split(3,2,2) # Trial of a proposed new international telecommunication public correspondence service, shared code
510
- country '992', fixed(2) >> split(3,2,2) # Tajikistan (Republic of)
511
- country '993', fixed(2) >> split(3,2,2) # Turkmenistan
512
- country '994', fixed(2) >> split(3,2,2) # Azerbaijani Republic
513
- country '995', fixed(2) >> split(3,2,2) # Georgia
514
- country '996', fixed(2) >> split(3,2,2) # Kyrgyz Republic
515
- country '997', fixed(2) >> split(3,2,2) # Spare code
516
- country '998', fixed(2) >> split(3,2,2) # Uzbekistan (Republic of)
517
- country '999', fixed(2) >> split(3,2,2) # Reserved for possible future use within the Telecommunications for Disaster Relief (TDR) concept
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
@@ -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
- "#{format_cc_ndc(format, space, cc, ndc)}#{format_local(space, parts)}"
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
@@ -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
@@ -0,0 +1,17 @@
1
+ module Phony
2
+
3
+ module NationalSplitters
4
+
5
+ class Default < DSL
6
+
7
+ def self.instance_for
8
+ @instance ||= new
9
+ end
10
+
11
+ def split number
12
+ number
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -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.2
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-05-06 00:00:00 +10:00
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.5.0
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.