phone_classifier 0.0.9 → 0.0.11
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 +3 -0
- data/lib/phone_classifier/forbidden.rb +5 -0
- data/lib/phone_classifier/mobile.rb +7 -2
- data/spec/phone_classifier_spec.rb +86 -9
- metadata +2 -2
data/README.md
CHANGED
@@ -40,7 +40,9 @@ Supported Countries
|
|
40
40
|
* +49, Germany
|
41
41
|
* +54, Argentina
|
42
42
|
* +60, Malaysia
|
43
|
+
* +61, Australia
|
43
44
|
* +65, Singapore
|
45
|
+
* +90, Turkey
|
44
46
|
* +94, Sri Lanka
|
45
47
|
* +91, India
|
46
48
|
* +98, Iran
|
@@ -69,6 +71,7 @@ Supported Countries
|
|
69
71
|
* +503, El Salvador
|
70
72
|
* +509, Haiti
|
71
73
|
* +852, Hong Kong
|
74
|
+
* +972, Israel
|
72
75
|
|
73
76
|
|
74
77
|
Where is it used
|
@@ -21,9 +21,12 @@ module Forbidden
|
|
21
21
|
'47' => %w{ 8.. }, # Norway
|
22
22
|
'48' => %w{70., 80.}, # Poland
|
23
23
|
'49' => %w{ 1. 164 168 169 180 181 19[0-4] 800 900 }, # Germany
|
24
|
+
'52' => %w{ }, # Mexico
|
24
25
|
'54' => %w{ 6.. 8.. }, # Argentina
|
25
26
|
'60' => %w{ 100 101 102 103 104 108 112 991 994 995 999 }, # Malaysia
|
27
|
+
'61' => %w{ 1 }, # Australia
|
26
28
|
'65' => %w{ 3... 800 1800 1900 }, # Singapore
|
29
|
+
'90' => %w{ 592 594 596 522 900 800 850 822 512 }, # Turkey
|
27
30
|
'91' => %w{ 90 95 96 }, # India
|
28
31
|
'94' => %w{ }, # Sri Lanka
|
29
32
|
'98' => %w{ 95. 96. 97. 98. 99.} , #Iran
|
@@ -52,6 +55,8 @@ module Forbidden
|
|
52
55
|
'503' => %w{ }, # El Salvador
|
53
56
|
'509' => %w{ 8. 9. }, # Haiti
|
54
57
|
'852' => %w{ 7... 8...}, # Hong Kong
|
58
|
+
'970' => %w{ 1 }, # Israel (blocked cc)
|
59
|
+
'972' => %w{ 1 }, # Israel
|
55
60
|
}
|
56
61
|
end
|
57
62
|
end
|
@@ -14,16 +14,19 @@
|
|
14
14
|
'39' => %w{3..}, # Italy
|
15
15
|
'40' => %w{ 7. }, # Romania
|
16
16
|
'41' => %w{ 7[6-9] }, # Switerzland
|
17
|
-
'43' => %w{ 67 68 644 65. 66. }, # Austria
|
17
|
+
'43' => %w{ 67 68 644 65. 66. 67. 68. 69. }, # Austria
|
18
18
|
'44' => %w{ 7[4-9].. }, # UK
|
19
19
|
'45' => %w{ 2[0-9] 30 31 40 41 42 5[0-3] 60 61 71 81 9[1-3] }, # Denmark
|
20
20
|
'46' => %w{ 70 72 73 76 }, # Sweden
|
21
21
|
'47' => %w{ 9.. 4.. 58. 59. }, # Norway
|
22
22
|
'48' => %w{50. 51. 53. 60. 66. 69. 72. 78. 79. 88.}, # Poland
|
23
23
|
'49' => %w{ 151 152 157 159 160 162 163 17[0-9] }, # Germany
|
24
|
-
'
|
24
|
+
'52' => %w{ .. ... }, # Mexico
|
25
|
+
'54' => %w{ \d{2} \d{3} \d{4} }, # Argentina (Everything can be mobile)
|
25
26
|
'60' => %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 }, # Malaysia
|
27
|
+
'61' => %w{ 4.. }, # Australia
|
26
28
|
'65' => %w{ 8... 9... }, # Singapore
|
29
|
+
'90' => %w{ 53. 54. 50. 55. }, # Turkey
|
27
30
|
'91' => %w{ 91 92 93 94 97 98 99 }, # India
|
28
31
|
'94' => %w{ 71 72 75 77 78 }, # Sri Lanka
|
29
32
|
'98' => %w{ 91. 92. 93. } , #Iran
|
@@ -52,6 +55,8 @@
|
|
52
55
|
'503' => %w{ 6... 7... }, # El Salvador
|
53
56
|
'509' => %w{ 32 33 34 35 36 37 38 39 4. }, # Haiti
|
54
57
|
'852' => %w{ 5... 6... 9... }, # Hong Kong
|
58
|
+
'970' => %w{ 5. }, # Israel (blocked cc)
|
59
|
+
'972' => %w{ 5. }, # Israel
|
55
60
|
}
|
56
61
|
end
|
57
62
|
end
|
@@ -5,11 +5,6 @@ require 'spec_helper'
|
|
5
5
|
|
6
6
|
describe PhoneClassifier do
|
7
7
|
|
8
|
-
context 'it handles invalid number' do
|
9
|
-
it 'does not timeout' do
|
10
|
-
PhoneClassifier.new('52726').kind.should == :landline
|
11
|
-
end
|
12
|
-
end
|
13
8
|
|
14
9
|
context "it classifies a phone number" do
|
15
10
|
|
@@ -44,6 +39,40 @@ describe PhoneClassifier do
|
|
44
39
|
context "kinds of numbers" do
|
45
40
|
|
46
41
|
|
42
|
+
context "Argentinan Numbers" do
|
43
|
+
|
44
|
+
it "should set AG mobile numbers" do
|
45
|
+
phone_number = "54111234566"
|
46
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context "Austrian Numbers" do
|
53
|
+
|
54
|
+
it "should set AT mobile numbers" do
|
55
|
+
phone_number = "4369911031234"
|
56
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
context "Australian Numbers" do
|
64
|
+
|
65
|
+
it "should set AU mobile numbers" do
|
66
|
+
phone_number = "61412123123"
|
67
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should set AU forbideen numbers" do
|
71
|
+
phone_number = "61190123123"
|
72
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
47
76
|
context "Belgium Numbers" do
|
48
77
|
|
49
78
|
it "should set BE mobile numbers" do
|
@@ -74,6 +103,27 @@ describe PhoneClassifier do
|
|
74
103
|
|
75
104
|
end
|
76
105
|
|
106
|
+
context "Swedish Numbers" do
|
107
|
+
|
108
|
+
it "should set SE mobile numbers" do
|
109
|
+
phone_number = "46729443333"
|
110
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
context "Slovenian Numbers" do
|
117
|
+
|
118
|
+
it "should set SL mobile numbers" do
|
119
|
+
phone_number = "38651336595"
|
120
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
end
|
126
|
+
|
77
127
|
context "German Numbers" do
|
78
128
|
|
79
129
|
it "should set DE mobile numbers" do
|
@@ -155,6 +205,12 @@ describe PhoneClassifier do
|
|
155
205
|
|
156
206
|
end
|
157
207
|
|
208
|
+
context 'Mexican Numbers' do
|
209
|
+
it 'should set mobile numbers' do
|
210
|
+
phone_number = "5215531048111"
|
211
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
212
|
+
end
|
213
|
+
end
|
158
214
|
context "Netherlands Numbers" do
|
159
215
|
|
160
216
|
it "should set NL mobile numbers" do
|
@@ -217,7 +273,6 @@ describe PhoneClassifier do
|
|
217
273
|
end
|
218
274
|
|
219
275
|
|
220
|
-
|
221
276
|
context "Nigerian Numbers" do
|
222
277
|
|
223
278
|
it "should set Nigeria mobile numbers" do
|
@@ -329,12 +384,29 @@ describe PhoneClassifier do
|
|
329
384
|
PhoneClassifier.new(phone_number).kind.should == :mobile
|
330
385
|
end
|
331
386
|
|
332
|
-
it "should set service numbers
|
387
|
+
it "should set service numbers" do
|
333
388
|
phone_number = "98 961 123 1234"
|
334
389
|
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
335
390
|
end
|
336
391
|
end
|
337
392
|
|
393
|
+
context 'Israelian numbers' do
|
394
|
+
it 'sets landline number' do
|
395
|
+
phone_number = "972 2 123 1234"
|
396
|
+
PhoneClassifier.new(phone_number).kind.should == :landline
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'sets mobile numbers' do
|
400
|
+
phone_number = "972 59 123 1234"
|
401
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
402
|
+
end
|
403
|
+
|
404
|
+
it 'sets service numbers' do
|
405
|
+
phone_number = "972 1 123 1234"
|
406
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
338
410
|
context "Malaysian Numbers" do
|
339
411
|
|
340
412
|
it "should set Malaysian mobile numbers" do
|
@@ -395,7 +467,7 @@ describe PhoneClassifier do
|
|
395
467
|
|
396
468
|
end
|
397
469
|
|
398
|
-
|
470
|
+
context "Tanzania Numbers" do
|
399
471
|
|
400
472
|
it "should set mobile numbers" do
|
401
473
|
phone_number = "255 61 123 1234"
|
@@ -404,10 +476,15 @@ describe PhoneClassifier do
|
|
404
476
|
|
405
477
|
it "should set service numbers " do
|
406
478
|
phone_number = "255 801 23 1234"
|
407
|
-
|
479
|
+
PhoneClassifier.new(phone_number).kind.should == :forbidden
|
408
480
|
end
|
409
481
|
end
|
410
482
|
|
483
|
+
context 'Turkey numbers' do
|
484
|
+
phone_number = "90 532 412 5111"
|
485
|
+
PhoneClassifier.new(phone_number).kind.should == :mobile
|
486
|
+
end
|
487
|
+
|
411
488
|
context "UK Numbers" do
|
412
489
|
|
413
490
|
it "should set UK mobile numbers" do
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: phone_classifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.11
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jens-Christian Fischer
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|