phony 1.7.11 → 1.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/phony/countries.rb +18 -2
- data/spec/lib/phony/countries_spec.rb +53 -44
- data/spec/lib/phony/country_codes_spec.rb +28 -0
- metadata +2 -2
data/lib/phony/countries.rb
CHANGED
@@ -272,7 +272,16 @@ Phony.define do
|
|
272
272
|
#
|
273
273
|
country '233', fixed(2) >> split(3,4)
|
274
274
|
|
275
|
-
|
275
|
+
# Nigeria
|
276
|
+
# Wikipedia says 3 4 split, many local number with no splitting
|
277
|
+
country '234',
|
278
|
+
one_of('1', '2', '9') >> split(3,4) | # Lagos, Ibadan and Abuja
|
279
|
+
match(/^(702\d)\d+$/) >> split(3,4) | # Mobile
|
280
|
+
match(/^(70[3-9])\d+$/) >> split(3,4) | # Mobile
|
281
|
+
match(/^(8[01]\d)\d+$/) >> split(3,4) | # Mobile
|
282
|
+
fixed(2) >> split(3,4) # 2-digit NDC
|
283
|
+
|
284
|
+
|
276
285
|
country '235', todo # Chad
|
277
286
|
country '236', todo # Central African Republic
|
278
287
|
country '237', todo # Cameroon
|
@@ -356,7 +365,14 @@ Phony.define do
|
|
356
365
|
one_of('21', '22') >> split(3,4) | # Lisboa & Porto
|
357
366
|
fixed(3) >> split(3,4) # 3-digit NDCs
|
358
367
|
|
359
|
-
|
368
|
+
# Luxembourg
|
369
|
+
#
|
370
|
+
country '352',
|
371
|
+
one_of('4') >> split(2,2,2) | # Luxembourg City
|
372
|
+
match(/^(2[467]\d{2})$/) >> split(2,2,2) | # 4-digit NDC
|
373
|
+
match(/^(6\d[18])\d+$/) >> split(3,3) | # mobile
|
374
|
+
match(/^(60\d{2})\d{8}$/) >> split(2,2,2,2) | # mobile machine to machine
|
375
|
+
match(/^([2-9]\d)/) >> split(2,2,2) # 2-digit NDC
|
360
376
|
|
361
377
|
# country '353' # Republic of Ireland, see special file.
|
362
378
|
|
@@ -129,70 +129,79 @@ describe 'country descriptions' do
|
|
129
129
|
it_splits '390909709511', ['39', '090', '970', '9511'] # Barcellona
|
130
130
|
end
|
131
131
|
describe 'Kenya' do
|
132
|
-
|
133
|
-
|
132
|
+
it_splits '254201234567', ['254', '20', '1234567'] # Nairobi
|
133
|
+
it_splits '254111234567', ['254', '11', '1234567'] # Mombasa
|
134
134
|
end
|
135
135
|
describe 'Lithuania' do
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
136
|
+
it_splits '37070012123', ['370', '700', '12', '123'] # Service
|
137
|
+
it_splits '37061212123', ['370', '612', '12', '123'] # Mobile
|
138
|
+
it_splits '37051231212', ['370', '5', '123', '12', '12'] # Vilnius
|
139
|
+
it_splits '37037121212', ['370', '37', '12', '12', '12'] # Kaunas
|
140
|
+
it_splits '37044011212', ['370', '440', '1', '12', '12'] # Skuodas
|
141
|
+
end
|
142
|
+
describe 'Luxembourg' do
|
143
|
+
it_splits '352222809', ['352', '22', '28', '09']
|
144
|
+
it_splits '35226222809', ['352', '26', '22', '28', '09']
|
145
|
+
it_splits '352621123456', ['352', '621', '123', '456']
|
146
|
+
it_splits '3524123456', ['352', '4', '12', '34', '56']
|
147
|
+
it_splits '352602112345678', ['352', '6021', '12', '34', '56', '78']
|
148
|
+
it_splits '352370431', ['352', '37', '04', '31']
|
149
|
+
it_splits '35227855', ['352', '27', '85', '5']
|
141
150
|
end
|
142
151
|
describe 'Malaysia' do
|
143
|
-
|
144
|
-
|
145
|
-
|
152
|
+
it_splits '6082123456', ['60', '82', '123456'] # Kuching
|
153
|
+
it_splits '60312345678', ['60', '3', '12345678'] # Kuala Lumpur
|
154
|
+
it_splits '60212345678', ['60', '2', '12345678'] # Singapore
|
146
155
|
end
|
147
156
|
describe 'Mexico' do
|
148
|
-
|
149
|
-
|
157
|
+
it_splits '525512121212', ['52', '55', '12', '12', '12', '12'] # Mexico City
|
158
|
+
it_splits '526641231212', ['52', '664', '123', '12', '12'] # Tijuana
|
150
159
|
end
|
151
160
|
describe 'The Netherlands' do
|
152
|
-
|
153
|
-
|
154
|
-
|
161
|
+
it_splits '31612345678', ['31', '6', '12345678'] # mobile
|
162
|
+
it_splits '31201234567', ['31', '20', '1234567']
|
163
|
+
it_splits '31222123456', ['31', '222', '123456']
|
155
164
|
end
|
156
165
|
describe 'Norway' do
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
166
|
+
it_splits '4721234567', ['47',false,'21','23','45','67']
|
167
|
+
it_splits '4731234567', ['47',false,'31','23','45','67']
|
168
|
+
it_splits '4741234567', ['47',false,'412','34','567']
|
169
|
+
it_splits '4751234567', ['47',false,'51','23','45','67']
|
170
|
+
it_splits '4761234567', ['47',false,'61','23','45','67']
|
171
|
+
it_splits '4771234567', ['47',false,'71','23','45','67']
|
172
|
+
it_splits '4781234567', ['47',false,'812','34','567']
|
173
|
+
it_splits '4791234567', ['47',false,'912','34','567']
|
165
174
|
end
|
166
175
|
describe 'Peru' do
|
167
|
-
|
168
|
-
|
169
|
-
|
176
|
+
it_splits '51112341234', ['51', '1', '1234', '1234'] # Lima
|
177
|
+
it_splits '51912341234', ['51', '9', '1234', '1234'] # mobile
|
178
|
+
it_splits '51841234123', ['51', '84', '1234', '123'] # Cuzco, best effort
|
170
179
|
end
|
171
180
|
describe 'Poland' do
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
181
|
+
it_splits '48123456789', ['48', '12', '345', '67', '89'] # Landline
|
182
|
+
it_splits '48501123456', ['48', '501', '123', '456'] # Mobile
|
183
|
+
it_splits '48800123456', ['48', '800', '123', '456'] # Free
|
184
|
+
it_splits '48801123456', ['48', '801', '123', '456'] # Shared cost
|
185
|
+
it_splits '48701123456', ['48', '701', '123', '456'] # Premium
|
177
186
|
end
|
178
187
|
describe 'Portugal' do
|
179
|
-
|
180
|
-
|
181
|
-
|
188
|
+
it_splits '351211231234', ['351', '21', '123', '1234'] # Lisboa
|
189
|
+
it_splits '351241123123', ['351', '241', '123', '123'] # Abrantes
|
190
|
+
it_splits '351931231234', ['351', '93', '123', '1234'] # mobile
|
182
191
|
end
|
183
192
|
describe 'Romania' do
|
184
|
-
|
185
|
-
|
186
|
-
|
193
|
+
it_splits '40211231234', ['40', '21', '123', '1234'] # Bucureşti
|
194
|
+
it_splits '40721231234', ['40', '72', '123', '1234'] # mobile
|
195
|
+
it_splits '40249123123', ['40', '249', '123', '123'] # Olt
|
187
196
|
end
|
188
197
|
describe 'Russia' do
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
198
|
+
it_splits '78122345678', ['7', '812', '234', '56', '78'] # Russia 3-digit
|
199
|
+
it_splits '74012771077', ['7', '4012', '77', '10', '77'] # Russia 4-digit
|
200
|
+
it_splits '78402411212', ['7', '84024', '1', '12', '12'] # Russia 5-digit
|
201
|
+
it_splits '7840121212', ['7', '840', '12', '12', '12'] # Abhasia
|
202
|
+
it_splits '7799121212', ['7', '799', '12', '12', '12'] # Kazachstan
|
203
|
+
it_splits '7995344121212', ['7','995344','12','12','12'] # South Osetia
|
204
|
+
it_splits '7209175276', ['7', '209', '17', '52', '76'] # Fantasy number
|
196
205
|
end
|
197
206
|
describe 'South Korea' do
|
198
207
|
it { Phony.split('82212345678').should == ['82', '2', '1234', '5678'] } # Seoul
|
@@ -109,6 +109,33 @@ describe Phony::CountryCodes do
|
|
109
109
|
it "should format irish numbers" do
|
110
110
|
@countries.formatted('35311234567', :format => :international).should == '+353 1 123 4567'
|
111
111
|
end
|
112
|
+
it "should format luxembourgian numbers" do
|
113
|
+
@countries.formatted('352222809', :format => :international).should == '+352 22 28 09'
|
114
|
+
end
|
115
|
+
it "should format luxembourgian 4-digit ndc numbers" do
|
116
|
+
@countries.formatted('35226222809', :format => :international).should == '+352 26 22 28 09'
|
117
|
+
end
|
118
|
+
it "should format luxembourgian mobile numbers" do
|
119
|
+
@countries.formatted('352621123456', :format => :international).should == '+352 621 123 456'
|
120
|
+
end
|
121
|
+
it "should format luxembourgian city numbers" do
|
122
|
+
@countries.formatted('3524123456', :format => :international).should == '+352 4 12 34 56'
|
123
|
+
end
|
124
|
+
it "should format luxembourgian machine to machine numbers" do
|
125
|
+
@countries.formatted('352602112345678', :format => :international).should == '+352 6021 12 34 56 78'
|
126
|
+
end
|
127
|
+
it "should format luxembourgian numbers" do
|
128
|
+
@countries.formatted('352370431', :format => :international).should == '+352 37 04 31'
|
129
|
+
end
|
130
|
+
it "should format luxembourgian numbers" do
|
131
|
+
@countries.formatted('35227855', :format => :international).should == '+352 27 85 5'
|
132
|
+
end
|
133
|
+
it "should format nigerian numbers" do
|
134
|
+
@countries.formatted('23414480000', :format => :international).should == '+234 1 448 0000'
|
135
|
+
end
|
136
|
+
it "should format nigerian mobile numbers" do
|
137
|
+
@countries.formatted('2347061234567', :format => :international).should == '+234 706 123 4567'
|
138
|
+
end
|
112
139
|
context 'with no spaces' do
|
113
140
|
it "should format north american numbers" do
|
114
141
|
Phony.formatted('18091231234', :format => :international, :spaces => '').should == '+18091231234'
|
@@ -151,6 +178,7 @@ describe Phony::CountryCodes do
|
|
151
178
|
it 'should format liechtensteiner numbers' do
|
152
179
|
Phony.formatted('4233841148', :format => :international_relative, :spaces => :-).should == '00423-384-11-48'
|
153
180
|
end
|
181
|
+
|
154
182
|
end
|
155
183
|
end
|
156
184
|
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.7.
|
4
|
+
version: 1.7.12
|
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-08-
|
12
|
+
date: 2012-08-25 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
|