phony 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -355,7 +355,11 @@ Phony.define do
355
355
  country '298', todo # Faroe Islands
356
356
  country '299', todo # Greenland
357
357
 
358
- country '350', todo # Gibraltar
358
+ # Gibraltar
359
+ country '350',
360
+ match(/^(2[012]\d)\d+$/) >> split(5) | # fixed
361
+ match(/^([56]\d)\d+$/) >> split(6) | # mobile
362
+ match(/^(8\d\d\d)$/) >> split(0)
359
363
 
360
364
  # Portugal.
361
365
  #
@@ -378,8 +382,19 @@ Phony.define do
378
382
 
379
383
  country '354', none >> split(3,4) # Iceland
380
384
  country '355', todo # Albania
381
- country '356', todo # Malta
382
- country '357', todo # Cyprus
385
+
386
+ # Malta
387
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_Malta
388
+ country '356',
389
+ match(/^([79]\d)\d+$/) >> split(6) | # mobile
390
+ match(/^(2\d\d\d)\d+$/) >> split(4) | # fixed line
391
+ fixed(4) >> split(4) # eg. with voice mail
392
+
393
+
394
+ # Cyprus
395
+ # http://www.cytaglobal.com/cytaglobal/userfiles/NewNumberingPlan.pdf
396
+ country '357', one_of('121','122','123') >> split(2,6) | # voicemail
397
+ fixed(2) >> split(6) # fixed & mobile
383
398
 
384
399
  # Finland.
385
400
  #
@@ -404,12 +419,23 @@ Phony.define do
404
419
  fixed(3) >> split(1,2,2) # 3-digit NDCs.
405
420
 
406
421
  country '371', todo # Latvia
407
- country '372', todo # Estonia
422
+
423
+ # Estonia
424
+ country '372',
425
+ match(/^(5\d\d\d)\d+$/) >> split(4) | # Mobile
426
+ match(/^((?:70|8[12])\d\d)\d+$/) >> split(4) | # Mobile
427
+ fixed(3) >> split(4) # 3-digit NDCs
428
+
408
429
  country '373', todo # Moldova
409
430
  country '374', todo # Armenia
410
431
  country '375', todo # Belarus
411
432
  country '376', todo # Andorra
412
- country '377', todo # Monaco
433
+
434
+ # Monaco
435
+ country '377',
436
+ one_of('6') >> split(2,2,2,2) | # mobile
437
+ fixed(2) >> split(2,2,2)
438
+
413
439
  country '378', todo # San Marino
414
440
  country '379', todo # Vatican City State
415
441
 
@@ -69,6 +69,11 @@ describe 'country descriptions' do
69
69
  it_splits '5371234567', ['53', '7', '1234567'] # Havana
70
70
  it_splits '5342123456', ['53', '42', '123456'] # Villa Clara
71
71
  end
72
+ describe 'Cyprus' do
73
+ it_splits '35712322123456', ['357', '123', '22', '123456'] # Voicemail
74
+ it_splits '35722123456', ['357', '22', '123456'] # Fixed
75
+ it_splits '35791123456', ['357', '91', '123456'] # Mobile
76
+ end
72
77
  describe 'Denmark' do
73
78
  it_splits '4532121212', ['45', false, '32', '12', '12', '12']
74
79
  end
@@ -77,6 +82,15 @@ describe 'country descriptions' do
77
82
  it_splits '20921234567', ['20', '92', '1234567']
78
83
  it_splits '20951234567', ['20', '95', '1234567']
79
84
  end
85
+ describe 'Estonia' do
86
+ it_splits '3723212345', ['372', '321', '2345'] # Landline
87
+ it_splits '37251231234', ['372', '5123', '1234'] # Mobile
88
+ it_splits '3728001234', ['372', '800', '1234'] # Freephone
89
+ it_splits '37281231234', ['372', '8123', '1234'] # Mobile
90
+ it_splits '37282231234', ['372', '8223', '1234'] # Mobile
91
+ it_splits '37283212345', ['372', '832', '12345'] # Mobile
92
+ it_splits '37270121234', ['372', '7012', '1234'] # Premium
93
+ end
80
94
  describe 'Finland' do
81
95
  it_splits '3589123123', ['358', '9', '123', '123'] # Helsinki
82
96
  it_splits '3581912312', ['358', '19', '123', '12'] # Nylandia
@@ -100,6 +114,17 @@ describe 'country descriptions' do
100
114
  describe 'Ghana' do
101
115
  it_splits '233302123456', ['233', '30', '212', '3456'] # Mobile Vodafone, Accra
102
116
  end
117
+ describe 'Gibraltar' do
118
+ it_splits '35020012345', ['350', '200', '12345'] # Fixed
119
+ it_splits '35021112345', ['350', '211', '12345'] # Fixed
120
+ it_splits '35022212345', ['350', '222', '12345'] # Fixed
121
+ it_splits '35054123456', ['350', '54', '123456'] # Mobile
122
+ it_splits '35056123456', ['350', '56', '123456'] # Mobile
123
+ it_splits '35057123456', ['350', '57', '123456'] # Mobile
124
+ it_splits '35058123456', ['350', '58', '123456'] # Mobile
125
+ it_splits '35060123456', ['350', '60', '123456'] # Mobile
126
+ it_splits '3508012', ['350', '8012', '' ] # Freephone
127
+ end
103
128
  describe 'Greece' do
104
129
  it_splits '3021123456', ['30', '21', '123456'] # Athens
105
130
  it_splits '3069512345', ['30', '695', '12345'] # Mobile
@@ -156,10 +181,20 @@ describe 'country descriptions' do
156
181
  it_splits '60312345678', ['60', '3', '12345678'] # Kuala Lumpur
157
182
  it_splits '60212345678', ['60', '2', '12345678'] # Singapore
158
183
  end
184
+ describe 'Malta' do
185
+ it_splits '35621231234', ['356', '2123', '1234'] # Fixed
186
+ it_splits '35677123456', ['356', '77', '123456'] # Mobile
187
+ it_splits '35698123456', ['356', '98', '123456'] # Mobile
188
+ it_splits '35651231234', ['356', '5123', '1234'] # Voice Mail
189
+ end
159
190
  describe 'Mexico' do
160
191
  it_splits '525512121212', ['52', '55', '12', '12', '12', '12'] # Mexico City
161
192
  it_splits '526641231212', ['52', '664', '123', '12', '12'] # Tijuana
162
193
  end
194
+ describe 'Monaco' do
195
+ it_splits '37741123456', ['377', '41', '12', '34', '56'] # Mobile
196
+ it_splits '377612345678', ['377', '6', '12', '34', '56', '78'] # Mobile
197
+ end
163
198
  describe 'Morocco' do
164
199
  it_splits '212537718685', ['212', '53', '7718', '685']
165
200
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
12
+ date: 2012-10-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Fast international phone number (E164 standard) normalizing, splitting
15
15
  and formatting. Lots of formatting options: International (+.., 00..), national
@@ -103,3 +103,4 @@ test_files:
103
103
  - spec/lib/phony/validations_spec.rb
104
104
  - spec/lib/phony/vanity_spec.rb
105
105
  - spec/lib/phony_spec.rb
106
+ has_rdoc: false