phony 2.15.0 → 2.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.textile +35 -7
- data/lib/phony/config.rb +91 -0
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +34 -24
- data/lib/phony/countries/bangladesh.rb +2 -0
- data/lib/phony/countries/belarus.rb +2 -0
- data/lib/phony/countries/brazil.rb +6 -4
- data/lib/phony/countries/cambodia.rb +6 -4
- data/lib/phony/countries/china.rb +7 -2
- data/lib/phony/countries/croatia.rb +13 -16
- data/lib/phony/countries/georgia.rb +6 -4
- data/lib/phony/countries/germany.rb +5 -2
- data/lib/phony/countries/guinea.rb +8 -5
- data/lib/phony/countries/india.rb +2 -0
- data/lib/phony/countries/indonesia.rb +8 -3
- data/lib/phony/countries/ireland.rb +27 -23
- data/lib/phony/countries/italy.rb +30 -17
- data/lib/phony/countries/japan.rb +61 -8
- data/lib/phony/countries/kyrgyzstan.rb +2 -0
- data/lib/phony/countries/latvia.rb +2 -0
- data/lib/phony/countries/libya.rb +3 -1
- data/lib/phony/countries/malaysia.rb +22 -2
- data/lib/phony/countries/moldova.rb +2 -0
- data/lib/phony/countries/montenegro.rb +2 -0
- data/lib/phony/countries/myanmar.rb +2 -0
- data/lib/phony/countries/namibia.rb +2 -0
- data/lib/phony/countries/nepal.rb +2 -0
- data/lib/phony/countries/netherlands.rb +5 -1
- data/lib/phony/countries/pakistan.rb +2 -0
- data/lib/phony/countries/paraguay.rb +2 -0
- data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +24 -14
- data/lib/phony/countries/saudi_arabia.rb +40 -0
- data/lib/phony/countries/serbia.rb +10 -4
- data/lib/phony/countries/somalia.rb +5 -1
- data/lib/phony/countries/south_korea.rb +16 -9
- data/lib/phony/countries/sweden.rb +53 -38
- data/lib/phony/countries/taiwan.rb +22 -46
- data/lib/phony/countries/tajikistan.rb +2 -0
- data/lib/phony/countries/turkmenistan.rb +2 -0
- data/lib/phony/countries/ukraine.rb +5 -2
- data/lib/phony/countries/united_kingdom.rb +5 -2
- data/lib/phony/countries/uruguay.rb +2 -0
- data/lib/phony/countries/vietnam.rb +94 -92
- data/lib/phony/countries/zimbabwe.rb +2 -0
- data/lib/phony/countries.rb +210 -98
- data/lib/phony/country.rb +15 -3
- data/lib/phony/country_codes.rb +17 -4
- data/lib/phony/dsl.rb +5 -3
- data/lib/phony/local_splitters/fixed.rb +2 -0
- data/lib/phony/national_code.rb +1 -1
- data/lib/phony/national_splitters/none.rb +1 -3
- data/lib/phony/trunk_code.rb +5 -4
- data/lib/phony/vanity.rb +1 -1
- data/lib/phony.rb +94 -59
- data/spec/functional/config_spec.rb +44 -0
- data/spec/functional/plausibility_spec.rb +373 -35
- data/spec/lib/phony/countries_spec.rb +295 -63
- data/spec/lib/phony/country_codes_spec.rb +106 -33
- data/spec/lib/phony/country_spec.rb +54 -15
- data/spec/lib/phony/dsl_spec.rb +2 -2
- data/spec/lib/phony/local_splitters/regex_spec.rb +12 -5
- data/spec/lib/phony/national_splitters/default_spec.rb +1 -1
- data/spec/lib/phony/trunk_code_spec.rb +85 -0
- data/spec/lib/phony/vanity_spec.rb +30 -0
- data/spec/lib/phony_spec.rb +70 -0
- metadata +27 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f2e0337c11693c028c028c978936d9753067bab16cceb1deba77f39e535fbb50
|
4
|
+
data.tar.gz: 45468532f0d66381ce8b52f8c500881ee6a34f134450f6ffac5b57193c1d4323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c2ad0d4272a0eaf808bc95f8ace53b1d3c5f7fe2718bd555547b5611915eee4a5f34ea968ef7ebe8fb7b4b8cb86b9040b8af48a8181a7d287a9a39d9906f312
|
7
|
+
data.tar.gz: 0a2e811f7f43f4e357fbe384381565a884073d98e6f1376664df1f457cf210dc759bf50c140749e7447cb034cc40e9d2916a77d3c7555df7f922fa5f522652f0
|
data/README.textile
CHANGED
@@ -5,29 +5,29 @@
|
|
5
5
|
|
6
6
|
h1. Phony
|
7
7
|
|
8
|
-
Disclaimer: Phony works with international numbers only, such as
|
8
|
+
Disclaimer: Phony works with international numbers only, such as @61 412 345 678@!
|
9
9
|
|
10
10
|
The (admittedly crazy) goal of this Gem is to be able to normalize/format/split all phone numbers in the world.
|
11
11
|
|
12
12
|
Used in: "airbnb.com":http://airbnb.com, "socialcam.com":http://socialcam.com, "zendesk.com":http://www.zendesk.com/ (and many, many others).
|
13
13
|
|
14
|
-
h2. Runtime Memory Usage
|
14
|
+
h2(#memory). Runtime Memory Usage
|
15
15
|
|
16
|
-
According to "memory_profiler":https://github.com/SamSaffron/memory_profiler, the Phony gem uses roughly
|
17
|
-
Usage was generated using: @ruby -e 'require "memory_profiler"; MemoryProfiler.report(allow_files: "phony"){ require "phony" }.pretty_print'@
|
16
|
+
According to "memory_profiler":https://github.com/SamSaffron/memory_profiler, the Phony gem uses roughly 1MB of memory per Ruby process.
|
17
|
+
Usage was generated using (look for @Total retained@): @ruby -e 'require "memory_profiler"; MemoryProfiler.report(allow_files: "phony"){ require "phony" }.pretty_print'@
|
18
18
|
|
19
19
|
h2. Description
|
20
20
|
|
21
21
|
This gem normalizes, formats and splits "*E164 phone numbers*":http://en.wikipedia.org/wiki/E.164. A valid E164 phone number *must* include a country code.
|
22
22
|
|
23
|
-
E164 numbers are international numbers with a country dial prefix, usually an area code and a subscriber number. For example, the
|
23
|
+
E164 numbers are international numbers with a country dial prefix, usually an area code and a subscriber number. For example, the Australian number @+61 412 345 678@ can be broken down into the following components:
|
24
24
|
* Country Code (CC): a country code of @61@
|
25
25
|
* National Destination Code (NDC): a mobile number denoted by the @4@ (specific to Australia)
|
26
26
|
* Local Number Part: a subscriber number of @12 345 678@
|
27
27
|
|
28
28
|
It currently handles the countries listed at the end of this README.
|
29
29
|
|
30
|
-
It is covered by roughly
|
30
|
+
It is covered by roughly 2,250 tests that run in 2 seconds (April 2019).
|
31
31
|
If it doesn't work, please "enter an issue":http://github.com/floere/phony/issues or better, fork and "send a pull request":http://github.com/floere/phony/pulls.
|
32
32
|
|
33
33
|
h2. Installation
|
@@ -78,9 +78,37 @@ NB If a country does not have an NDC, @#split@ will return @false@ in the NDC po
|
|
78
78
|
|
79
79
|
@Phony.split('4512121212').assert == ['45', false, '12', '12', '12', '12']@
|
80
80
|
|
81
|
+
h3(#loading). Loading only a country subset (Phony 2.18.0+).
|
82
|
+
|
83
|
+
Use this in case you'd like to save "memory":#memory that is used by Phony's CC rules.
|
84
|
+
|
85
|
+
"Phony::Config.load docs":./qed/config.md
|
86
|
+
|
87
|
+
First, @require 'phony/config'@.
|
88
|
+
Then, one of the following, which will load the rest of Phony.
|
89
|
+
|
90
|
+
Load only these CCs:
|
91
|
+
@Phony::Config.load(only: ['41', '44'])@
|
92
|
+
|
93
|
+
Loads everything except these CCs:
|
94
|
+
@Phony::Config.load(except: ['41', '44'])@
|
95
|
+
|
96
|
+
Convenience form of @only@:
|
97
|
+
@Phony::Config.load('41', '44')@
|
98
|
+
|
99
|
+
Each of these loads the rest of Phony.
|
100
|
+
|
101
|
+
Memory usage can be checked using (look for @Total retained@):
|
102
|
+
@ruby -e 'require "memory_profiler"; MemoryProfiler.report(allow_files: "phony"){ require "phony/config"; Phony::Config.load("1") }.pretty_print'@
|
103
|
+
For example, when just loading the NANP CC, the retained memory usage is ~63kB.
|
104
|
+
|
81
105
|
h2. List of Handled Countries
|
82
106
|
|
83
|
-
Mildly unmaintained list: Abhas, Afghan, Algerian,
|
107
|
+
Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
|
108
|
+
|
109
|
+
h2. Proud Sponsors
|
110
|
+
|
111
|
+
* Renuo AG (July 22 –): "Github":https://github.com/renuo, "Homepage":https://www.renuo.ch
|
84
112
|
|
85
113
|
h2. License
|
86
114
|
|
data/lib/phony/config.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phony
|
4
|
+
|
5
|
+
# Add config.
|
6
|
+
class << self
|
7
|
+
attr_writer :config
|
8
|
+
|
9
|
+
def config
|
10
|
+
# Default config includes all CCs.
|
11
|
+
@config ||= Config.new([], [])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# The Config class is only used to configure Phony and to load specific
|
16
|
+
# subsets of CCs.
|
17
|
+
#
|
18
|
+
class Config
|
19
|
+
|
20
|
+
attr_reader :included_ccs, :excluded_ccs
|
21
|
+
|
22
|
+
def initialize included_ccs, excluded_ccs
|
23
|
+
@included_ccs = included_ccs || []
|
24
|
+
@excluded_ccs = excluded_ccs || []
|
25
|
+
end
|
26
|
+
|
27
|
+
def load? cc
|
28
|
+
return false if has_excluded? && excluded_ccs.include?(cc)
|
29
|
+
|
30
|
+
if has_included?
|
31
|
+
# We have to check the included_ccs, otherwise false.
|
32
|
+
return true if included_ccs.include?(cc)
|
33
|
+
|
34
|
+
false
|
35
|
+
else
|
36
|
+
# It's not in excluded and no included was given.
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
def has_included?
|
41
|
+
!included_ccs.empty?
|
42
|
+
end
|
43
|
+
def has_excluded?
|
44
|
+
!excluded_ccs.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
# Use as follows:
|
48
|
+
#
|
49
|
+
# require 'phony/config'
|
50
|
+
#
|
51
|
+
# # Load only these:
|
52
|
+
# Phony::Config.load(only: ['41', '44'])
|
53
|
+
# # or all except these:
|
54
|
+
# Phony::Config.load(except: ['41', '44'])
|
55
|
+
# # or "only", in short form.
|
56
|
+
# Phony::Config.load('41', '44')
|
57
|
+
# # or even shorter form:
|
58
|
+
# Phony::Config.load(41, 44)
|
59
|
+
#
|
60
|
+
def self.load *options
|
61
|
+
# Extract options.
|
62
|
+
last = options.last
|
63
|
+
only, except = if last.respond_to?(:to_hash)
|
64
|
+
# We have the explicit form.
|
65
|
+
[last[:only], last[:except]]
|
66
|
+
elsif options.respond_to?(:to_ary)
|
67
|
+
# We have the convenience short forms.
|
68
|
+
[options, []]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Set defaults.
|
72
|
+
only, except = [only || [], except || []]
|
73
|
+
# Convert to expected format if possible.
|
74
|
+
only, except = [only.map(&:to_s), except.map(&:to_s)]
|
75
|
+
|
76
|
+
# Check params.
|
77
|
+
raise "Params given to Phony::Config.load must be Array-like. The one given was: #{only}" unless only.respond_to?(:to_ary)
|
78
|
+
raise "Params given to Phony::Config.load must be Array-like. The one given was: #{except}" unless except.respond_to?(:to_ary)
|
79
|
+
|
80
|
+
# Configure Phony.
|
81
|
+
Phony.config = new(only, except)
|
82
|
+
|
83
|
+
# Load phony.
|
84
|
+
Kernel.load File.expand_path('../../phony.rb', __FILE__)
|
85
|
+
|
86
|
+
# Return the stored config data.
|
87
|
+
Phony.config
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,355 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Argentinian numbers are all ten digits long.
|
4
|
+
# Information taken from:
|
5
|
+
# https://www.enacom.gob.ar/multimedia/normativas/1997/Resolucion%2046_97.pdf
|
6
|
+
# http://www.wtng.info/wtng-54-ar.html
|
7
|
+
# https://en.wikipedia.org/wiki/Telephone_numbers_in_Argentina
|
8
|
+
# Area codes collected from https://www.enacom.gob.ar/indicativos-interurbanos_p366 (06/27/19)
|
9
|
+
|
10
|
+
|
11
|
+
# Landline
|
12
|
+
area_codes_2digits = [
|
13
|
+
'11',
|
14
|
+
]
|
15
|
+
|
16
|
+
area_codes_3digits = [
|
17
|
+
'220',
|
18
|
+
'221',
|
19
|
+
'223',
|
20
|
+
'230',
|
21
|
+
'236',
|
22
|
+
'237',
|
23
|
+
'249',
|
24
|
+
'260',
|
25
|
+
'261',
|
26
|
+
'263',
|
27
|
+
'264',
|
28
|
+
'266',
|
29
|
+
'280',
|
30
|
+
'291',
|
31
|
+
'294',
|
32
|
+
'297',
|
33
|
+
'298',
|
34
|
+
'299',
|
35
|
+
'336',
|
36
|
+
'341',
|
37
|
+
'342',
|
38
|
+
'343',
|
39
|
+
'345',
|
40
|
+
'348',
|
41
|
+
'351',
|
42
|
+
'353',
|
43
|
+
'358',
|
44
|
+
'362',
|
45
|
+
'364',
|
46
|
+
'370',
|
47
|
+
'376',
|
48
|
+
'379',
|
49
|
+
'380',
|
50
|
+
'381',
|
51
|
+
'383',
|
52
|
+
'385',
|
53
|
+
'387',
|
54
|
+
'388',
|
55
|
+
]
|
56
|
+
|
57
|
+
area_codes_4digits = [
|
58
|
+
'2202',
|
59
|
+
'2221',
|
60
|
+
'2223',
|
61
|
+
'2224',
|
62
|
+
'2225',
|
63
|
+
'2226',
|
64
|
+
'2227',
|
65
|
+
'2229',
|
66
|
+
'2241',
|
67
|
+
'2242',
|
68
|
+
'2243',
|
69
|
+
'2244',
|
70
|
+
'2245',
|
71
|
+
'2246',
|
72
|
+
'2252',
|
73
|
+
'2254',
|
74
|
+
'2255',
|
75
|
+
'2257',
|
76
|
+
'2261',
|
77
|
+
'2262',
|
78
|
+
'2264',
|
79
|
+
'2265',
|
80
|
+
'2266',
|
81
|
+
'2267',
|
82
|
+
'2268',
|
83
|
+
'2271',
|
84
|
+
'2272',
|
85
|
+
'2273',
|
86
|
+
'2274',
|
87
|
+
'2281',
|
88
|
+
'2283',
|
89
|
+
'2284',
|
90
|
+
'2285',
|
91
|
+
'2286',
|
92
|
+
'2291',
|
93
|
+
'2292',
|
94
|
+
'2296',
|
95
|
+
'2297',
|
96
|
+
'2302',
|
97
|
+
'2314',
|
98
|
+
'2316',
|
99
|
+
'2317',
|
100
|
+
'2320',
|
101
|
+
'2323',
|
102
|
+
'2324',
|
103
|
+
'2325',
|
104
|
+
'2326',
|
105
|
+
'2331',
|
106
|
+
'2333',
|
107
|
+
'2334',
|
108
|
+
'2335',
|
109
|
+
'2336',
|
110
|
+
'2337',
|
111
|
+
'2338',
|
112
|
+
'2342',
|
113
|
+
'2343',
|
114
|
+
'2344',
|
115
|
+
'2345',
|
116
|
+
'2346',
|
117
|
+
'2352',
|
118
|
+
'2353',
|
119
|
+
'2354',
|
120
|
+
'2355',
|
121
|
+
'2356',
|
122
|
+
'2357',
|
123
|
+
'2358',
|
124
|
+
'2392',
|
125
|
+
'2393',
|
126
|
+
'2394',
|
127
|
+
'2395',
|
128
|
+
'2396',
|
129
|
+
'2473',
|
130
|
+
'2474',
|
131
|
+
'2475',
|
132
|
+
'2477',
|
133
|
+
'2478',
|
134
|
+
'2622',
|
135
|
+
'2624',
|
136
|
+
'2625',
|
137
|
+
'2626',
|
138
|
+
'2646',
|
139
|
+
'2647',
|
140
|
+
'2648',
|
141
|
+
'2651',
|
142
|
+
'2655',
|
143
|
+
'2656',
|
144
|
+
'2657',
|
145
|
+
'2658',
|
146
|
+
'2901',
|
147
|
+
'2902',
|
148
|
+
'2903',
|
149
|
+
'2920',
|
150
|
+
'2921',
|
151
|
+
'2922',
|
152
|
+
'2923',
|
153
|
+
'2924',
|
154
|
+
'2925',
|
155
|
+
'2926',
|
156
|
+
'2927',
|
157
|
+
'2928',
|
158
|
+
'2929',
|
159
|
+
'2931',
|
160
|
+
'2932',
|
161
|
+
'2933',
|
162
|
+
'2934',
|
163
|
+
'2935',
|
164
|
+
'2936',
|
165
|
+
'2940',
|
166
|
+
'2942',
|
167
|
+
'2945',
|
168
|
+
'2946',
|
169
|
+
'2948',
|
170
|
+
'2952',
|
171
|
+
'2953',
|
172
|
+
'2954',
|
173
|
+
'2962',
|
174
|
+
'2963',
|
175
|
+
'2964',
|
176
|
+
'2966',
|
177
|
+
'2972',
|
178
|
+
'2982',
|
179
|
+
'2983',
|
180
|
+
'3327',
|
181
|
+
'3329',
|
182
|
+
'3382',
|
183
|
+
'3385',
|
184
|
+
'3387',
|
185
|
+
'3388',
|
186
|
+
'3400',
|
187
|
+
'3401',
|
188
|
+
'3402',
|
189
|
+
'3404',
|
190
|
+
'3405',
|
191
|
+
'3406',
|
192
|
+
'3407',
|
193
|
+
'3408',
|
194
|
+
'3409',
|
195
|
+
'3435',
|
196
|
+
'3436',
|
197
|
+
'3437',
|
198
|
+
'3438',
|
199
|
+
'3442',
|
200
|
+
'3444',
|
201
|
+
'3445',
|
202
|
+
'3446',
|
203
|
+
'3447',
|
204
|
+
'3454',
|
205
|
+
'3455',
|
206
|
+
'3456',
|
207
|
+
'3458',
|
208
|
+
'3460',
|
209
|
+
'3462',
|
210
|
+
'3463',
|
211
|
+
'3464',
|
212
|
+
'3465',
|
213
|
+
'3466',
|
214
|
+
'3467',
|
215
|
+
'3468',
|
216
|
+
'3469',
|
217
|
+
'3471',
|
218
|
+
'3472',
|
219
|
+
'3476',
|
220
|
+
'3482',
|
221
|
+
'3483',
|
222
|
+
'3487',
|
223
|
+
'3489',
|
224
|
+
'3491',
|
225
|
+
'3492',
|
226
|
+
'3493',
|
227
|
+
'3496',
|
228
|
+
'3497',
|
229
|
+
'3498',
|
230
|
+
'3521',
|
231
|
+
'3522',
|
232
|
+
'3524',
|
233
|
+
'3525',
|
234
|
+
'3532',
|
235
|
+
'3533',
|
236
|
+
'3537',
|
237
|
+
'3541',
|
238
|
+
'3542',
|
239
|
+
'3543',
|
240
|
+
'3544',
|
241
|
+
'3546',
|
242
|
+
'3547',
|
243
|
+
'3548',
|
244
|
+
'3549',
|
245
|
+
'3562',
|
246
|
+
'3563',
|
247
|
+
'3564',
|
248
|
+
'3571',
|
249
|
+
'3572',
|
250
|
+
'3573',
|
251
|
+
'3574',
|
252
|
+
'3575',
|
253
|
+
'3576',
|
254
|
+
'3582',
|
255
|
+
'3583',
|
256
|
+
'3584',
|
257
|
+
'3585',
|
258
|
+
'3711',
|
259
|
+
'3715',
|
260
|
+
'3716',
|
261
|
+
'3718',
|
262
|
+
'3721',
|
263
|
+
'3725',
|
264
|
+
'3731',
|
265
|
+
'3734',
|
266
|
+
'3735',
|
267
|
+
'3741',
|
268
|
+
'3743',
|
269
|
+
'3751',
|
270
|
+
'3754',
|
271
|
+
'3755',
|
272
|
+
'3756',
|
273
|
+
'3757',
|
274
|
+
'3758',
|
275
|
+
'3772',
|
276
|
+
'3773',
|
277
|
+
'3774',
|
278
|
+
'3775',
|
279
|
+
'3777',
|
280
|
+
'3781',
|
281
|
+
'3782',
|
282
|
+
'3786',
|
283
|
+
'3821',
|
284
|
+
'3825',
|
285
|
+
'3826',
|
286
|
+
'3827',
|
287
|
+
'3832',
|
288
|
+
'3835',
|
289
|
+
'3837',
|
290
|
+
'3838',
|
291
|
+
'3841',
|
292
|
+
'3843',
|
293
|
+
'3844',
|
294
|
+
'3845',
|
295
|
+
'3846',
|
296
|
+
'3854',
|
297
|
+
'3855',
|
298
|
+
'3856',
|
299
|
+
'3857',
|
300
|
+
'3858',
|
301
|
+
'3861',
|
302
|
+
'3862',
|
303
|
+
'3863',
|
304
|
+
'3865',
|
305
|
+
'3867',
|
306
|
+
'3868',
|
307
|
+
'3869',
|
308
|
+
'3873',
|
309
|
+
'3876',
|
310
|
+
'3877',
|
311
|
+
'3878',
|
312
|
+
'3885',
|
313
|
+
'3886',
|
314
|
+
'3887',
|
315
|
+
'3888',
|
316
|
+
'3891',
|
317
|
+
'3892',
|
318
|
+
'3894',
|
319
|
+
]
|
320
|
+
|
321
|
+
# Mobile
|
322
|
+
# Mobile phone numbers in Argentina are assigned the same geographic area codes as fixed lines,
|
323
|
+
# according to the subscriber's choice or residence, and can be 6, 7 or 8 digits long, just as
|
324
|
+
# landline numbers are. The difference with landline numbers is that a prefix 15, never used for
|
325
|
+
# landlines, must be dialed.
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
# International: +54 + 9 + area code + subscriber number (without '15' prefix)
|
330
|
+
# Domestic: area code + 15 + subscriber number
|
331
|
+
# Mobile numbers in Argentina may be listed as 15-xxxxxxx. However, the leading '15'
|
332
|
+
# is a domestic prefix which must be omitted when calling these from outside Argentina,
|
333
|
+
# with the xxxxxxx being the actual subscriber number portion.
|
334
|
+
|
335
|
+
# Non-geographic numbers 0ppp-nnn-nnnn
|
336
|
+
special_numbers = [
|
337
|
+
'800', # toll-free telephone numbers
|
338
|
+
'810', # calls from any area chargeable at local rate
|
339
|
+
'822', # toll-free numbers used for calling card access
|
340
|
+
'600', # premium-rate telephone numbers
|
341
|
+
'609', # premium, fixed-rate gaming numbers
|
342
|
+
'610', # dial-up Internet access numbers, usually cheaper than a local call, less frequently used as dial-up Internet access decreased
|
343
|
+
'605', # premium-rate telephone numbers for charity donations
|
344
|
+
]
|
345
|
+
|
346
|
+
Phony.define do
|
347
|
+
country '54', trunk('0') |
|
348
|
+
one_of(area_codes_4digits) >> split(2, 4) | # landline
|
349
|
+
one_of(area_codes_3digits) >> split(3, 4) | # landline
|
350
|
+
one_of(area_codes_2digits) >> split(4, 4) | # landline
|
351
|
+
one_of(area_codes_2digits.map{|x| "9#{x}" }) >> split(4, 4) | # mobile
|
352
|
+
one_of(area_codes_3digits.map{|x| "9#{x}" }) >> split(3, 4) | # mobile
|
353
|
+
one_of(area_codes_4digits.map{|x| "9#{x}" }) >> split(2, 4) | # mobile
|
354
|
+
one_of(special_numbers) >> split(3, 4)
|
355
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
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
5
|
ndcs = [
|
@@ -10,20 +12,22 @@ ndcs = [
|
|
10
12
|
'732' # Linz
|
11
13
|
]
|
12
14
|
|
15
|
+
corporate_2digit = [
|
16
|
+
'57',
|
17
|
+
'59'
|
18
|
+
]
|
19
|
+
|
13
20
|
corporate = [
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'509', # -
|
25
|
-
'517', # -
|
26
|
-
'720', #
|
21
|
+
'501',
|
22
|
+
'502',
|
23
|
+
'503',
|
24
|
+
'504',
|
25
|
+
'505',
|
26
|
+
'506',
|
27
|
+
'507',
|
28
|
+
'508',
|
29
|
+
'509',
|
30
|
+
'517'
|
27
31
|
]
|
28
32
|
|
29
33
|
mobile = [
|
@@ -43,10 +47,14 @@ mobile = [
|
|
43
47
|
'667',
|
44
48
|
'668',
|
45
49
|
'669',
|
50
|
+
'670',
|
46
51
|
'676',
|
52
|
+
'677',
|
53
|
+
'678',
|
47
54
|
'680',
|
48
55
|
'681',
|
49
56
|
'688',
|
57
|
+
'690',
|
50
58
|
'699',
|
51
59
|
]
|
52
60
|
|
@@ -64,7 +72,6 @@ service = [
|
|
64
72
|
'730',
|
65
73
|
'740',
|
66
74
|
'780',
|
67
|
-
'800',
|
68
75
|
'802',
|
69
76
|
'804',
|
70
77
|
'810',
|
@@ -78,18 +85,21 @@ service = [
|
|
78
85
|
'939'
|
79
86
|
]
|
80
87
|
|
81
|
-
# https://www.rtr.at/en/tk/E129/
|
88
|
+
# https://www.rtr.at/en/tk/E129/Austrian_Numbering_Plan_2011-03-30.pdf
|
82
89
|
#
|
83
90
|
# TODO Add more details.
|
84
91
|
#
|
85
92
|
Phony.define do
|
86
|
-
country '43', trunk('0')
|
87
|
-
one_of('1')
|
88
|
-
one_of(service)
|
89
|
-
one_of(
|
90
|
-
one_of(
|
91
|
-
one_of(
|
92
|
-
one_of(
|
93
|
-
one_of(
|
94
|
-
|
93
|
+
country '43', trunk('0') |
|
94
|
+
one_of('1') >> split(3..12) | # Vienna
|
95
|
+
one_of(service) >> split(9..9) |
|
96
|
+
one_of('720') >> split(6..10) | # VoIP number length is 9..13
|
97
|
+
one_of('800') >> split(6..10) | # Free number length is 9..13
|
98
|
+
one_of(corporate_2digit) >> split(3..11) | # Corporate number length is 5..13
|
99
|
+
one_of(corporate) >> split(2..10) | # Corporate number length is 5..13
|
100
|
+
one_of(ndcs) >> split(5..10) |
|
101
|
+
one_of('663') >> split(6..8) | # 6..8 digit mobile.
|
102
|
+
one_of(mobile) >> split(4,3..9) |
|
103
|
+
one_of(mobile_2digit) >> split(7..7) | # Separate as mobile contains 676 - 67 violates the prefix rule.
|
104
|
+
fixed(4) >> split(3..9) # Number length is 7..13.
|
95
105
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Brazilian phone numbers.
|
2
4
|
#
|
3
5
|
#
|
@@ -87,17 +89,17 @@
|
|
87
89
|
# 98 #Maranhão
|
88
90
|
# 99 #Maranhão
|
89
91
|
|
90
|
-
ndcs =
|
92
|
+
ndcs = "(11|12|13|14|15|16|17|18|19|21|22|24|27|28|31|32|33|34|35|36|37|38|41|42|43|44|45|46|47|48|49|51|52|53|54|55|61|62|63|64|65|66|67|68|69|71|72|73|74|75|77|78|79|81|82|83|84|85|86|87|88|89|91|92|93|94|95|96|97|98|99)"
|
91
93
|
|
92
94
|
service = %w{ 100 128 190 191 192 193 194 197 198 199 } # State specific numbers were not added. See http://www.brasil.gov.br/navegue_por/aplicativos/agenda
|
93
95
|
|
94
96
|
special_numbers_3_4 = %w{ 0800 }
|
95
|
-
special_numbers_4 = %w{ 3003 4004 4020 }
|
97
|
+
special_numbers_4 = %w{ 3003 4003 4004 4020 }
|
96
98
|
|
97
99
|
Phony.define do
|
98
100
|
country '55',
|
99
|
-
match(
|
100
|
-
match(ndcs)
|
101
|
+
match(/^#{ndcs}9\d{8}$/) >> split(5,4) |
|
102
|
+
match(/^#{ndcs}\d{8}$/) >> split(4,4) |
|
101
103
|
one_of(special_numbers_3_4) >> split(3,4) |
|
102
104
|
one_of(special_numbers_4) >> split(4) |
|
103
105
|
one_of(service) >> split(3) |
|