phony 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -1
- data/lib/countries.rb +6 -2
- data/spec/lib/countries_spec.rb +12 -1
- metadata +1 -1
data/README.textile
CHANGED
@@ -7,7 +7,7 @@ This gem can normalize, format and split E164 numbers.
|
|
7
7
|
|
8
8
|
The (admittedly crazy) *goal* of this Gem is to be able to format/split all phone numbers in the world.
|
9
9
|
|
10
|
-
Currently handles Afghan, Algerian, Austrian, Australian, Belgian, Brazilian, Chilean, Chinese, Cuban, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, Malaysian, Mexican, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, South African, South Korean, Spanish, Swedish, Swiss, Tunisian, Turkish, Liechtenstein, UK, US, and Venezuelan numbers.
|
10
|
+
Currently handles Afghan, Algerian, Austrian, Australian, Belgian, Brazilian, Chilean, Chinese, Croatian, Cuban, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, Lithuanian, Malaysian, Mexican, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, Slovakian, South African, South Korean, Spanish, Swedish, Swiss, Tunisian, Turkish, Liechtenstein, UK, US, and Venezuelan numbers.
|
11
11
|
And to some extent, all others. Just try if it works for you.
|
12
12
|
|
13
13
|
If it doesn't, please "enter an issue":http://github.com/floere/phony/issues.
|
data/lib/countries.rb
CHANGED
@@ -200,7 +200,11 @@ Phony.define do
|
|
200
200
|
one_of('2','3','5','6','8','9', :max_length => 2) >> split(3,3)
|
201
201
|
country '359', fixed(2) >> split(3,2,2) # Bulgaria
|
202
202
|
|
203
|
-
country '370',
|
203
|
+
country '370', one_of('700', '800') >> split(2,3) | # Lithuania
|
204
|
+
match(/^(6\d\d)\d+$/) >> split(2,3) | # Mobile
|
205
|
+
one_of('5') >> split(3,2,2) | # Vilnius
|
206
|
+
one_of('37','41') >> split(2,2,2) | #
|
207
|
+
fixed(3) >> split(1,2,2)
|
204
208
|
country '371', fixed(2) >> split(3,2,2) # Latvia
|
205
209
|
country '372', fixed(2) >> split(3,2,2) # Estonia
|
206
210
|
country '373', fixed(2) >> split(3,2,2) # Moldova
|
@@ -216,7 +220,7 @@ Phony.define do
|
|
216
220
|
country '382', fixed(2) >> split(3,2,2) # -
|
217
221
|
country '383', fixed(2) >> split(3,2,2) # -
|
218
222
|
country '384', fixed(2) >> split(3,2,2) # -
|
219
|
-
country '385',
|
223
|
+
country '385', one_of('1', :max_length => 2) >> split(3,5) # Croatia
|
220
224
|
country '386', fixed(2) >> split(3,2,2) # Slovenia
|
221
225
|
country '387', fixed(2) >> split(3,2,2) # Bosnia and Herzegovina
|
222
226
|
country '388', fixed(2) >> split(3,2,2) # Group of countries, shared code
|
data/spec/lib/countries_spec.rb
CHANGED
@@ -42,6 +42,10 @@ describe 'country descriptions' do
|
|
42
42
|
Phony.split('862112345678').should == ['86', '21', '1234', '5678'] # Shanghai
|
43
43
|
Phony.split('8675582193447').should == ['86', '755', '8219', '3447'] # Shenzhen
|
44
44
|
end
|
45
|
+
it 'handles croatian numbers' do
|
46
|
+
Phony.split('385112312345').should == ['385', '1', '123', '12345'] # Zagreb
|
47
|
+
Phony.split('385491231234').should == ['385', '49', '123', '1234'] # Krapina
|
48
|
+
end
|
45
49
|
it 'handles cuban numbers' do
|
46
50
|
Phony.split('5351231234').should == ['53', '5123', '1234'] # Mobile
|
47
51
|
Phony.split('5371234567').should == ['53', '7', '1234567'] # Havana
|
@@ -94,10 +98,17 @@ describe 'country descriptions' do
|
|
94
98
|
Phony.split('3545511234').should == ['354', '551', '1234'] # Reykjavík
|
95
99
|
end
|
96
100
|
it "handles italian numbers" do
|
97
|
-
Phony.split('3934869528').should == ['39', '3486', '952', '8']
|
101
|
+
Phony.split('3934869528').should == ['39', '3486', '952', '8'] # Mobile
|
98
102
|
Phony.split('39068546705').should == ['39', '06', '854', '6705'] # Roma
|
99
103
|
Phony.split('390909709511').should == ['39', '090', '970', '9511'] # Barcellona
|
100
104
|
end
|
105
|
+
it "handles lithuanian numbers" do
|
106
|
+
Phony.split('37070012123').should == ['370', '700', '12', '123'] # Service
|
107
|
+
Phony.split('37061212123').should == ['370', '612', '12', '123'] # Mobile
|
108
|
+
Phony.split('37051231212').should == ['370', '5', '123', '12', '12'] # Vilnius
|
109
|
+
Phony.split('37037121212').should == ['370', '37', '12', '12', '12'] # Kaunas
|
110
|
+
Phony.split('37044011212').should == ['370', '440', '1', '12', '12'] # Skuodas
|
111
|
+
end
|
101
112
|
it 'handles malay numbers' do
|
102
113
|
Phony.split('6082123456').should == ['60', '82', '123456'] # Kuching
|
103
114
|
Phony.split('60312345678').should == ['60', '3', '12345678'] # Kuala Lumpur
|