phony 2.2.2 → 2.2.3
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.
- checksums.yaml +14 -6
- data/README.textile +1 -0
- data/lib/phony/countries.rb +6 -1
- data/spec/functional/plausibility_spec.rb +168 -159
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
YTY4ODE5YzgzM2YwMWUzMjJiMTg4YWY4YjZkOTEwNGFlZGJiMjkzNw==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
N2UxNDExZWFhOWM3MjBmMDVhM2QzY2ExYmVjYTJjYzk1MzQ2MDgxZA==
|
|
7
|
+
!binary "U0hBNTEy":
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MzhmN2YzZmM2YzYxYTE2YzdiMGYzOTE0NTBkZWQ4NTI1MzU4ZWM2ZDhiOWVk
|
|
10
|
+
YTE3MTJhYWJjMDk4NWFkMmY1ZGI0MjJkNzcwODVjZGQ4OTdhZDY0YzIyOTcy
|
|
11
|
+
OWNjMzhlN2M0MmU4ZDE2ZDU1MTdkNDAyODVhNWM3NmM4Yjc0ZTA=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
ZTQyNjgxZDk5YzljYmNlZTljY2EwMGY5NzUzZDQ3MmFjYjcyMDYyZWNhMTBm
|
|
14
|
+
ODY3MmVmN2RjN2M1YWUzMzExYzM4ZmY2Y2JjMWQ1OTFlOWUxMmEyN2E3MGYx
|
|
15
|
+
MmU5OThhYmIwZGQ0N2Y0MDE1ZmQ0YjkyNzFlZjc3ZDNjMGQ3Y2Y=
|
data/README.textile
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"!{float:right}https://secure.travis-ci.org/floere/phony.png!":http://travis-ci.org/floere/phony
|
|
2
2
|
"!https://codeclimate.com/github/floere/phony.png!":https://codeclimate.com/github/floere/phony
|
|
3
|
+
!http://inch-pages.github.io/github/floere/phony.png!:http://inch-pages.github.io/github/floere/phony
|
|
3
4
|
|
|
4
5
|
h1. Phony
|
|
5
6
|
|
data/lib/phony/countries.rb
CHANGED
|
@@ -488,7 +488,12 @@ Phony.define do
|
|
|
488
488
|
country '294', todo # -
|
|
489
489
|
country '295', todo # -
|
|
490
490
|
country '296', todo # -
|
|
491
|
-
|
|
491
|
+
|
|
492
|
+
# Aruba
|
|
493
|
+
# http://www.itu.int/dms_pub/itu-t/oth/02/02/T020200000B0001PDFE.pdf
|
|
494
|
+
# Landline numbers begin 52 or 58.
|
|
495
|
+
country '297',
|
|
496
|
+
fixed(3) >> split(4)
|
|
492
497
|
|
|
493
498
|
# Faroe Islands http://www.wtng.info/wtng-298-fo.html
|
|
494
499
|
country '298',
|
|
@@ -126,132 +126,12 @@ describe 'plausibility' do
|
|
|
126
126
|
Phony.plausible?('+43 663 000000').should be_true
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
# TODO: more needs to be done here
|
|
130
|
-
#
|
|
131
|
-
it "is correct for Swiss numbers" do
|
|
132
|
-
Phony.plausible?('+41 44 111 22 33').should be_true
|
|
133
|
-
Phony.plausible?('+41 44 111 22 334').should be_false
|
|
134
|
-
Phony.plausible?('+41 44 111 22').should be_false
|
|
135
|
-
end
|
|
136
|
-
|
|
137
129
|
it "is correct for Belgian numbers" do
|
|
138
130
|
Phony.plausible?('+32 3 241 11 32').should be_true
|
|
139
131
|
Phony.plausible?('0032 3 241 11 32').should be_true
|
|
140
132
|
Phony.plausible?('0032 (0) 3 241 11 32').should be_true
|
|
141
133
|
end
|
|
142
134
|
|
|
143
|
-
it "is correct for Danish numbers" do
|
|
144
|
-
Phony.plausible?('+45 44 11 12 23 34').should be_false
|
|
145
|
-
Phony.plausible?('+45 44 11 12 2').should be_false
|
|
146
|
-
Phony.plausible?('+45 44 55 22 33').should be_true
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it 'is correct for egyptian numbers' do
|
|
150
|
-
Phony.plausible?('+20 800 1234567').should be_true
|
|
151
|
-
Phony.plausible?('+20 800 12345678').should be_false
|
|
152
|
-
Phony.plausible?('+20 2 12345678').should be_true
|
|
153
|
-
Phony.plausible?('+20 2 1234567').should be_false
|
|
154
|
-
Phony.plausible?('+20 40 12345678').should be_true
|
|
155
|
-
Phony.plausible?('+20 40 1234567').should be_false
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it 'is correct for Dutch numbers' do
|
|
159
|
-
Phony.plausible?('+31 6 12 34 56 78').should be_true
|
|
160
|
-
Phony.plausible?('+31 6 12 34 56 7').should be_false
|
|
161
|
-
Phony.plausible?('+31 20 123 5678').should be_true
|
|
162
|
-
Phony.plausible?('+31 20 123 567').should be_false
|
|
163
|
-
Phony.plausible?('+31 221 123 567').should be_true
|
|
164
|
-
Phony.plausible?('+31 221 123 56').should be_false
|
|
165
|
-
Phony.plausible?('+31 880 450 245').should be_true
|
|
166
|
-
Phony.plausible?('+31 880 450 24').should be_false
|
|
167
|
-
Phony.plausible?('+31 900 001 002').should be_true
|
|
168
|
-
Phony.plausible?('+31 900 001 00').should be_false
|
|
169
|
-
end
|
|
170
|
-
it 'is correct for Nigerian numbers' do
|
|
171
|
-
Phony.plausible?('+234 807 766 1234').should be_true
|
|
172
|
-
Phony.plausible?('+234 807 766 123').should be_false
|
|
173
|
-
end
|
|
174
|
-
it 'is correct for Italian numbers' do
|
|
175
|
-
Phony.plausible?('+39 06 1234 4567').should be_true
|
|
176
|
-
|
|
177
|
-
Phony.plausible?('+39 035 00000').should be_false
|
|
178
|
-
Phony.plausible?('+39 035 000000').should be_true
|
|
179
|
-
Phony.plausible?('+39 015 8407324').should be_true
|
|
180
|
-
|
|
181
|
-
Phony.plausible?('+39 0471 123 456').should be_true
|
|
182
|
-
|
|
183
|
-
# Mobile
|
|
184
|
-
Phony.plausible?('+39 335 123 4567').should be_true
|
|
185
|
-
Phony.plausible?('+39 335 123').should be_false
|
|
186
|
-
end
|
|
187
|
-
it 'is correct for German numbers' do
|
|
188
|
-
Phony.plausible?('+49 209 169 - 0').should be_true # Gelsenkirchen
|
|
189
|
-
Phony.plausible?('+49 209 169 - 3530').should be_true # Gelsenkirchen
|
|
190
|
-
Phony.plausible?('+49 40 123 45678').should be_true
|
|
191
|
-
Phony.plausible?('+49 40 123 456789').should be_true # TODO ?
|
|
192
|
-
Phony.plausible?('+49 171 123 4567').should be_true
|
|
193
|
-
Phony.plausible?('+49 171 123 45678').should be_false
|
|
194
|
-
Phony.plausible?('+49 177 123 1234').should be_true
|
|
195
|
-
Phony.plausible?('+49 176 123 12345').should be_true
|
|
196
|
-
Phony.plausible?('+49 991 1234').should be_true # stricter 3 digit ndc rules
|
|
197
|
-
Phony.plausible?('+49 2041 123').should be_true # Grandfathered numbers.
|
|
198
|
-
Phony.plausible?('+49 2041 1234567').should be_true
|
|
199
|
-
Phony.plausible?('+49 2041 12345689').should be_false # Could be a call-through number
|
|
200
|
-
Phony.plausible?('+49 31234 123456').should be_true
|
|
201
|
-
Phony.plausible?('+49 31234 1234567').should be_false # Could be a call-through number
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it 'is correct for Israelian numbers' do
|
|
205
|
-
Phony.plausible?('+972 2 123 1234').should be_true
|
|
206
|
-
Phony.plausible?('+972 59 123 1234').should be_true
|
|
207
|
-
end
|
|
208
|
-
it "is correct for US numbers" do
|
|
209
|
-
# Still need E164 conform numbers.
|
|
210
|
-
#
|
|
211
|
-
Phony.plausible?('4346667777', cc: '1').should be_false
|
|
212
|
-
|
|
213
|
-
# Automatic country checking.
|
|
214
|
-
#
|
|
215
|
-
Phony.plausible?('1-4346667777').should be_true
|
|
216
|
-
Phony.plausible?('1-800-692-7753').should be_true
|
|
217
|
-
Phony.plausible?('1-911').should be_false
|
|
218
|
-
Phony.plausible?('1-911-123-1234').should be_false
|
|
219
|
-
Phony.plausible?('143466677777').should be_false # too long
|
|
220
|
-
Phony.plausible?('143466677').should be_false # too short
|
|
221
|
-
|
|
222
|
-
# With string constraints.
|
|
223
|
-
#
|
|
224
|
-
Phony.plausible?('14346667777', cc: '1').should be_true
|
|
225
|
-
Phony.plausible?('14346667777', ndc: '434').should be_true
|
|
226
|
-
Phony.plausible?('14346667777', cc: '1', ndc: '434').should be_true
|
|
227
|
-
|
|
228
|
-
# With regexp constraints.
|
|
229
|
-
#
|
|
230
|
-
Phony.plausible?('14346667777', cc: /[123]/).should be_true
|
|
231
|
-
Phony.plausible?('14346667777', ndc: /434|435/).should be_true
|
|
232
|
-
Phony.plausible?('14346667777', cc: /[123]/, ndc: /434|435/).should be_true
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
it "is correct for Portugese numbers" do
|
|
236
|
-
Phony.plausible?('+351 800 123456').should be_true
|
|
237
|
-
Phony.plausible?('+351 90 1234567').should be_true
|
|
238
|
-
Phony.plausible?('+351 90 123456').should be_false
|
|
239
|
-
Phony.plausible?('+351 123 1234567').should be_true
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
it "is correct for Russia" do
|
|
243
|
-
Phony.plausible?('+7 800 2000 600').should be_true
|
|
244
|
-
Phony.plausible?('+7 960 301 23 45').should be_true
|
|
245
|
-
Phony.plausible?('+7 800 2000 60').should be_false # too short
|
|
246
|
-
Phony.plausible?('796030123451').should be_false # too long
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
it "is correct for Azerbaijan" do
|
|
250
|
-
Phony.plausible?('+994 12 1234567').should be_true
|
|
251
|
-
Phony.plausible?('+994 12 12345').should be_false # too short
|
|
252
|
-
Phony.plausible?('+994 12 12345678').should be_false # too long
|
|
253
|
-
end
|
|
254
|
-
|
|
255
135
|
it "is correct for Albania" do
|
|
256
136
|
Phony.plausible?('+355 85 123456').should be_true
|
|
257
137
|
Phony.plausible?('+355 85 12345').should be_false # too short
|
|
@@ -273,12 +153,6 @@ describe 'plausibility' do
|
|
|
273
153
|
Phony.plausible?('+376 7123456').should be_false # too long
|
|
274
154
|
end
|
|
275
155
|
|
|
276
|
-
it "is correct for Netherlands Antilles" do
|
|
277
|
-
Phony.plausible?('+599 1234567').should be_true
|
|
278
|
-
Phony.plausible?('+599 123456').should be_false # too short
|
|
279
|
-
Phony.plausible?('+599 12345678').should be_false # too long
|
|
280
|
-
end
|
|
281
|
-
|
|
282
156
|
it "is correct for Armenia" do
|
|
283
157
|
Phony.plausible?('+374 12345678').should be_true
|
|
284
158
|
Phony.plausible?('+374 1234567').should be_false # too short
|
|
@@ -286,9 +160,20 @@ describe 'plausibility' do
|
|
|
286
160
|
end
|
|
287
161
|
|
|
288
162
|
it "is correct for Aruba" do
|
|
289
|
-
|
|
290
|
-
Phony.plausible?('+297
|
|
291
|
-
Phony.plausible?('+297
|
|
163
|
+
# Landline
|
|
164
|
+
Phony.plausible?('+297 525 5200').should be_true
|
|
165
|
+
Phony.plausible?('+297 586 6555').should be_true
|
|
166
|
+
# Mobile
|
|
167
|
+
Phony.plausible?('+297 737 7667').should be_true
|
|
168
|
+
|
|
169
|
+
Phony.plausible?('+297 520 000').should be_false # too short
|
|
170
|
+
Phony.plausible?('+297 520 00000').should be_false # too long
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "is correct for Azerbaijan" do
|
|
174
|
+
Phony.plausible?('+994 12 1234567').should be_true
|
|
175
|
+
Phony.plausible?('+994 12 12345').should be_false # too short
|
|
176
|
+
Phony.plausible?('+994 12 12345678').should be_false # too long
|
|
292
177
|
end
|
|
293
178
|
|
|
294
179
|
it 'is correct for Bangladesh' do
|
|
@@ -325,29 +210,6 @@ describe 'plausibility' do
|
|
|
325
210
|
Phony.plausible?('+375 800 12345678').should be_false
|
|
326
211
|
end
|
|
327
212
|
|
|
328
|
-
it_is_correct_for 'Belize', :samples => '+501 205 1234'
|
|
329
|
-
it_is_correct_for 'Benin', :samples => '+229 1234 5678'
|
|
330
|
-
it_is_correct_for 'Bolivia', :samples => '+591 2 277 2266'
|
|
331
|
-
it_is_correct_for 'Botswana', :samples => ['+267 80 123 456',
|
|
332
|
-
'+267 29 567 89',
|
|
333
|
-
'+267 463 4567',
|
|
334
|
-
'+267 58 123 45',
|
|
335
|
-
'+267 7 6712 345',
|
|
336
|
-
'+267 8 1234 567']
|
|
337
|
-
it_is_correct_for 'Colombia', :samples => ['+57 1 123 4567', '+57 310 123 4567']
|
|
338
|
-
it_is_correct_for 'Philippines', :samples => [['+63 2 1234567', '+63 2 1234567890'],
|
|
339
|
-
'+63 88 1234567',
|
|
340
|
-
['+63 920 123456', '+63 920 1234567']]
|
|
341
|
-
|
|
342
|
-
it_is_correct_for 'Pakistan', :samples => ['+92 21 1234 5678',
|
|
343
|
-
'+92 22 1234 567',
|
|
344
|
-
'+92 232 123 456',
|
|
345
|
-
'+92 30 1234 5678']
|
|
346
|
-
it_is_correct_for 'Bhutan (Kingdom of)', :samples => '+975 2 889 648'
|
|
347
|
-
it_is_correct_for 'Brunei Darussalam', :samples => '+673 5 523 876'
|
|
348
|
-
it_is_correct_for 'Burkina Faso', :samples => '+226 1476 2312'
|
|
349
|
-
it_is_correct_for 'Burundi', :samples => '+257 1234 5678'
|
|
350
|
-
|
|
351
213
|
it 'is correct for Cambodia' do
|
|
352
214
|
# http://en.wikipedia.org/wiki/Telecommunications_in_Cambodia#Mobile_networks
|
|
353
215
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Cambodia
|
|
@@ -398,6 +260,160 @@ describe 'plausibility' do
|
|
|
398
260
|
Phony.plausible?("+85523123456").should be_false # Fixed line (NDC + invalid A)
|
|
399
261
|
end
|
|
400
262
|
|
|
263
|
+
it "is correct for Danish numbers" do
|
|
264
|
+
Phony.plausible?('+45 44 11 12 23 34').should be_false
|
|
265
|
+
Phony.plausible?('+45 44 11 12 2').should be_false
|
|
266
|
+
Phony.plausible?('+45 44 55 22 33').should be_true
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it 'is correct for Dutch numbers' do
|
|
270
|
+
Phony.plausible?('+31 6 12 34 56 78').should be_true
|
|
271
|
+
Phony.plausible?('+31 6 12 34 56 7').should be_false
|
|
272
|
+
Phony.plausible?('+31 20 123 5678').should be_true
|
|
273
|
+
Phony.plausible?('+31 20 123 567').should be_false
|
|
274
|
+
Phony.plausible?('+31 221 123 567').should be_true
|
|
275
|
+
Phony.plausible?('+31 221 123 56').should be_false
|
|
276
|
+
Phony.plausible?('+31 880 450 245').should be_true
|
|
277
|
+
Phony.plausible?('+31 880 450 24').should be_false
|
|
278
|
+
Phony.plausible?('+31 900 001 002').should be_true
|
|
279
|
+
Phony.plausible?('+31 900 001 00').should be_false
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
it 'is correct for Egyptian numbers' do
|
|
283
|
+
Phony.plausible?('+20 800 1234567').should be_true
|
|
284
|
+
Phony.plausible?('+20 800 12345678').should be_false
|
|
285
|
+
Phony.plausible?('+20 2 12345678').should be_true
|
|
286
|
+
Phony.plausible?('+20 2 1234567').should be_false
|
|
287
|
+
Phony.plausible?('+20 40 12345678').should be_true
|
|
288
|
+
Phony.plausible?('+20 40 1234567').should be_false
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
it 'is correct for German numbers' do
|
|
292
|
+
Phony.plausible?('+49 209 169 - 0').should be_true # Gelsenkirchen
|
|
293
|
+
Phony.plausible?('+49 209 169 - 3530').should be_true # Gelsenkirchen
|
|
294
|
+
Phony.plausible?('+49 40 123 45678').should be_true
|
|
295
|
+
Phony.plausible?('+49 40 123 456789').should be_true # TODO ?
|
|
296
|
+
Phony.plausible?('+49 171 123 4567').should be_true
|
|
297
|
+
Phony.plausible?('+49 171 123 45678').should be_false
|
|
298
|
+
Phony.plausible?('+49 177 123 1234').should be_true
|
|
299
|
+
Phony.plausible?('+49 176 123 12345').should be_true
|
|
300
|
+
Phony.plausible?('+49 991 1234').should be_true # stricter 3 digit ndc rules
|
|
301
|
+
Phony.plausible?('+49 2041 123').should be_true # Grandfathered numbers.
|
|
302
|
+
Phony.plausible?('+49 2041 1234567').should be_true
|
|
303
|
+
Phony.plausible?('+49 2041 12345689').should be_false # Could be a call-through number
|
|
304
|
+
Phony.plausible?('+49 31234 123456').should be_true
|
|
305
|
+
Phony.plausible?('+49 31234 1234567').should be_false # Could be a call-through number
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
it 'is correct for Israelian numbers' do
|
|
309
|
+
Phony.plausible?('+972 2 123 1234').should be_true
|
|
310
|
+
Phony.plausible?('+972 59 123 1234').should be_true
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
it 'is correct for Italian numbers' do
|
|
314
|
+
Phony.plausible?('+39 06 1234 4567').should be_true
|
|
315
|
+
|
|
316
|
+
Phony.plausible?('+39 035 00000').should be_false
|
|
317
|
+
Phony.plausible?('+39 035 000000').should be_true
|
|
318
|
+
Phony.plausible?('+39 015 8407324').should be_true
|
|
319
|
+
|
|
320
|
+
Phony.plausible?('+39 0471 123 456').should be_true
|
|
321
|
+
|
|
322
|
+
# Mobile
|
|
323
|
+
Phony.plausible?('+39 335 123 4567').should be_true
|
|
324
|
+
Phony.plausible?('+39 335 123').should be_false
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
it 'is correct for Malaysia' do
|
|
328
|
+
Phony.plausible?('+60 14 123 1234').should be_true
|
|
329
|
+
Phony.plausible?('+60 14 1234 1234').should be_false
|
|
330
|
+
Phony.plausible?('+60 14 1234 12').should be_false # too short
|
|
331
|
+
Phony.plausible?('+60 14 1234 12345').should be_false # too long
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
it "is correct for Netherlands Antilles" do
|
|
335
|
+
Phony.plausible?('+599 1234567').should be_true
|
|
336
|
+
Phony.plausible?('+599 123456').should be_false # too short
|
|
337
|
+
Phony.plausible?('+599 12345678').should be_false # too long
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
it 'is correct for Nigerian numbers' do
|
|
341
|
+
Phony.plausible?('+234 807 766 1234').should be_true
|
|
342
|
+
Phony.plausible?('+234 807 766 123').should be_false
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
it "is correct for Portugese numbers" do
|
|
346
|
+
Phony.plausible?('+351 800 123456').should be_true
|
|
347
|
+
Phony.plausible?('+351 90 1234567').should be_true
|
|
348
|
+
Phony.plausible?('+351 90 123456').should be_false
|
|
349
|
+
Phony.plausible?('+351 123 1234567').should be_true
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
it "is correct for Russia" do
|
|
353
|
+
Phony.plausible?('+7 800 2000 600').should be_true
|
|
354
|
+
Phony.plausible?('+7 960 301 23 45').should be_true
|
|
355
|
+
Phony.plausible?('+7 800 2000 60').should be_false # too short
|
|
356
|
+
Phony.plausible?('796030123451').should be_false # too long
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
# TODO: more needs to be done here
|
|
360
|
+
#
|
|
361
|
+
it "is correct for Swiss numbers" do
|
|
362
|
+
Phony.plausible?('+41 44 111 22 33').should be_true
|
|
363
|
+
Phony.plausible?('+41 44 111 22 334').should be_false
|
|
364
|
+
Phony.plausible?('+41 44 111 22').should be_false
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
it "is correct for US numbers" do
|
|
368
|
+
# Still need E164 conform numbers.
|
|
369
|
+
#
|
|
370
|
+
Phony.plausible?('4346667777', cc: '1').should be_false
|
|
371
|
+
|
|
372
|
+
# Automatic country checking.
|
|
373
|
+
#
|
|
374
|
+
Phony.plausible?('1-4346667777').should be_true
|
|
375
|
+
Phony.plausible?('1-800-692-7753').should be_true
|
|
376
|
+
Phony.plausible?('1-911').should be_false
|
|
377
|
+
Phony.plausible?('1-911-123-1234').should be_false
|
|
378
|
+
Phony.plausible?('143466677777').should be_false # too long
|
|
379
|
+
Phony.plausible?('143466677').should be_false # too short
|
|
380
|
+
|
|
381
|
+
# With string constraints.
|
|
382
|
+
#
|
|
383
|
+
Phony.plausible?('14346667777', cc: '1').should be_true
|
|
384
|
+
Phony.plausible?('14346667777', ndc: '434').should be_true
|
|
385
|
+
Phony.plausible?('14346667777', cc: '1', ndc: '434').should be_true
|
|
386
|
+
|
|
387
|
+
# With regexp constraints.
|
|
388
|
+
#
|
|
389
|
+
Phony.plausible?('14346667777', cc: /[123]/).should be_true
|
|
390
|
+
Phony.plausible?('14346667777', ndc: /434|435/).should be_true
|
|
391
|
+
Phony.plausible?('14346667777', cc: /[123]/, ndc: /434|435/).should be_true
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
it_is_correct_for 'Belize', :samples => '+501 205 1234'
|
|
395
|
+
it_is_correct_for 'Benin', :samples => '+229 1234 5678'
|
|
396
|
+
it_is_correct_for 'Bolivia', :samples => '+591 2 277 2266'
|
|
397
|
+
it_is_correct_for 'Botswana', :samples => ['+267 80 123 456',
|
|
398
|
+
'+267 29 567 89',
|
|
399
|
+
'+267 463 4567',
|
|
400
|
+
'+267 58 123 45',
|
|
401
|
+
'+267 7 6712 345',
|
|
402
|
+
'+267 8 1234 567']
|
|
403
|
+
it_is_correct_for 'Colombia', :samples => ['+57 1 123 4567', '+57 310 123 4567']
|
|
404
|
+
it_is_correct_for 'Philippines', :samples => [['+63 2 1234567', '+63 2 1234567890'],
|
|
405
|
+
'+63 88 1234567',
|
|
406
|
+
['+63 920 123456', '+63 920 1234567']]
|
|
407
|
+
|
|
408
|
+
it_is_correct_for 'Pakistan', :samples => ['+92 21 1234 5678',
|
|
409
|
+
'+92 22 1234 567',
|
|
410
|
+
'+92 232 123 456',
|
|
411
|
+
'+92 30 1234 5678']
|
|
412
|
+
it_is_correct_for 'Bhutan (Kingdom of)', :samples => '+975 2 889 648'
|
|
413
|
+
it_is_correct_for 'Brunei Darussalam', :samples => '+673 5 523 876'
|
|
414
|
+
it_is_correct_for 'Burkina Faso', :samples => '+226 1476 2312'
|
|
415
|
+
it_is_correct_for 'Burundi', :samples => '+257 1234 5678'
|
|
416
|
+
|
|
401
417
|
it_is_correct_for 'Cameroon', :samples => '+237 7372 8186'
|
|
402
418
|
it_is_correct_for 'Cape Verde', :samples => '+238 642 3843'
|
|
403
419
|
it_is_correct_for 'Central African Republic', :samples => '+236 1234 5678'
|
|
@@ -539,13 +555,6 @@ describe 'plausibility' do
|
|
|
539
555
|
it_is_correct_for 'Maldives (Republic of)', :samples => '+960 928 8399'
|
|
540
556
|
it_is_correct_for 'Mali', :samples => '+223 1117 9812'
|
|
541
557
|
|
|
542
|
-
it 'is correct for Malaysia' do
|
|
543
|
-
Phony.plausible?('+60 14 123 1234').should be_true
|
|
544
|
-
Phony.plausible?('+60 14 1234 1234').should be_false
|
|
545
|
-
Phony.plausible?('+60 14 1234 12').should be_false # too short
|
|
546
|
-
Phony.plausible?('+60 14 1234 12345').should be_false # too long
|
|
547
|
-
end
|
|
548
|
-
|
|
549
558
|
it_is_correct_for 'Marshall Islands (Republic of the)', :samples => '+692 372 7183'
|
|
550
559
|
it_is_correct_for 'Martinique (French Department of)', :samples => '+596 596 123 456'
|
|
551
560
|
it_is_correct_for 'Mauritania', :samples => '+222 1234 5678'
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phony
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.2.
|
|
4
|
+
version: 2.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Hanke
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-02
|
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description: 'Fast international phone number (E164 standard) normalizing, splitting
|
|
13
|
+
description: ! 'Fast international phone number (E164 standard) normalizing, splitting
|
|
14
14
|
and formatting. Lots of formatting options: International (+.., 00..), national
|
|
15
15
|
(0..), and local).'
|
|
16
16
|
email: florian.hanke+phony@gmail.com
|
|
@@ -19,9 +19,6 @@ extensions: []
|
|
|
19
19
|
extra_rdoc_files:
|
|
20
20
|
- README.textile
|
|
21
21
|
files:
|
|
22
|
-
- README.textile
|
|
23
|
-
- lib/phony.rb
|
|
24
|
-
- lib/phony/countries.rb
|
|
25
22
|
- lib/phony/countries/austria.rb
|
|
26
23
|
- lib/phony/countries/bangladesh.rb
|
|
27
24
|
- lib/phony/countries/belarus.rb
|
|
@@ -58,6 +55,7 @@ files:
|
|
|
58
55
|
- lib/phony/countries/united_kingdom.rb
|
|
59
56
|
- lib/phony/countries/uruguay.rb
|
|
60
57
|
- lib/phony/countries/zimbabwe.rb
|
|
58
|
+
- lib/phony/countries.rb
|
|
61
59
|
- lib/phony/country.rb
|
|
62
60
|
- lib/phony/country_codes.rb
|
|
63
61
|
- lib/phony/dsl.rb
|
|
@@ -72,6 +70,8 @@ files:
|
|
|
72
70
|
- lib/phony/national_splitters/variable.rb
|
|
73
71
|
- lib/phony/trunk_code.rb
|
|
74
72
|
- lib/phony/vanity.rb
|
|
73
|
+
- lib/phony.rb
|
|
74
|
+
- README.textile
|
|
75
75
|
- spec/functional/error_spec.rb
|
|
76
76
|
- spec/functional/normalize_spec.rb
|
|
77
77
|
- spec/functional/plausibility_spec.rb
|
|
@@ -98,17 +98,17 @@ require_paths:
|
|
|
98
98
|
- lib
|
|
99
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
|
-
- -
|
|
101
|
+
- - ! '>='
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: '0'
|
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
|
-
- -
|
|
106
|
+
- - ! '>='
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
108
|
version: '0'
|
|
109
109
|
requirements: []
|
|
110
110
|
rubyforge_project:
|
|
111
|
-
rubygems_version: 2.
|
|
111
|
+
rubygems_version: 2.0.3
|
|
112
112
|
signing_key:
|
|
113
113
|
specification_version: 4
|
|
114
114
|
summary: Fast international phone number (E164 standard) normalizing, splitting and
|