phony 1.1.4 → 1.1.5
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/lib/phony.rb +2 -0
- data/lib/phony/countries/all_other.rb +16 -13
- data/lib/phony/countries/chile.rb +20 -0
- data/lib/phony/countries/peru.rb +19 -0
- data/spec/lib/phony_spec.rb +20 -7
- metadata +5 -3
data/lib/phony.rb
CHANGED
@@ -21,12 +21,14 @@ require File.expand_path '../phony/country', __FILE__
|
|
21
21
|
#
|
22
22
|
require File.expand_path '../phony/countries/all_other', __FILE__
|
23
23
|
require File.expand_path '../phony/countries/austria', __FILE__
|
24
|
+
require File.expand_path '../phony/countries/chile', __FILE__
|
24
25
|
require File.expand_path '../phony/countries/egypt', __FILE__
|
25
26
|
require File.expand_path '../phony/countries/germany', __FILE__
|
26
27
|
require File.expand_path '../phony/countries/greece', __FILE__
|
27
28
|
require File.expand_path '../phony/countries/hungary', __FILE__
|
28
29
|
require File.expand_path '../phony/countries/italy', __FILE__
|
29
30
|
require File.expand_path '../phony/countries/netherlands', __FILE__
|
31
|
+
require File.expand_path '../phony/countries/peru', __FILE__
|
30
32
|
require File.expand_path '../phony/countries/romania', __FILE__
|
31
33
|
require File.expand_path '../phony/countries/sweden', __FILE__
|
32
34
|
|
@@ -87,26 +87,29 @@ module Phony
|
|
87
87
|
),
|
88
88
|
'49' => Countries::Germany,
|
89
89
|
|
90
|
-
|
91
|
-
#
|
92
|
-
'
|
93
|
-
'
|
94
|
-
'
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
'
|
99
|
-
'
|
90
|
+
'51' => Countries::Peru,
|
91
|
+
'52' => fixed(2), # TODO Mexico
|
92
|
+
'53' => fixed(2), # TODO Cuba
|
93
|
+
'54' => fixed(2), # TODO Argentine Republic
|
94
|
+
'55' => fixed(2, # Brazil (Federative Republic of)
|
95
|
+
:local_format => [4, 4],
|
96
|
+
:service_ndcs => %w{100 128 190 191 192 193 194 197 198 199}
|
97
|
+
), # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
|
98
|
+
'56' => Countries::Chile,
|
99
|
+
'57' => fixed(2), # TODO Colombia (Republic of)
|
100
|
+
'58' => fixed(2), # TODO Venezuela (Bolivarian Republic of)
|
100
101
|
|
101
|
-
'60' => fixed(2), # Malaysia
|
102
|
+
'60' => fixed(2), # TODO Malaysia
|
102
103
|
'61' => fixed(1, # Australia
|
103
104
|
:local_format => [4, 4]
|
104
105
|
),
|
105
|
-
'62' => fixed(2), # Indonesia (Republic of)
|
106
|
-
'63' => fixed(2), # Philippines (Republic of the)
|
106
|
+
'62' => fixed(2), # TODO Indonesia (Republic of)
|
107
|
+
'63' => fixed(2), # TODO Philippines (Republic of the)
|
107
108
|
'64' => fixed(1, # New Zealand
|
108
109
|
:local_format => [3, 4]
|
109
110
|
),
|
111
|
+
# TODO From here on.
|
112
|
+
#
|
110
113
|
'65' => fixed(2), # Singapore (Republic of)
|
111
114
|
'66' => fixed(2), # Thailand
|
112
115
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Chilean phone numbers.
|
2
|
+
#
|
3
|
+
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Chile
|
4
|
+
# http://www.wtng.info/wtng-56-cl.html
|
5
|
+
#
|
6
|
+
# TODO Totally unsure about this one, as I get contradicting infos.
|
7
|
+
# As usual, best effort.
|
8
|
+
#
|
9
|
+
Phony::Countries::Chile = Phony::Country.configured :local_format => [8],
|
10
|
+
:local_special_format => [3, 3],
|
11
|
+
:ndc_fallback_length => 2,
|
12
|
+
:ndc_mapping => {
|
13
|
+
:landline => [
|
14
|
+
'2', # Santiago
|
15
|
+
],
|
16
|
+
:mobile => [
|
17
|
+
'9',
|
18
|
+
],
|
19
|
+
:service => %w{130 131 132 133 134 135 136 137 139 147 149}
|
20
|
+
}
|
@@ -0,0 +1,19 @@
|
|
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
|
+
:local_special_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
|
+
}
|
data/spec/lib/phony_spec.rb
CHANGED
@@ -8,10 +8,18 @@ describe Phony do
|
|
8
8
|
it "should handle austrian numbers" do
|
9
9
|
Phony.split('43198110').should == ['43', '1', '98110']
|
10
10
|
end
|
11
|
+
it 'handles brazilian numbers' do
|
12
|
+
Phony.split('551112341234').should == ['55', '11', '1234', '1234']
|
13
|
+
end
|
14
|
+
it 'handles chilean numbers' do
|
15
|
+
Phony.split('5621234567').should == ['56', '2', '1234567'] # Santiago
|
16
|
+
Phony.split('5675123456').should == ['56', '75', '123456'] # Curico
|
17
|
+
Phony.split('56912345678').should == ['56', '9', '12345678'] # mobile
|
18
|
+
end
|
11
19
|
it 'handles danish numbers' do
|
12
20
|
Phony.split('4532121212').should == ['45', '32', '12', '12', '12']
|
13
21
|
end
|
14
|
-
it
|
22
|
+
it 'handles dutch numbers' do
|
15
23
|
Phony.split('31612345678').should == ['31', '6', '12345678'] # mobile
|
16
24
|
Phony.split('31201234567').should == ['31', '20', '1234567']
|
17
25
|
Phony.split('31222123456').should == ['31', '222', '123456']
|
@@ -36,22 +44,27 @@ describe Phony do
|
|
36
44
|
it "should handle italian numbers" do
|
37
45
|
Phony.split('3928061371').should == ['39', '2', '806', '1371']
|
38
46
|
end
|
47
|
+
it 'handles peruvian numbers' do
|
48
|
+
Phony.split('51112341234').should == ['51', '1', '1234', '1234'] # Lima
|
49
|
+
Phony.split('51912341234').should == ['51', '9', '1234', '1234'] # mobile
|
50
|
+
Phony.split('51841234123').should == ['51', '84', '1234', '123'] # Cuzco, best effort
|
51
|
+
end
|
39
52
|
it "should handle polish numbers" do
|
40
53
|
Phony.split('48121123123').should == ['48', '12', '1', '123', '123']
|
41
54
|
end
|
42
55
|
it 'handles romanian numbers' do
|
43
|
-
Phony.split('40211231234').should == ['40', '21', '123', '1234']
|
44
|
-
Phony.split('40721231234').should == ['40', '72', '123', '1234']
|
45
|
-
Phony.split('40249123123').should == ['40', '249', '123', '123']
|
56
|
+
Phony.split('40211231234').should == ['40', '21', '123', '1234'] # Bucureşti
|
57
|
+
Phony.split('40721231234').should == ['40', '72', '123', '1234'] # mobile
|
58
|
+
Phony.split('40249123123').should == ['40', '249', '123', '123'] # Olt
|
59
|
+
end
|
60
|
+
it 'handles russian numbers' do
|
61
|
+
Phony.split('78122345678').should == ['7', '812', '234', '56', '78']
|
46
62
|
end
|
47
63
|
it "should handle swedish numbers" do
|
48
64
|
Phony.split('46812345678').should == ['46', '8', '12345678']
|
49
65
|
Phony.split('46111234567').should == ['46', '11', '1234567']
|
50
66
|
Phony.split('46125123456').should == ['46', '125', '123456']
|
51
67
|
end
|
52
|
-
it 'handles russian numbers' do
|
53
|
-
Phony.split('78122345678').should == ['7', '812', '234', '56', '78']
|
54
|
-
end
|
55
68
|
it "should handle swiss numbers" do
|
56
69
|
Phony.split('41443643532').should == ['41', '44', '364', '35', '32']
|
57
70
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 5
|
9
|
+
version: 1.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Florian Hanke
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-01 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -29,12 +29,14 @@ extra_rdoc_files:
|
|
29
29
|
files:
|
30
30
|
- lib/phony/countries/all_other.rb
|
31
31
|
- lib/phony/countries/austria.rb
|
32
|
+
- lib/phony/countries/chile.rb
|
32
33
|
- lib/phony/countries/egypt.rb
|
33
34
|
- lib/phony/countries/germany.rb
|
34
35
|
- lib/phony/countries/greece.rb
|
35
36
|
- lib/phony/countries/hungary.rb
|
36
37
|
- lib/phony/countries/italy.rb
|
37
38
|
- lib/phony/countries/netherlands.rb
|
39
|
+
- lib/phony/countries/peru.rb
|
38
40
|
- lib/phony/countries/romania.rb
|
39
41
|
- lib/phony/countries/sweden.rb
|
40
42
|
- lib/phony/country.rb
|