phone 1.2.3 → 1.3.0.beta0
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 +4 -4
- data/.document +3 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +14 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +50 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +183 -0
- data/Rakefile +38 -0
- data/data/{phone_countries.yml → phone/countries.yml} +16 -14
- data/lib/phone.rb +75 -53
- data/lib/phone/country.rb +45 -0
- data/lib/{errors.rb → phone/errors.rb} +0 -0
- data/lib/phone/version.rb +4 -0
- data/phone.gemspec +25 -0
- data/test/countries/au_test.rb +11 -11
- data/test/countries/ba_test.rb +4 -4
- data/test/countries/be_test.rb +12 -11
- data/test/countries/de_test.rb +7 -7
- data/test/countries/es_test.rb +33 -0
- data/test/countries/fr_test.rb +5 -5
- data/test/countries/gb_test.rb +42 -41
- data/test/countries/hr_test.rb +14 -14
- data/test/countries/hu_test.rb +5 -5
- data/test/countries/ie_test.rb +20 -0
- data/test/countries/nl_test.rb +43 -43
- data/test/countries/nz_test.rb +8 -0
- data/test/countries/pt_test.rb +18 -18
- data/test/countries/rs_test.rb +7 -7
- data/test/countries/se_test.rb +44 -43
- data/test/countries/si_test.rb +7 -7
- data/test/countries/ua_test.rb +4 -4
- data/test/countries/us_test.rb +6 -6
- data/test/countries/uy_test.rb +22 -0
- data/test/countries/za_test.rb +4 -4
- data/test/extension_test.rb +3 -3
- data/test/helper.rb +41 -0
- data/test/phone_test.rb +99 -53
- data/test_usa_phones_with_extensions.csv +99 -0
- metadata +112 -30
- data/LICENSE +0 -19
- data/Readme.rdoc +0 -126
- data/lib/country.rb +0 -36
- data/lib/support.rb +0 -78
- data/test/test_helper.rb +0 -15
data/test/countries/pt_test.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
3
|
## Portugal
|
4
4
|
# source 1: http://pt.wikipedia.org/wiki/N%C3%BAmeros_de_telefone_em_Portugal
|
5
5
|
# source 2: http://www.anacom.pt/render.jsp?categoryId=279035
|
6
6
|
|
7
|
-
class PTTest < Test
|
8
|
-
|
7
|
+
class PTTest < Minitest::Test
|
8
|
+
|
9
9
|
### Prefixes followed by corresponding tests
|
10
|
-
|
10
|
+
|
11
11
|
## 01-09: reserved for future use
|
12
12
|
## 1: Short Numbers
|
13
|
-
|
13
|
+
|
14
14
|
## 2: Landline / fixed numbers
|
15
15
|
|
16
16
|
## two digits landlines
|
@@ -22,13 +22,13 @@ class PTTest < Test::Unit::TestCase
|
|
22
22
|
def test_oporto
|
23
23
|
parse_test('+351 22 123 4567', '351', '22', '1234567')
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
## three digits landlines
|
27
27
|
# 231: Mealhada
|
28
28
|
def test_mealhada
|
29
29
|
parse_test('+351 231 123456', '351', '231', '123456')
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
# 232-295 (Viseu - Angra do Heroismo)
|
33
33
|
def test_viseu
|
34
34
|
parse_test('+351 232 123456', '351', '232', '123456')
|
@@ -36,27 +36,27 @@ class PTTest < Test::Unit::TestCase
|
|
36
36
|
def test_angra
|
37
37
|
parse_test('+351 295 123456', '351', '295', '123456')
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
# 296: Ponta Delgada
|
41
41
|
def test_pontadelgada
|
42
42
|
parse_test('+351 296 123456', '351', '296', '123456')
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
## 3: Nomad services
|
46
46
|
## 4: Not used
|
47
47
|
## 5: Free
|
48
48
|
## 6: Audiotext service, data network access...
|
49
49
|
|
50
|
-
## 7: Premium numbers ("Universal access numbers")
|
51
|
-
|
50
|
+
## 7: Premium numbers ("Universal access numbers")
|
51
|
+
|
52
52
|
# 707-708: Premium Numbers
|
53
53
|
def test_707
|
54
54
|
Phoner::Phone.default_country_code = '351'
|
55
55
|
parse_test('707 123 456', '351', '707', '123456')
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
## 8: Free toll numbers
|
59
|
-
|
59
|
+
|
60
60
|
# 800: Numero verde ("Green Number")
|
61
61
|
def test_800
|
62
62
|
Phoner::Phone.default_country_code = '351'
|
@@ -72,9 +72,9 @@ class PTTest < Test::Unit::TestCase
|
|
72
72
|
Phoner::Phone.default_country_code = '351'
|
73
73
|
parse_test('809 123 456', '351', '809', '123456')
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
## 9: Mobile networks
|
77
|
-
|
77
|
+
|
78
78
|
## two-digits mobile networks
|
79
79
|
# 91: Vodafone
|
80
80
|
def test_vodafone
|
@@ -88,7 +88,7 @@ class PTTest < Test::Unit::TestCase
|
|
88
88
|
def test_tmn
|
89
89
|
parse_test('+351 96 1234567', '351', '96', '1234567')
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
## three-digits mobile networks
|
93
93
|
# 921: TMN three-digits
|
94
94
|
def test_tmn921
|
@@ -106,7 +106,7 @@ class PTTest < Test::Unit::TestCase
|
|
106
106
|
def test_zonmobile
|
107
107
|
parse_test('+351 929 123456', '351', '929', '123456')
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
def test_validates
|
111
111
|
Phoner::Phone.default_country_code = nil
|
112
112
|
assert_equal Phoner::Phone.valid?('00351211234567'), true
|
@@ -125,5 +125,5 @@ class PTTest < Test::Unit::TestCase
|
|
125
125
|
assert_equal Phoner::Phone.valid?('708123456'), true
|
126
126
|
assert_equal Phoner::Phone.valid?('800 123 456'), true
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
end
|
data/test/countries/rs_test.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
3
|
## Serbia
|
4
|
-
class RSTest < Test
|
5
|
-
|
4
|
+
class RSTest < Minitest::Test
|
5
|
+
|
6
6
|
def test_local
|
7
7
|
# Beograd
|
8
8
|
parse_test('+381 11 24 33 836', '381', '11', '2433836')
|
9
9
|
end
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
|
12
12
|
def test_mobile
|
13
13
|
# mts
|
14
14
|
parse_test('+381 648542987', '381', '64', '8542987')
|
15
|
-
end
|
16
|
-
|
15
|
+
end
|
16
|
+
|
17
17
|
end
|
data/test/countries/se_test.rb
CHANGED
@@ -1,121 +1,122 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "helper"
|
2
3
|
|
3
4
|
## Sweden
|
4
|
-
class SETest < Test
|
5
|
+
class SETest < Minitest::Test
|
5
6
|
|
6
7
|
# 08 Greater Stockholm
|
7
8
|
def test_stockholm
|
8
9
|
parse_test('+4685555555', '46', '8', '5555555')
|
9
10
|
end
|
10
|
-
|
11
|
+
|
11
12
|
## two digit codes
|
12
|
-
|
13
|
+
|
13
14
|
# 010 Geographically Independent Numbers / VOIP services
|
14
15
|
def test_independent_numbers
|
15
16
|
parse_test('+46105555555', '46', '10', '5555555')
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
# 011 Norrköping
|
19
20
|
def test_norrkoping
|
20
21
|
parse_test('+46115555555', '46', '11', '5555555')
|
21
22
|
end
|
22
|
-
|
23
|
+
|
23
24
|
# 013 Linköping
|
24
25
|
def test_linkoping
|
25
26
|
parse_test('+46135555555', '46', '13', '5555555')
|
26
27
|
end
|
27
|
-
|
28
|
+
|
28
29
|
# 016 Eskilstuna-Torshälla
|
29
30
|
def test_eskilstuna
|
30
31
|
parse_test('+46165555555', '46', '16', '5555555')
|
31
32
|
end
|
32
|
-
|
33
|
+
|
33
34
|
# 018 Uppsala
|
34
35
|
def test_uppsala
|
35
36
|
parse_test('+46185555555', '46', '18', '5555555')
|
36
37
|
end
|
37
|
-
|
38
|
+
|
38
39
|
# 019 Örebro-Kumla
|
39
40
|
def test_orebro
|
40
41
|
parse_test('+46195555555', '46', '19', '5555555')
|
41
42
|
end
|
42
|
-
|
43
|
+
|
43
44
|
# 020 toll-free
|
44
45
|
def test_toll_free
|
45
46
|
parse_test('+46205555555', '46', '20', '5555555')
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
# 021 Västerås
|
49
50
|
def test_vasteras
|
50
51
|
parse_test('+46215555555', '46', '21', '5555555')
|
51
52
|
end
|
52
|
-
|
53
|
+
|
53
54
|
# 023 Falun
|
54
55
|
def test_falun
|
55
56
|
parse_test('+46235555555', '46', '23', '5555555')
|
56
57
|
end
|
57
|
-
|
58
|
+
|
58
59
|
# 026 Gävle-Sandviken
|
59
60
|
def test_gavle
|
60
61
|
parse_test('+46265555555', '46', '26', '5555555')
|
61
62
|
end
|
62
|
-
|
63
|
+
|
63
64
|
# 031 Göteborg
|
64
65
|
def test_goteborg
|
65
66
|
parse_test('+46315555555', '46', '31', '5555555')
|
66
67
|
end
|
67
|
-
|
68
|
+
|
68
69
|
# 033 Borås
|
69
70
|
def test_boras
|
70
71
|
parse_test('+46335555555', '46', '33', '5555555')
|
71
72
|
end
|
72
|
-
|
73
|
+
|
73
74
|
# 035 Halmstad
|
74
75
|
def test_halmstad
|
75
76
|
parse_test('+46355555555', '46', '35', '5555555')
|
76
77
|
end
|
77
|
-
|
78
|
+
|
78
79
|
# 036 Jönköping-Huskvarna
|
79
80
|
def test_jonkoping
|
80
81
|
parse_test('+46365555555', '46', '36', '5555555')
|
81
82
|
end
|
82
|
-
|
83
|
+
|
83
84
|
# 040 Malmö
|
84
85
|
def test_malmo
|
85
86
|
parse_test('+46405555555', '46', '40', '5555555')
|
86
87
|
end
|
87
|
-
|
88
|
+
|
88
89
|
# 042 Helsingborg-Höganäs
|
89
90
|
def test_helsingborg
|
90
91
|
parse_test('+46425555555', '46', '42', '5555555')
|
91
92
|
end
|
92
|
-
|
93
|
+
|
93
94
|
# 044 Kristianstad
|
94
95
|
def test_kristianstad
|
95
96
|
parse_test('+46445555555', '46', '44', '5555555')
|
96
97
|
end
|
97
|
-
|
98
|
+
|
98
99
|
# 046 Lund
|
99
100
|
def test_lund
|
100
101
|
parse_test('+46465555555', '46', '46', '5555555')
|
101
102
|
end
|
102
|
-
|
103
|
+
|
103
104
|
# 054 Karlstad
|
104
105
|
def test_karlstad
|
105
106
|
parse_test('+46545555555', '46', '54', '5555555')
|
106
107
|
end
|
107
|
-
|
108
|
+
|
108
109
|
# 060 Sundsvall-Timrå
|
109
110
|
def test_sundsvall
|
110
111
|
parse_test('+46605555555', '46', '60', '5555555')
|
111
112
|
end
|
112
|
-
|
113
|
+
|
113
114
|
# 063 Östersund
|
114
115
|
def test_ostersund
|
115
116
|
parse_test('+46635555555', '46', '63', '5555555')
|
116
117
|
end
|
117
|
-
|
118
|
-
# 070,
|
118
|
+
|
119
|
+
# 070,
|
119
120
|
def test_mobile_70
|
120
121
|
parse_test('+46705555555', '46', '70', '5555555')
|
121
122
|
end
|
@@ -124,34 +125,34 @@ class SETest < Test::Unit::TestCase
|
|
124
125
|
def test_telematics
|
125
126
|
parse_test('+46715555555', '46', '71', '5555555')
|
126
127
|
end
|
127
|
-
|
128
|
-
# 072,
|
128
|
+
|
129
|
+
# 072,
|
129
130
|
def test_mobile_72
|
130
131
|
parse_test('+46725555555', '46', '72', '5555555')
|
131
132
|
end
|
132
|
-
|
133
|
-
# 073,
|
133
|
+
|
134
|
+
# 073,
|
134
135
|
def test_mobile_73
|
135
136
|
parse_test('+46735555555', '46', '73', '5555555')
|
136
137
|
end
|
137
|
-
|
138
|
+
|
138
139
|
# 076 Mobile networks
|
139
140
|
def test_mobile_76
|
140
141
|
parse_test('+46765555555', '46', '76', '5555555')
|
141
142
|
end
|
142
|
-
|
143
|
+
|
143
144
|
# 090 Umeå
|
144
145
|
def test_umea
|
145
146
|
parse_test('+46905555555', '46', '90', '5555555')
|
146
147
|
end
|
147
|
-
|
148
|
+
|
148
149
|
# 099 Premium rate calls
|
149
150
|
def test_premium_99
|
150
151
|
parse_test('+46995555555', '46', '99', '5555555')
|
151
152
|
end
|
152
153
|
|
153
154
|
## three digit codes
|
154
|
-
|
155
|
+
|
155
156
|
# 0120 Åtvidaberg
|
156
157
|
def test_atvidaberg
|
157
158
|
parse_test('+46120555555', '46', '120', '555555')
|
@@ -181,7 +182,7 @@ class SETest < Test::Unit::TestCase
|
|
181
182
|
# 0174 Alunda
|
182
183
|
# 0175 Hallstavik-Rimbo
|
183
184
|
# 0176 Norrtälje
|
184
|
-
|
185
|
+
|
185
186
|
# 0220 Hallstahammar-Surahammar
|
186
187
|
def test_hallstahammar
|
187
188
|
parse_test('+462205555555', '46', '220', '5555555')
|
@@ -221,7 +222,7 @@ class SETest < Test::Unit::TestCase
|
|
221
222
|
def test_ockelbo
|
222
223
|
parse_test('+462975555555', '46', '297', '5555555')
|
223
224
|
end
|
224
|
-
|
225
|
+
|
225
226
|
# 0300 Kungsbacka
|
226
227
|
def test_kungsbacka
|
227
228
|
parse_test('+463005555555', '46', '300', '5555555')
|
@@ -250,7 +251,7 @@ class SETest < Test::Unit::TestCase
|
|
250
251
|
# 0390 Gränna
|
251
252
|
# 0392 Mullsjö
|
252
253
|
# 0393 Vaggeryd
|
253
|
-
|
254
|
+
|
254
255
|
# 0410 Trelleborg
|
255
256
|
def test_trelleborg
|
256
257
|
parse_test('+464105555555', '46', '410', '5555555')
|
@@ -302,7 +303,7 @@ class SETest < Test::Unit::TestCase
|
|
302
303
|
# 0496 Mariannelund
|
303
304
|
# 0498 Gotland
|
304
305
|
# 0499 Mönsterås
|
305
|
-
|
306
|
+
|
306
307
|
# 0500 Skövde
|
307
308
|
def test_skovde
|
308
309
|
parse_test('+465005555555', '46', '500', '5555555')
|
@@ -365,7 +366,7 @@ class SETest < Test::Unit::TestCase
|
|
365
366
|
# 0589 Arboga
|
366
367
|
# 0590 Filipstad
|
367
368
|
# 0591 Hällefors-Grythyttan
|
368
|
-
|
369
|
+
|
369
370
|
# 0611 Härnösand
|
370
371
|
def test_harnosand
|
371
372
|
parse_test('+466115555555', '46', '611', '5555555')
|
@@ -408,15 +409,15 @@ class SETest < Test::Unit::TestCase
|
|
408
409
|
# 0693 Bräcke-Gällö
|
409
410
|
# 0695 Stugun
|
410
411
|
# 0696 Hammarstrand
|
411
|
-
|
412
|
+
|
412
413
|
# 07x(x) various non-geographical area codes
|
413
414
|
# ambiguous!
|
414
|
-
|
415
|
+
|
415
416
|
# 074(x) Pagers
|
416
417
|
def test_pagers
|
417
418
|
parse_test('+467405555555', '46', '740', '5555555')
|
418
419
|
end
|
419
|
-
|
420
|
+
|
420
421
|
# 0900 Premium rate calls
|
421
422
|
def test_premium_900
|
422
423
|
parse_test('+469005555555', '46', '900', '5555555')
|
@@ -450,7 +451,7 @@ class SETest < Test::Unit::TestCase
|
|
450
451
|
def test_vannas
|
451
452
|
parse_test('+469355555555', '46', '935', '5555555')
|
452
453
|
end
|
453
|
-
# 0939 Premium rate calls
|
454
|
+
# 0939 Premium rate calls
|
454
455
|
# 0940 Vilhelmina
|
455
456
|
# 0941 Åsele
|
456
457
|
# 0942 Dorotea
|
data/test/countries/si_test.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
3
|
## Slovenia
|
4
|
-
class SITest < Test
|
5
|
-
|
4
|
+
class SITest < Minitest::Test
|
5
|
+
|
6
6
|
def test_local
|
7
7
|
#Maribor
|
8
8
|
parse_test('+ 386 2 23 46 611', '386', '2', '2346611')
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def test_local_2
|
12
12
|
# Koper
|
13
13
|
parse_test('+ 386 5 23 46 611', '386', '5', '2346611')
|
14
|
-
end
|
15
|
-
|
14
|
+
end
|
15
|
+
|
16
16
|
def test_mobile
|
17
17
|
# Mobitel
|
18
18
|
parse_test('+386 51 258999', '386', '51', '258999')
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
end
|
data/test/countries/ua_test.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
3
|
## Ukraine
|
4
|
-
class UATest < Test
|
4
|
+
class UATest < Minitest::Test
|
5
5
|
|
6
6
|
def test_local
|
7
7
|
parse_test('+380 57 711 22 33', '380', '57', '7112233')
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def test_mobile
|
11
11
|
parse_test('+380-50-111-22-33', '380', '50', '1112233')
|
12
12
|
end
|
@@ -14,5 +14,5 @@ class UATest < Test::Unit::TestCase
|
|
14
14
|
def test_mobile2
|
15
15
|
parse_test('+380-66-042-22-01', '380', '66', '0422201')
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
end
|