phone_classifier 0.0.3 → 0.0.4
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/README.md +2 -0
- data/lib/phone_classifier/forbidden.rb +2 -0
- data/lib/phone_classifier/mobile.rb +2 -0
- data/spec/phone_classifier_spec.rb +79 -48
- metadata +1 -1
data/README.md
CHANGED
@@ -40,6 +40,7 @@ Supported Countries
|
|
40
40
|
* +49, Germany
|
41
41
|
* +60, Malaysia
|
42
42
|
* +65, Singapore
|
43
|
+
* +98, Iran
|
43
44
|
* +212, Morocco
|
44
45
|
* +213, Algeria
|
45
46
|
* +233, Ghana
|
@@ -60,6 +61,7 @@ Supported Countries
|
|
60
61
|
* +386, Slovenia
|
61
62
|
* +420, Czech Republic
|
62
63
|
* +421, Slovakia
|
64
|
+
* +509, Haiti
|
63
65
|
* +852, Hong Kong
|
64
66
|
|
65
67
|
|
@@ -23,6 +23,7 @@ module Forbidden
|
|
23
23
|
'49' => %w{ 1. 164 168 169 180 181 19[0-4] 800 900 }, # Germany
|
24
24
|
'60' => %w{ 100 101 102 103 104 108 112 991 994 995 999 }, # Malaysia
|
25
25
|
'65' => %w{ 3... 800 1800 1900 }, # Singapore
|
26
|
+
'98' => %w{ 95. 96. 97. 98. 99.} , #Iran
|
26
27
|
'212' => %w{ 8. }, # Morocco
|
27
28
|
'213' => %w{ 8.. 9.. }, # Algeria
|
28
29
|
'233' => %w{ 1 4 6 7 8 9 }, # Ghana
|
@@ -43,6 +44,7 @@ module Forbidden
|
|
43
44
|
'386' => %w{ 80 89 90 }, # Slovenia
|
44
45
|
'420' => %w{ 8.. 9.. }, # Czech republic
|
45
46
|
'421' => %w{ }, # Slovakia
|
47
|
+
'509' => %w{ 8. 9. }, # Haiti
|
46
48
|
'852' => %w{ 7... 8...}, # Hong Kong
|
47
49
|
}
|
48
50
|
end
|
@@ -23,6 +23,7 @@
|
|
23
23
|
'49' => %w{ 151 152 157 159 160 162 163 17[0-9] }, # Germany
|
24
24
|
'60' => %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 }, # Malaysia
|
25
25
|
'65' => %w{ 8... 9... }, # Singapore
|
26
|
+
'98' => %w{ 91. 92. 93. } , #Iran
|
26
27
|
'212' => %w{ 6. }, # Morocco
|
27
28
|
'213' => %w{ 55 66 697 699 77 790 796 }, # Algeria
|
28
29
|
'233' => %w{ 20 23 24 26 27 28 50 54 57 }, # Ghana
|
@@ -43,6 +44,7 @@
|
|
43
44
|
'386' => %w{ 30 40 31 41 51 71 70 64}, # Slovenia
|
44
45
|
'420' => %w{ 60[1-8] 72. 73. 77. 79. 91 }, # Czech Republic
|
45
46
|
'421' => %w{ 9.. }, # Slovakia
|
47
|
+
'509' => %w{ 32 33 34 35 36 37 38 39 4. }, # Haiti
|
46
48
|
'852' => %w{ 5... 6... 9... }, # Hong Kong
|
47
49
|
}
|
48
50
|
end
|
@@ -47,7 +47,7 @@ describe PhoneClassifier do
|
|
47
47
|
|
48
48
|
it "should set BE land numbers" do
|
49
49
|
phone_number = "326279584"
|
50
|
-
|
50
|
+
PhoneClassifier.new(phone_number).kind.should == :landline
|
51
51
|
|
52
52
|
end
|
53
53
|
|
@@ -62,7 +62,7 @@ describe PhoneClassifier do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should set CH land numbers" do
|
65
|
-
phone_number =
|
65
|
+
phone_number = "41444010930"
|
66
66
|
PhoneClassifier.new(phone_number).kind.should == :landline
|
67
67
|
end
|
68
68
|
|
@@ -76,7 +76,7 @@ describe PhoneClassifier do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should set DE land numbers" do
|
79
|
-
phone_number =
|
79
|
+
phone_number = "4977317983830"
|
80
80
|
PhoneClassifier.new(phone_number).kind.should == :landline
|
81
81
|
end
|
82
82
|
|
@@ -114,7 +114,7 @@ describe PhoneClassifier do
|
|
114
114
|
context "French Numbers" do
|
115
115
|
|
116
116
|
it "should set FR forbidden numbers" do
|
117
|
-
phone_number =
|
117
|
+
phone_number = "33810459827"
|
118
118
|
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
119
119
|
end
|
120
120
|
|
@@ -180,7 +180,7 @@ describe PhoneClassifier do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it "should set PL forbidden numbers" do
|
183
|
-
phone_number =
|
183
|
+
phone_number = "488001234567"
|
184
184
|
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
185
185
|
end
|
186
186
|
|
@@ -199,7 +199,7 @@ describe PhoneClassifier do
|
|
199
199
|
end
|
200
200
|
|
201
201
|
it "should set ES forbidden numbers (900)" do
|
202
|
-
phone_number =
|
202
|
+
phone_number = "34901 123 123"
|
203
203
|
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
204
204
|
end
|
205
205
|
|
@@ -210,29 +210,6 @@ describe PhoneClassifier do
|
|
210
210
|
|
211
211
|
end
|
212
212
|
|
213
|
-
context "UK Numbers" do
|
214
|
-
|
215
|
-
it "should set UK mobile numbers" do
|
216
|
-
phone_number = "447412121314"
|
217
|
-
PhoneClassifier.new(phone_number).kind.should == :mobile
|
218
|
-
end
|
219
|
-
|
220
|
-
it "should set UK mobile numbers" do
|
221
|
-
phone_number = "44778533097"
|
222
|
-
PhoneClassifier.new(phone_number).kind.should == :mobile
|
223
|
-
end
|
224
|
-
|
225
|
-
it "should set UK land numbers" do
|
226
|
-
phone_number = "442012121314"
|
227
|
-
PhoneClassifier.new(phone_number).kind.should == :landline
|
228
|
-
end
|
229
|
-
|
230
|
-
it "should set UK forbidden numbers" do
|
231
|
-
phone_number = "4480012121314"
|
232
|
-
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
233
|
-
end
|
234
|
-
|
235
|
-
end
|
236
213
|
|
237
214
|
|
238
215
|
context "Nigerian Numbers" do
|
@@ -294,6 +271,52 @@ describe PhoneClassifier do
|
|
294
271
|
|
295
272
|
end
|
296
273
|
|
274
|
+
|
275
|
+
context "Haitian Numbers" do
|
276
|
+
|
277
|
+
it "should set mobile numbers" do
|
278
|
+
phone_number = "509 34 12 1234"
|
279
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should set service numbers " do
|
283
|
+
phone_number = "509 81 12 1234"
|
284
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
context "Hong Kong Numbers" do
|
289
|
+
|
290
|
+
it "should set mobile numbers" do
|
291
|
+
phone_number = "852 6123 1234"
|
292
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
293
|
+
end
|
294
|
+
|
295
|
+
it "should set service numbers " do
|
296
|
+
phone_number = "852 8123 1234"
|
297
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
context "Iran Numbers" do
|
303
|
+
|
304
|
+
it "should set landline numbers" do
|
305
|
+
phone_number = "98 21 1123 1234"
|
306
|
+
PhoneClassifier.new(phone_number).kind.should == :landline
|
307
|
+
end
|
308
|
+
|
309
|
+
it "should set mobile numbers" do
|
310
|
+
phone_number = "98 919 123 1234"
|
311
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
312
|
+
end
|
313
|
+
|
314
|
+
it "should set service numbers " do
|
315
|
+
phone_number = "98 961 123 1234"
|
316
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
297
320
|
context "Malaysian Numbers" do
|
298
321
|
|
299
322
|
it "should set Malaysian mobile numbers" do
|
@@ -311,32 +334,40 @@ describe PhoneClassifier do
|
|
311
334
|
|
312
335
|
context "Singapore Numbers" do
|
313
336
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
337
|
+
it "should set mobile numbers" do
|
338
|
+
phone_number = "65 8123 1234"
|
339
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
340
|
+
end
|
318
341
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
342
|
+
it "should set service numbers " do
|
343
|
+
phone_number = "65 3123 1234"
|
344
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
345
|
+
end
|
346
|
+
end
|
323
347
|
|
324
348
|
|
325
|
-
|
349
|
+
context "UK Numbers" do
|
326
350
|
|
327
|
-
|
351
|
+
it "should set UK mobile numbers" do
|
352
|
+
phone_number = "447412121314"
|
353
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
354
|
+
end
|
328
355
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
356
|
+
it "should set UK mobile numbers" do
|
357
|
+
phone_number = "44778533097"
|
358
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
359
|
+
end
|
333
360
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
361
|
+
it "should set UK land numbers" do
|
362
|
+
phone_number = "442012121314"
|
363
|
+
PhoneClassifier.new(phone_number).kind.should == :landline
|
364
|
+
end
|
338
365
|
|
366
|
+
it "should set UK forbidden numbers" do
|
367
|
+
phone_number = "4480012121314"
|
368
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
369
|
+
end
|
339
370
|
|
340
|
-
|
371
|
+
end
|
341
372
|
|
342
373
|
end
|