phony 1.2.11 → 1.3.0
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.textile +1 -1
- data/lib/countries.rb +385 -0
- data/lib/phony.rb +11 -9
- data/lib/phony/countries.rb +1 -0
- data/lib/phony/countries/austria.rb +68 -67
- data/lib/phony/countries/belgium.rb +29 -57
- data/lib/phony/countries/chile.rb +5 -12
- data/lib/phony/countries/china.rb +21 -20
- data/lib/phony/countries/egypt.rb +12 -37
- data/lib/phony/countries/germany.rb +39 -36
- data/lib/phony/countries/greece.rb +21 -25
- data/lib/phony/countries/hungary.rb +6 -19
- data/lib/phony/countries/italy.rb +174 -152
- data/lib/phony/countries/malaysia.rb +17 -17
- data/lib/phony/countries/netherlands.rb +50 -52
- data/lib/phony/countries/romania.rb +28 -27
- data/lib/phony/countries/south_korea.rb +11 -11
- data/lib/phony/countries/sweden.rb +49 -49
- data/lib/phony/countries/united_kingdom.rb +4 -4
- data/lib/phony/country.rb +14 -80
- data/lib/phony/country_codes.rb +23 -3
- data/lib/phony/dsl.rb +78 -0
- data/lib/phony/national_code.rb +2 -5
- data/lib/phony/national_splitters/dsl.rb +20 -0
- data/lib/phony/national_splitters/fixed.rb +1 -1
- data/lib/phony/national_splitters/none.rb +1 -1
- data/lib/phony/national_splitters/regex.rb +49 -0
- data/lib/phony/national_splitters/variable.rb +6 -6
- data/lib/phony/vanity.rb +3 -0
- data/spec/lib/phony/country_codes_spec.rb +1 -1
- data/spec/lib/phony/country_spec.rb +12 -45
- data/spec/lib/phony/local_splitters/fixed_spec.rb +8 -0
- data/spec/lib/phony/national_code_spec.rb +13 -0
- data/spec/lib/phony/national_splitters/regex_spec.rb +23 -0
- data/spec/lib/phony/national_splitters/variable_spec.rb +2 -4
- data/spec/lib/phony_spec.rb +44 -4
- metadata +9 -21
- data/lib/phony/countries/all_other.rb +0 -455
- data/lib/phony/countries/norway.rb +0 -11
- data/lib/phony/countries/peru.rb +0 -19
- data/lib/phony/countries/portugal.rb +0 -16
- data/lib/phony/national_splitters/experimental.rb +0 -17
- data/spec/lib/phony/countries/austria_spec.rb +0 -24
- data/spec/lib/phony/countries/belgium_spec.rb +0 -33
- data/spec/lib/phony/countries/egypt_spec.rb +0 -18
- data/spec/lib/phony/countries/greece_spec.rb +0 -18
- data/spec/lib/phony/countries/portugal_spec.rb +0 -21
- data/spec/lib/phony/countries/switzerland_spec.rb +0 -18
- data/spec/lib/phony/countries/united_kingdom_spec.rb +0 -50
@@ -1,11 +0,0 @@
|
|
1
|
-
# Norway. Complete plan available here:
|
2
|
-
# http://www.npt.no/pt_internet/e_164/nummerplaner.html
|
3
|
-
#
|
4
|
-
# (5-digit special numbers and 01 is missing)
|
5
|
-
#
|
6
|
-
handler = Phony::NationalCode.new(
|
7
|
-
Phony::NationalSplitters::None.instance_for,
|
8
|
-
Phony::LocalSplitters::Regex.instance_for(/^[1].*$/ => [3], /^[489].*$/ => [3,2,3], :fallback => [2,2,2,2])
|
9
|
-
)
|
10
|
-
|
11
|
-
Phony::Countries::Norway = Phony::Country.new handler
|
data/lib/phony/countries/peru.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Peruvian phone numbers.
|
2
|
-
#
|
3
|
-
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Peru
|
4
|
-
#
|
5
|
-
Phony::Countries::Peru = Phony::Country.configured :local_format => [4, 4],
|
6
|
-
:service_local_format => [3, 3],
|
7
|
-
:ndc_fallback_length => 2,
|
8
|
-
:ndc_mapping => {
|
9
|
-
:landline => [
|
10
|
-
'1', # Lima
|
11
|
-
],
|
12
|
-
:mobile => [
|
13
|
-
'9',
|
14
|
-
],
|
15
|
-
:service => [
|
16
|
-
'103',
|
17
|
-
'105',
|
18
|
-
]
|
19
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# Portuguese phone numbers.
|
2
|
-
#
|
3
|
-
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Portugal
|
4
|
-
#
|
5
|
-
Phony::Countries::Portugal = Phony::Country.configured :local_format => [3, 4],
|
6
|
-
:local_special_format => [3, 3],
|
7
|
-
:local_mobile_format => [3, 3],
|
8
|
-
:ndc_fallback_length => 3,
|
9
|
-
:ndc_mapping => {
|
10
|
-
:landline => [
|
11
|
-
'21', # Lisboa
|
12
|
-
'22', # Porto
|
13
|
-
],
|
14
|
-
:mobile => ('90'..'99').to_a,
|
15
|
-
:service => %w{700 800} # Not exhaustive.
|
16
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::Countries::Austria do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@austria = Phony::Countries::Austria
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "split" do
|
10
|
-
it "should handle Vienna" do
|
11
|
-
@austria.split('198110').should == ['1', '98110']
|
12
|
-
end
|
13
|
-
it "should handle some mobile services" do
|
14
|
-
@austria.split('66914093902').should == ['669', '14093902']
|
15
|
-
end
|
16
|
-
it "should handle Graz" do
|
17
|
-
@austria.split('3161234567891').should == ['316', '1234567891']
|
18
|
-
end
|
19
|
-
it "should handle Rohrau" do
|
20
|
-
@austria.split('2164123456789').should == ['2164', '123456789']
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe Phony::Countries::Belgium do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
@belgium = Phony::Countries::Belgium
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "split" do
|
13
|
-
it "should handle Antwerpen" do
|
14
|
-
@belgium.split('35551212').should == ['3', '555', '1212']
|
15
|
-
end
|
16
|
-
it "should handle Brugge" do
|
17
|
-
@belgium.split('505551212').should == ['50', '555', '1212']
|
18
|
-
end
|
19
|
-
it "should handle Brussels" do
|
20
|
-
@belgium.split('25551212').should == ['2', '555', '1212']
|
21
|
-
end
|
22
|
-
it "should handle Gent" do
|
23
|
-
@belgium.split('95551914').should == ['9', '555', '1914']
|
24
|
-
end
|
25
|
-
it "should handle Liège" do
|
26
|
-
@belgium.split('45551414').should == ['4', '555', '1414']
|
27
|
-
end
|
28
|
-
it "should handle some mobile services" do
|
29
|
-
@belgium.split('475279584').should == ['475', '279584']
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::Countries::Egypt do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@egypt = Phony::Countries::Egypt
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "split" do
|
10
|
-
it "works" do
|
11
|
-
@egypt.split('233453756').should == ['2', '33453756']
|
12
|
-
end
|
13
|
-
it "works" do
|
14
|
-
@egypt.split('921234567').should == ['92', '1234567']
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::Countries::Greece do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@greece = Phony::Countries::Greece
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "split" do
|
10
|
-
it 'works' do
|
11
|
-
@greece.split('21123456').should == ['21', '123456']
|
12
|
-
end
|
13
|
-
it 'works' do
|
14
|
-
@greece.split('25941234').should == ['2594', '1234']
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::Countries::Portugal do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@portugal = Phony::Countries::Portugal
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "split" do
|
10
|
-
it "works with Lisboa" do
|
11
|
-
@portugal.split('211231234').should == ['21', '123', '1234']
|
12
|
-
end
|
13
|
-
it "works with Abrantes" do
|
14
|
-
@portugal.split('241123123').should == ['241', '123', '123']
|
15
|
-
end
|
16
|
-
it 'works with a mobile' do
|
17
|
-
@portugal.split('931231234').should == ['93', '123', '1234']
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Switzerland' do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@switzerland = Phony::Countries.with_cc '41'
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "split" do
|
10
|
-
it "works" do
|
11
|
-
@switzerland.split('443643532').should == ['44', '364', '35', '32']
|
12
|
-
end
|
13
|
-
it "works" do
|
14
|
-
@switzerland.split('800123456').should == ['800', '123', '456']
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::Countries::UnitedKingdom do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@uk = Phony::Countries::UnitedKingdom
|
7
|
-
end
|
8
|
-
|
9
|
-
# Note: Many Specs
|
10
|
-
#
|
11
|
-
describe "split" do
|
12
|
-
it "should handle London" do
|
13
|
-
@uk.split('2045671113').should == ['20', '4567', '1113']
|
14
|
-
end
|
15
|
-
it "should handle Cardiff" do
|
16
|
-
@uk.split('2076229901').should == ['20', '7622', '9901']
|
17
|
-
end
|
18
|
-
it "should handle Leeds" do
|
19
|
-
@uk.split('1136770011').should == ['113', '677', '0011']
|
20
|
-
end
|
21
|
-
it "should handle Dundee" do
|
22
|
-
@uk.split('1382229845').should == ['1382', '229845']
|
23
|
-
end
|
24
|
-
it "should handle Bolten" do
|
25
|
-
@uk.split('120499532').should == ['1204', '99532']
|
26
|
-
end
|
27
|
-
it "should handle Sedbergh" do
|
28
|
-
@uk.split('1539618756').should ==['15396', '18756']
|
29
|
-
end
|
30
|
-
it "should handle Mobile Numbers" do
|
31
|
-
@uk.split('7780605207').should == ['7780', '605207']
|
32
|
-
end
|
33
|
-
it "should handle Mobile Numbers" do
|
34
|
-
@uk.split('7480605207').should == ['7480', '605207']
|
35
|
-
end
|
36
|
-
it "should handle service numbers with 800 [regression]" do
|
37
|
-
@uk.split('8005878323').should == ['800', '587', '8323']
|
38
|
-
end
|
39
|
-
#
|
40
|
-
# 44 116 xxx xxxx Leicester
|
41
|
-
# 44 131 xxx xxxx Edinburgh
|
42
|
-
# 44 151 xxx xxxx Liverpool
|
43
|
-
# 44 1382 xxxxxx Dundee
|
44
|
-
# 44 1386 xxxxxx Evesham
|
45
|
-
# 44 1865 xxxxxx Oxford
|
46
|
-
# 44 153 96 xxxxx Sedbergh
|
47
|
-
# 44 169 77 xxxx Brampton
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|