phony 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -1
- data/lib/phony/countries/all_other.rb +21 -17
- data/spec/lib/phony/countries/germany_spec.rb +3 -0
- data/spec/lib/phony_spec.rb +7 -1
- metadata +2 -2
data/README.textile
CHANGED
@@ -5,7 +5,7 @@ h2. Description
|
|
5
5
|
This gem can normalize, format and split E164 numbers.
|
6
6
|
"More about E164 numbers in this Wiki":http://en.wikipedia.org/wiki/E.164.
|
7
7
|
|
8
|
-
Currently handles Austrian, Australian, Belgian, Czech, Egyptian, French, German, Greek, Hungarian, Italian, (The) Netherlands, New Zealand, Norwegian, Polish, Russian, South African, Spanish, Swiss, Liechtenstein, US numbers.
|
8
|
+
Currently handles Afghan, Austrian, Australian, Belgian, Brazilian, Chilean, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, South African, Spanish, Swedish, Swiss, Liechtenstein, US, Venezuelan numbers.
|
9
9
|
And to some extend, all others. Just try if it works for you.
|
10
10
|
|
11
11
|
h2. Installation
|
@@ -97,8 +97,10 @@ module Phony
|
|
97
97
|
), # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
|
98
98
|
'56' => Countries::Chile,
|
99
99
|
'57' => fixed(2), # TODO Colombia (Republic of)
|
100
|
-
'58' => fixed(
|
101
|
-
|
100
|
+
'58' => fixed(3, # Venezuela (Bolivarian Republic of)
|
101
|
+
:local_format => [7]
|
102
|
+
),
|
103
|
+
|
102
104
|
'60' => fixed(2), # TODO Malaysia
|
103
105
|
'61' => fixed(1, # Australia
|
104
106
|
:local_format => [4, 4]
|
@@ -108,25 +110,27 @@ module Phony
|
|
108
110
|
'64' => fixed(1, # New Zealand
|
109
111
|
:local_format => [3, 4]
|
110
112
|
),
|
111
|
-
# TODO
|
112
|
-
#
|
113
|
-
'65' => fixed(2), # Singapore (Republic of)
|
114
|
-
'66' => fixed(2), # Thailand
|
113
|
+
'65' => fixed(2), # TODO Singapore (Republic of)
|
114
|
+
'66' => fixed(2), # TODO Thailand
|
115
115
|
|
116
|
-
'81' => fixed(2), # Japan
|
117
|
-
'82' => fixed(2), # Korea (Republic of)
|
118
|
-
'84' => fixed(2), # Viet Nam (Socialist Republic of)
|
119
|
-
'86' => fixed(2), # China (People's Republic of)
|
116
|
+
'81' => fixed(2), # TODO Japan
|
117
|
+
'82' => fixed(2), # TODO Korea (Republic of)
|
118
|
+
'84' => fixed(2), # TODO Viet Nam (Socialist Republic of)
|
119
|
+
'86' => fixed(2), # TODO China (People's Republic of)
|
120
120
|
|
121
|
-
'90' => fixed(2), # Turkey
|
122
|
-
'91' => fixed(2), # India (Republic of)
|
123
|
-
'92' => fixed(2), # Pakistan (Islamic Republic of)
|
124
|
-
'93' => fixed(2
|
125
|
-
|
126
|
-
|
127
|
-
'
|
121
|
+
'90' => fixed(2), # TODO Turkey
|
122
|
+
'91' => fixed(2), # TODO India (Republic of)
|
123
|
+
'92' => fixed(2), # TODO Pakistan (Islamic Republic of)
|
124
|
+
'93' => fixed(2, # Afghanistan
|
125
|
+
:local_format => [7] # Actually, the document says 6, but the examples use 7.
|
126
|
+
), # http://www.wtng.info/wtng-93-af.html
|
127
|
+
'94' => fixed(2), # TODO Sri Lanka (Democratic Socialist Republic of)
|
128
|
+
'95' => fixed(2), # TODO Myanmar (Union of)
|
129
|
+
'98' => fixed(2), # TODO Iran (Islamic Republic of)
|
128
130
|
},
|
129
131
|
3 => {
|
132
|
+
# TODO From here on.
|
133
|
+
#
|
130
134
|
'210' => fixed(2), # -
|
131
135
|
'211' => fixed(2), # -
|
132
136
|
'212' => fixed(2), # Morocco
|
@@ -22,6 +22,9 @@ describe Phony::Countries::Germany do
|
|
22
22
|
it "should handle service numbers with 180 [regression]" do
|
23
23
|
@germany.split('1805878323').should == ['180', '587', '8323']
|
24
24
|
end
|
25
|
+
it "should handle service numbers with 181 [regression]" do
|
26
|
+
@germany.split('1815878323').should == ['181', '587', '8323']
|
27
|
+
end
|
25
28
|
end
|
26
29
|
|
27
30
|
end
|
data/spec/lib/phony_spec.rb
CHANGED
@@ -5,6 +5,9 @@ require 'spec_helper'
|
|
5
5
|
describe Phony do
|
6
6
|
|
7
7
|
describe "split" do
|
8
|
+
it 'handles afghan numbers' do
|
9
|
+
Phony.split('93201234567').should == ['93', '20', '1234567'] # Kabul
|
10
|
+
end
|
8
11
|
it "should handle austrian numbers" do
|
9
12
|
Phony.split('43198110').should == ['43', '1', '98110']
|
10
13
|
end
|
@@ -13,7 +16,7 @@ describe Phony do
|
|
13
16
|
end
|
14
17
|
it 'handles chilean numbers' do
|
15
18
|
Phony.split('5621234567').should == ['56', '2', '1234567'] # Santiago
|
16
|
-
Phony.split('5675123456').should == ['56', '75', '123456']
|
19
|
+
Phony.split('5675123456').should == ['56', '75', '123456'] # Curico
|
17
20
|
Phony.split('56912345678').should == ['56', '9', '12345678'] # mobile
|
18
21
|
end
|
19
22
|
it 'handles danish numbers' do
|
@@ -71,6 +74,9 @@ describe Phony do
|
|
71
74
|
it "should handle US numbers" do
|
72
75
|
Phony.split('15551115511').should == ['1', '555', '111', '5511']
|
73
76
|
end
|
77
|
+
it "should handle venezuelan numbers" do
|
78
|
+
Phony.split('582121234567').should == ["58", "212", "1234567"]
|
79
|
+
end
|
74
80
|
it "should handle new zealand numbers" do
|
75
81
|
Phony.split('6491234567').should == ['64', '9', '123', '4567']
|
76
82
|
end
|