phony 1.2.11 → 1.3.0
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 +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,69 +1,70 @@
|
|
1
|
+
include Phony::DSL
|
2
|
+
|
1
3
|
# Austria uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
|
2
4
|
#
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
5
|
+
ndcs = [
|
6
|
+
'1', # Vienna
|
7
|
+
'57', # -
|
8
|
+
'59', # -
|
9
|
+
'89', # Routing Number
|
10
|
+
'316', # Graz
|
11
|
+
'501', # -
|
12
|
+
'502', # -
|
13
|
+
'503', # -
|
14
|
+
'504', # -
|
15
|
+
'505', # -
|
16
|
+
'506', # -
|
17
|
+
'507', # -
|
18
|
+
'508', # -
|
19
|
+
'509', # -
|
20
|
+
'512', # Innsbruck
|
21
|
+
'517', # -
|
22
|
+
'662', # Salzburg
|
23
|
+
'720', #
|
24
|
+
'732' # Linz
|
25
|
+
]
|
26
|
+
|
27
|
+
mobile = [
|
28
|
+
'67',
|
29
|
+
'68',
|
30
|
+
'644',
|
31
|
+
'650',
|
32
|
+
'651',
|
33
|
+
'652',
|
34
|
+
'653',
|
35
|
+
'655',
|
36
|
+
'657',
|
37
|
+
'659',
|
38
|
+
'660',
|
39
|
+
'661',
|
40
|
+
'663',
|
41
|
+
'664',
|
42
|
+
'665',
|
43
|
+
'666',
|
44
|
+
'667',
|
45
|
+
'668',
|
46
|
+
'669'
|
47
|
+
]
|
48
|
+
|
49
|
+
service = [
|
50
|
+
'710',
|
51
|
+
'711',
|
52
|
+
'718',
|
53
|
+
'730',
|
54
|
+
'740',
|
55
|
+
'780',
|
56
|
+
'800',
|
57
|
+
'802',
|
58
|
+
'804',
|
59
|
+
'810',
|
60
|
+
'820',
|
61
|
+
'821',
|
62
|
+
'828',
|
63
|
+
'900',
|
64
|
+
'901',
|
65
|
+
'930',
|
66
|
+
'931',
|
67
|
+
'939'
|
68
|
+
]
|
69
|
+
|
70
|
+
Phony::Countries::Austria = one_of(service + mobile + ndcs, :max_length => 4) >> split(10)
|
@@ -1,61 +1,33 @@
|
|
1
|
+
include Phony::DSL
|
2
|
+
|
1
3
|
# Belgium uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
|
2
4
|
#
|
3
5
|
# Taken from: http://en.wikipedia.org/wiki/Telephone_numbers_in_Belgium
|
4
6
|
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
'486', # Base
|
33
|
-
'487', # Base
|
34
|
-
'488', # Base
|
35
|
-
'489', # Base
|
36
|
-
'490', # Proximus
|
37
|
-
'491', # Proximus
|
38
|
-
'492', # Proximus
|
39
|
-
'493', # Proximus
|
40
|
-
'494', # Proximus
|
41
|
-
'495', # Proximus
|
42
|
-
'496', # Proximus
|
43
|
-
'497', # Proximus
|
44
|
-
'498', # Proximus
|
45
|
-
'499', # Proximus
|
46
|
-
],
|
47
|
-
:service => [
|
48
|
-
'70', # Specialty numbers, i.e. bus information or bank information
|
49
|
-
'800', # Tollfree
|
50
|
-
'900', # Premium
|
51
|
-
'901', # Premium
|
52
|
-
'902', # Premium
|
53
|
-
'903', # Premium
|
54
|
-
'904', # Premium
|
55
|
-
'905', # Premium
|
56
|
-
'906', # Premium
|
57
|
-
'907', # Premium
|
58
|
-
'908', # Premium
|
59
|
-
'909' # Premium
|
60
|
-
]
|
61
|
-
}
|
7
|
+
ndcs = [
|
8
|
+
'2', # Brussels (Bruxelles/Brussel)
|
9
|
+
'3', # Antwerpen (Antwerp), Sint-Niklaas
|
10
|
+
'4', # Liège (Luik), Voeren (Fourons)
|
11
|
+
'9', # Gent (Ghent/Gand)
|
12
|
+
]
|
13
|
+
|
14
|
+
mobile_regex = /^(4[789]\d)\d{6}$/ # Mobistar, Base, Proximus
|
15
|
+
|
16
|
+
service = [
|
17
|
+
'70', # Specialty numbers, i.e. bus information or bank information
|
18
|
+
'800', # Tollfree
|
19
|
+
'900', # Premium
|
20
|
+
'901', # Premium
|
21
|
+
'902', # Premium
|
22
|
+
'903', # Premium
|
23
|
+
'904', # Premium
|
24
|
+
'905', # Premium
|
25
|
+
'906', # Premium
|
26
|
+
'907', # Premium
|
27
|
+
'908', # Premium
|
28
|
+
'909' # Premium
|
29
|
+
]
|
30
|
+
|
31
|
+
Phony::Countries::Belgium = one_of(service) >> split(3,3) |
|
32
|
+
match(mobile_regex) >> split(6) |
|
33
|
+
one_of(ndcs, :max_length => 2) >> split(3,5)
|
@@ -6,15 +6,8 @@
|
|
6
6
|
# Note: Totally unsure about this one, as I get contradicting infos (see links above).
|
7
7
|
# As usual, best effort.
|
8
8
|
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
'2', # Santiago
|
15
|
-
],
|
16
|
-
:mobile => [
|
17
|
-
'9',
|
18
|
-
],
|
19
|
-
:service => %w{130 131 132 133 134 135 136 137 139 147 149}
|
20
|
-
}
|
9
|
+
service = %w{130 131 132 133 134 135 136 137 139 147 149}
|
10
|
+
|
11
|
+
Phony::Countries::Chile = one_of(*service) >> split(3,3) |
|
12
|
+
|
13
|
+
one_of('2', '9', :max_length => 2) >> split(8) # Santiago (2) and mobile.
|
@@ -1,26 +1,27 @@
|
|
1
|
+
include Phony::DSL
|
2
|
+
|
1
3
|
# Chinese phone numbers.
|
2
4
|
#
|
3
5
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_China
|
4
6
|
#
|
5
7
|
# Note: Tibet partially uses 4-digit NDC codes. This is NOT YET reflected here.
|
6
8
|
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
9
|
+
ndcs = [
|
10
|
+
'10', # Beijing, TODO Confirm – is it 10 or 1?
|
11
|
+
'20', # Guangzhou
|
12
|
+
'21', # Shanghai
|
13
|
+
'22', # Tianjin
|
14
|
+
'23', # Chongquin
|
15
|
+
'24', # Shenyang
|
16
|
+
'25', # Nanjing
|
17
|
+
'26', # Taipei, Taiwan - gotta be kidding, right?!
|
18
|
+
'27', # Wuhan
|
19
|
+
'28', # Chengdu
|
20
|
+
'29', # Xi'an
|
21
|
+
]
|
22
|
+
mobile = %w{ 130 131 132 133 135 136 137 138 139 145 150 151 152 153 155 156 157 158 159 185 186 187 188 189 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 }
|
23
|
+
service = %w{ 110 114 119 120 122 999 } # Probably not exhaustive. TODO Look at http://www.eoc.com.cn/?action-viewnews-itemid-11493.
|
24
|
+
|
25
|
+
Phony::Countries::China = one_of(service) >> split(8) |
|
26
|
+
one_of(mobile) >> split(4,4) |
|
27
|
+
one_of(ndcs, :max_length => 3) >> split(4,4)
|
@@ -1,42 +1,17 @@
|
|
1
|
+
include Phony::DSL
|
2
|
+
|
3
|
+
# TODO Move this into the country definitions.
|
4
|
+
|
1
5
|
# Egyptian phone numbers.
|
2
6
|
#
|
3
7
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Egypt
|
4
8
|
#
|
5
|
-
|
9
|
+
ndcs = [
|
10
|
+
'2', # Cairo/Giza
|
11
|
+
'3', # Alexandria
|
12
|
+
]
|
13
|
+
|
14
|
+
# TODO Change how one_of works. max_length should be optional.
|
6
15
|
#
|
7
|
-
Phony::Countries::Egypt =
|
8
|
-
|
9
|
-
:ndc_fallback_length => 2,
|
10
|
-
:ndc_mapping => {
|
11
|
-
:landline => [
|
12
|
-
'2', # Cairo/Giza
|
13
|
-
'3', # Alexandria
|
14
|
-
'13', # Banha
|
15
|
-
'15', # 10th of Ramadan
|
16
|
-
'45', # Damanhur
|
17
|
-
'46', # Marsa Matruh
|
18
|
-
'47', # Kafer El Sheik
|
19
|
-
'48', # Monufia
|
20
|
-
'50', # Mansoura
|
21
|
-
'55', # Zazazig
|
22
|
-
'56', # Spare
|
23
|
-
'57', # Damiette
|
24
|
-
'62', # Suez
|
25
|
-
'64', # Ismailia
|
26
|
-
'65', # Red Sea
|
27
|
-
'66', # Port Said
|
28
|
-
'68', # El Arish
|
29
|
-
'69', # El-Tor
|
30
|
-
'82', # Beni Suef
|
31
|
-
'84', # Fayoum
|
32
|
-
'86', # Minia
|
33
|
-
'88', # Assiout
|
34
|
-
'92', # Wadi El Gehid
|
35
|
-
'93', # Sohag
|
36
|
-
'95', # Luxor
|
37
|
-
'96', # Qunea
|
38
|
-
'97', # Aswan
|
39
|
-
],
|
40
|
-
:mobile => %w{10 11 12 14 16 17 18 19},
|
41
|
-
:service => %w{800} # Not exhaustive.
|
42
|
-
}
|
16
|
+
Phony::Countries::Egypt = one_of('800') >> split(7) |
|
17
|
+
one_of(ndcs, :max_length => 2) >> split(8)
|
@@ -1,12 +1,12 @@
|
|
1
|
+
include Phony::DSL
|
2
|
+
|
1
3
|
# Germany uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
|
2
4
|
#
|
3
5
|
# Note: Germany uses a variable ndc format from length 2 to 5.
|
4
6
|
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
:ndc_mapping => {
|
9
|
-
:landline => ['10', # Call-By-Call
|
7
|
+
|
8
|
+
ndcs = [
|
9
|
+
'10', # Call-By-Call
|
10
10
|
'11', # formerly Value Added Services
|
11
11
|
'13', # Voting and Lottery Numbers
|
12
12
|
'30', # Berlin
|
@@ -3990,36 +3990,36 @@ Phony::Countries::Germany = Phony::Country.configured :local_format => [3, 10],
|
|
3990
3990
|
'9976',
|
3991
3991
|
'9977',
|
3992
3992
|
'9978',
|
3993
|
-
]
|
3994
|
-
|
3995
|
-
'150', # Group3G/Quam
|
3996
|
-
'151', # T-Mobile
|
3997
|
-
'152', # Vodafone
|
3998
|
-
'155', # E-Plus
|
3999
|
-
'156', # Mobilcom
|
4000
|
-
'157', # E-Plus
|
4001
|
-
'159', # O2
|
4002
|
-
'160', # T-Mobile
|
4003
|
-
'161', # C-Netz
|
4004
|
-
'162', # Vodafone
|
4005
|
-
'163', # E-Plus
|
4006
|
-
'164', # Cityruf
|
4007
|
-
'165', # Quix
|
4008
|
-
'166', # Telmi
|
4009
|
-
'168', # Scall
|
4010
|
-
'169', # Cityruf, Scall, Skyper (e*cityruf, e*message, e*skyper)
|
4011
|
-
'170', # T-Mobile
|
4012
|
-
'171', # T-Mobile
|
4013
|
-
'172', # Vodafone
|
4014
|
-
'173', # Vodafone
|
4015
|
-
'174', # Vodafone
|
4016
|
-
'175', # T-Mobile
|
4017
|
-
'176', # O2 Germany
|
4018
|
-
'177', # E-Plus
|
4019
|
-
'178', # E-Plus
|
4020
|
-
'179', # O2 Germany
|
4021
|
-
]
|
4022
|
-
|
3993
|
+
]
|
3994
|
+
# mobile = [
|
3995
|
+
# '150', # Group3G/Quam
|
3996
|
+
# '151', # T-Mobile
|
3997
|
+
# '152', # Vodafone
|
3998
|
+
# '155', # E-Plus
|
3999
|
+
# '156', # Mobilcom
|
4000
|
+
# '157', # E-Plus
|
4001
|
+
# '159', # O2
|
4002
|
+
# '160', # T-Mobile
|
4003
|
+
# '161', # C-Netz
|
4004
|
+
# '162', # Vodafone
|
4005
|
+
# '163', # E-Plus
|
4006
|
+
# '164', # Cityruf
|
4007
|
+
# '165', # Quix
|
4008
|
+
# '166', # Telmi
|
4009
|
+
# '168', # Scall
|
4010
|
+
# '169', # Cityruf, Scall, Skyper (e*cityruf, e*message, e*skyper)
|
4011
|
+
# '170', # T-Mobile
|
4012
|
+
# '171', # T-Mobile
|
4013
|
+
# '172', # Vodafone
|
4014
|
+
# '173', # Vodafone
|
4015
|
+
# '174', # Vodafone
|
4016
|
+
# '175', # T-Mobile
|
4017
|
+
# '176', # O2 Germany
|
4018
|
+
# '177', # E-Plus
|
4019
|
+
# '178', # E-Plus
|
4020
|
+
# '179', # O2 Germany
|
4021
|
+
# ]
|
4022
|
+
service = [
|
4023
4023
|
'12', # Innovative Services
|
4024
4024
|
'130',
|
4025
4025
|
'180', #
|
@@ -4066,4 +4066,7 @@ Phony::Countries::Germany = Phony::Country.configured :local_format => [3, 10],
|
|
4066
4066
|
'9005',
|
4067
4067
|
'9009',
|
4068
4068
|
]
|
4069
|
-
|
4069
|
+
|
4070
|
+
Phony::Countries::Germany = one_of(service) >> split(3,10) |
|
4071
|
+
match(/^(1[567]\d)\d*$/) >> split(3,10) | # Mobile
|
4072
|
+
one_of(ndcs, :max_length => 5) >> split(3,10)
|