phony 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,5 +1,7 @@
1
1
  h1. Phony
2
2
 
3
+ Used in e.g.: "airbnb.com":airbnb.com, "restorm.com":restorm.com
4
+
3
5
  h2. Description
4
6
 
5
7
  This gem can normalize, format and split E164 numbers.
@@ -253,9 +253,12 @@ Phony.define do
253
253
  country '251', todo # Ethiopia
254
254
  country '252', todo # Somali Democratic Republic
255
255
  country '253', todo # Djibouti
256
- country '254', todo # Kenya
257
- country '255', todo # Tanzania
258
- country '256', todo # Uganda
256
+ country '254', fixed(2) >> split(7) # Kenya
257
+ country '255', match(/^([89]\d\d)/) >> split(3,3) | # Special/Premium. Tanzania
258
+ one_of('112', '118') >> split(3,3) | # Short Codes.
259
+ fixed(2) >> split(3,4) # Geographic.
260
+ country '256', match(/^(46[45]|4[78]\d)/) >> split(6) | # Geo 1. Uganda
261
+ fixed(2) >> split(7) # Geo 2.
259
262
  country '257', todo # Burundi
260
263
  country '258', todo # Mozambique
261
264
  country '259', todo # -
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe 'country descriptions' do
6
6
 
7
- describe "splitting" do
7
+ describe 'splitting' do
8
8
  it 'handles afghan numbers' do
9
9
  Phony.split('93201234567').should == ['93', '20', '1234567'] # Kabul
10
10
  end
@@ -12,13 +12,13 @@ describe 'country descriptions' do
12
12
  Phony.split('213211231234').should == ['213', '21', '123', '1234'] # Algiers
13
13
  Phony.split('213331231234').should == ['213', '33', '123', '1234'] # Batna
14
14
  end
15
- it "handles austrian numbers" do
15
+ it 'handles austrian numbers' do
16
16
  Phony.split('43198110').should == ['43', '1', '98110'] # Vienna
17
17
  Phony.split('4366914093902').should == ['43', '669', '14093902'] # Mobile
18
18
  Phony.split('433161234567891').should == ['43', '316', '1234567891'] # Graz
19
19
  Phony.split('432164123456789').should == ['43', '2164', '123456789'] # Rohrau
20
20
  end
21
- it "handles australian numbers" do
21
+ it 'handles australian numbers' do
22
22
  Phony.split('61512341234').should == ['61', '5', '1234', '1234'] # Landline
23
23
  Phony.split('61423123123').should == ['61', '423', '123', '123'] # Mobile
24
24
  end
@@ -62,7 +62,7 @@ describe 'country descriptions' do
62
62
  Phony.split('31201234567').should == ['31', '20', '1234567']
63
63
  Phony.split('31222123456').should == ['31', '222', '123456']
64
64
  end
65
- it "handles egyptian numbers" do
65
+ it 'handles egyptian numbers' do
66
66
  Phony.split('20212345678').should == ['20', '2', '12345678']
67
67
  Phony.split('20921234567').should == ['20', '92', '1234567']
68
68
  Phony.split('20951234567').should == ['20', '95', '1234567']
@@ -73,10 +73,10 @@ describe 'country descriptions' do
73
73
  Phony.split('3585012312').should == ['358', '50', '123', '12'] # Mobile
74
74
  Phony.split('358600123').should == ['358', '600', '123'] # Service
75
75
  end
76
- it "handles french numbers" do
76
+ it 'handles french numbers' do
77
77
  Phony.split('33112345678').should == ['33', '1', '12','34','56','78']
78
78
  end
79
- it "handles german numbers" do
79
+ it 'handles german numbers' do
80
80
  Phony.split('493038625454').should == ['49', '30', '386', '25454'] # Berlin
81
81
  Phony.split('4922137683323').should == ['49', '221', '376', '83323'] # Cologne
82
82
  Phony.split('497614767676').should == ['49', '761', '476', '7676'] # Freiburg im Breisgau
@@ -85,29 +85,33 @@ describe 'country descriptions' do
85
85
  Phony.split('491805878323').should == ['49', '180', '587', '8323'] # Service numbers
86
86
  Phony.split('491815878323').should == ['49', '181', '587', '8323'] # Service numbers
87
87
  end
88
- it "handles greek numbers" do
88
+ it 'handles greek numbers' do
89
89
  Phony.split('3021123456').should == ['30', '21', '123456'] # Athens
90
90
  Phony.split('3069512345').should == ['30', '695', '12345'] # Mobile
91
91
  Phony.split('302108131234').should == ['30', '21', '08131234'] # Long mobile, noted by vilcsak in pull request #26.
92
92
  Phony.split('3025941234').should == ['30', '2594', '1234']
93
93
  Phony.split('3022631234').should == ['30', '2263', '1234']
94
94
  end
95
- it "handles hungarian numbers" do
95
+ it 'handles hungarian numbers' do
96
96
  Phony.split('3612345678').should == ['36', '1', '234', '5678']
97
97
  Phony.split('3622123456').should == ['36', '22', '123', '456']
98
98
  end
99
- it "handles icelandic numbers" do
99
+ it 'handles icelandic numbers' do
100
100
  Phony.split('354112').should == ['354', '112'] # Emergency TODO
101
101
  Phony.split('3544211234').should == ['354', '421', '1234'] # Keflavík
102
102
  Phony.split('3544621234').should == ['354', '462', '1234'] # Akureyri
103
103
  Phony.split('3545511234').should == ['354', '551', '1234'] # Reykjavík
104
104
  end
105
- it "handles italian numbers" do
105
+ it 'handles italian numbers' do
106
106
  Phony.split('3934869528').should == ['39', '3486', '952', '8'] # Mobile
107
107
  Phony.split('39068546705').should == ['39', '06', '854', '6705'] # Roma
108
108
  Phony.split('390909709511').should == ['39', '090', '970', '9511'] # Barcellona
109
109
  end
110
- it "handles lithuanian numbers" do
110
+ it 'handles kenyan numbers' do
111
+ Phony.split('254201234567').should == ['254', '20', '1234567'] # Nairobi
112
+ Phony.split('254111234567').should == ['254', '11', '1234567'] # Mombasa
113
+ end
114
+ it 'handles lithuanian numbers' do
111
115
  Phony.split('37070012123').should == ['370', '700', '12', '123'] # Service
112
116
  Phony.split('37061212123').should == ['370', '612', '12', '123'] # Mobile
113
117
  Phony.split('37051231212').should == ['370', '5', '123', '12', '12'] # Vilnius
@@ -138,7 +142,7 @@ describe 'country descriptions' do
138
142
  Phony.split('51912341234').should == ['51', '9', '1234', '1234'] # mobile
139
143
  Phony.split('51841234123').should == ['51', '84', '1234', '123'] # Cuzco, best effort
140
144
  end
141
- it "handles polish numbers" do
145
+ it 'handles polish numbers' do
142
146
  Phony.split('48123123123').should == ['48', '123', '123', '123']
143
147
  end
144
148
  it 'handles portuguese numbers' do
@@ -167,25 +171,34 @@ describe 'country descriptions' do
167
171
  Phony.split('21611231234').should == ['216', '1', '123', '1234'] # Ariana
168
172
  Phony.split('21621231234').should == ['216', '2', '123', '1234'] # Bizerte
169
173
  end
170
- it "handles singaporean numbers" do
174
+ it 'handles singaporean numbers' do
171
175
  Phony.split('6561231234').should == ['65', '6123', '1234'] # Fixed line
172
176
  end
173
- it "handles slovakian numbers" do
177
+ it 'handles slovakian numbers' do
174
178
  Phony.split('421912123456').should == ['421', '912', '123456'] # Mobile
175
179
  Phony.split('421212345678').should == ['421', '2', '12345678'] # Bratislava
176
180
  Phony.split('421371234567').should == ['421', '37', '1234567'] # Nitra / Other
177
181
  end
178
- it "handles swedish numbers" do
182
+ it 'handles swedish numbers' do
179
183
  Phony.split('46812345678').should == ['46', '8', '12345678'] # Stockholm
180
184
  Phony.split('46111234567').should == ['46', '11', '1234567']
181
185
  Phony.split('46125123456').should == ['46', '125', '123456']
182
186
  end
183
- it "handles swiss numbers" do
187
+ it 'handles swiss numbers' do
184
188
  Phony.split('41443643532').should == ['41', '44', '364', '35', '32']
185
189
  end
190
+ it 'handles tanzanian numbers' do
191
+ Phony.split('255221231234').should == ['255', '22', '123', '1234'] # Dar Es Salaam
192
+ Phony.split('255651231234').should == ['255', '65', '123', '1234'] # TIGO
193
+ Phony.split('255861123123').should == ['255', '861', '123', '123'] # Special Rates
194
+ end
186
195
  it 'handles turkish numbers' do
187
196
  Phony.split('903121234567').should == ['90', '312', '123', '4567'] # Ankara
188
197
  end
198
+ it 'handles ugandan numbers' do
199
+ Phony.split('256414123456').should == ['256', '41', '4123456'] # Kampania
200
+ Phony.split('256464441234').should == ['256', '464', '441234'] # Mubende
201
+ end
189
202
  it 'handles UK numbers' do
190
203
  Phony.split('442045671113').should == ['44', '20', '4567', '1113'] # London
191
204
  Phony.split('442076229901').should == ['44', '20', '7622', '9901'] # Cardiff
@@ -197,20 +210,20 @@ describe 'country descriptions' do
197
210
  Phony.split('447480605207').should == ['44', '7480', '605207'] # Mobile
198
211
  Phony.split('448005878323').should == ['44', '800', '587', '8323'] # Service, regression
199
212
  end
200
- it "handles US numbers" do
213
+ it 'handles US numbers' do
201
214
  Phony.split('15551115511').should == ['1', '555', '111', '5511']
202
215
  end
203
- it "handles venezuelan numbers" do
204
- Phony.split('582121234567').should == ["58", "212", "1234567"]
216
+ it 'handles venezuelan numbers' do
217
+ Phony.split('582121234567').should == ['58', '212', '1234567']
205
218
  end
206
- it "handles new zealand numbers" do
219
+ it 'handles new zealand numbers' do
207
220
  Phony.split('6491234567').should == ['64', '9', '123', '4567']
208
221
  end
209
222
 
210
- it "handles french service numbers" do
223
+ it 'handles french service numbers' do
211
224
  Phony.split('33812345678').should == ['33', '8', '12','34','56','78']
212
225
  end
213
- it "handles swiss service numbers" do
226
+ it 'handles swiss service numbers' do
214
227
  Phony.split('41800334455').should == ['41', '800', '334', '455']
215
228
  end
216
229
  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.4.5
4
+ version: 1.4.6
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: 2011-09-30 00:00:00.000000000 +02:00
12
+ date: 2011-10-11 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: ! 'Fast international phone number (E164 standard) normalizing, splitting