phony 2.18.4 → 2.18.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db79646f3b77b08c8894645615cfb86ac101c27f7aa7f45ff11f3b5465ce6ec4
4
- data.tar.gz: 3c4b444c507b434adbe52651941b444019313c1c09473e64a8dc779036b8b549
3
+ metadata.gz: 062a3448529e9cd54a3b989ab0522ee2035821af37c7b194a1b3167bdb8f1693
4
+ data.tar.gz: 6f2b104415be34d29daf0569326a5a7480c6e44f243533e5e0ed51dbe554c699
5
5
  SHA512:
6
- metadata.gz: 267251e1d56ab1b335c3779b5a28a7b15d8b73b9635a1e60a604cf48b500f376c65fcd6a158e94d4eb07db97e392410443094da02694224561f1a48d4175c037
7
- data.tar.gz: f496ad6a5854fbdaa919fb5fc175dbba898fcd5261096fe3df43929f98b4bf1af476bc80853b16116703ab99aae3b34eb014ed7903e46fb0dbc93bfe829dcedb
6
+ metadata.gz: c1e05a38ac40ddf8b69792071ceaf62fe90a66f79ee0ba6992f6022a4ab88ff5d33d33fa9276612e135231f3554f01eb83f551b5c163e7e2f0faf8e0a52417d0
7
+ data.tar.gz: d2f5667fd4d32a6bd33961eca81928c2140a5383837f4a027203cad67afa34107560ea80291f35fee06fce9a43417f8e4272cc08b436eed6d5036c9f0aa18769
@@ -24,6 +24,7 @@ load File.expand_path '../phony/dsl.rb', __FILE__
24
24
  #
25
25
  # The ones that need more space to define.
26
26
  #
27
+ load File.expand_path '../phony/countries/argentina.rb', __FILE__
27
28
  load File.expand_path '../phony/countries/austria.rb', __FILE__
28
29
  load File.expand_path '../phony/countries/bangladesh.rb', __FILE__
29
30
  load File.expand_path '../phony/countries/belarus.rb', __FILE__
@@ -213,14 +213,7 @@ Phony.define do
213
213
  fixed(3) >> split(7) # 3-digit NDCs
214
214
 
215
215
  # Argentine Republic.
216
- #
217
- country '54',
218
- one_of('11', '911') >> split(4,4) | # Fixed & Mobile
219
- match(/^(22[0137]|237|26[14]|29[179]|34[1235]|35[138]|38[1578])/) >> split(3,4) | # Fixed
220
- match(/^(922[0137]|9237|926[14]|929[179]|934[1235]|935[138]|938[1578])/) >> split(3,4) | # Mobile
221
- match(/^(9\d{4})/) >> split(2,4) | # Mobile
222
- match(/^([68]\d{2})/) >> split(3,4) | # Service
223
- fixed(4) >> split(2,4) # Fixed
216
+ # country '54' # argentina, see special file.
224
217
 
225
218
  # Brazil (Federative Republic of).
226
219
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
@@ -738,11 +731,12 @@ Phony.define do
738
731
  # Monaco
739
732
  #
740
733
  country '377',
741
- one_of('6') >> split(2,2,2,2) | # mobile
734
+ one_of('6') >> split(2,2,2,2) | # mobile
742
735
  fixed(2) >> split(2,2,2)
743
736
 
744
737
  # San Marino
745
738
  country '378',
739
+ trunk('', :normalize => false) |
746
740
  none >> matched_split(
747
741
  /\A\d{6}\z/ => [3,3],
748
742
  /\A\d+\z/ => [3,3,4]
@@ -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
@@ -85,7 +85,7 @@ service = [
85
85
  '939'
86
86
  ]
87
87
 
88
- # https://www.rtr.at/en/tk/E129/2312_Austrian_Numbering_Plan_2011-03-30.pdf
88
+ # https://www.rtr.at/en/tk/E129/Austrian_Numbering_Plan_2011-03-30.pdf
89
89
  #
90
90
  # TODO Add more details.
91
91
  #
@@ -97,7 +97,7 @@ Phony.define do
97
97
  one_of('800') >> split(6..10) | # Free number length is 9..13
98
98
  one_of(corporate_2digit) >> split(3..11) | # Corporate number length is 5..13
99
99
  one_of(corporate) >> split(2..10) | # Corporate number length is 5..13
100
- one_of(ndcs) >> split(6..10) |
100
+ one_of(ndcs) >> split(5..10) |
101
101
  one_of('663') >> split(6..8) | # 6..8 digit mobile.
102
102
  one_of(mobile) >> split(4,3..9) |
103
103
  one_of(mobile_2digit) >> split(7..7) | # Separate as mobile contains 676 - 67 violates the prefix rule.
@@ -4090,7 +4090,7 @@ Phony.define do
4090
4090
  one_of(*service) >> split(3,1..9) |
4091
4091
  one_of(*mobile_4digits) >> split(3,4) |
4092
4092
  one_of(*mobile_3digits) >> split(4,3..4) |
4093
- one_of(*ndcs2) >> split(3,2..10) |
4093
+ one_of(*ndcs2) >> split(3,1..10) |
4094
4094
  one_of(*ndcs3) >> split(3,1..9) |
4095
4095
  one_of(*ndcs4) >> split(3,0..8) |
4096
4096
  fixed(5) >> split(3,0..7)
@@ -46,7 +46,8 @@ describe 'plausibility' do
46
46
  end
47
47
 
48
48
  context 'specific countries' do
49
- it_is_correct_for 'Austria', :samples => '+43 720 116987' # VoIP
49
+ it_is_correct_for 'Austria', :samples => ['+43 720 116987', # VoIP
50
+ '+43 463 12345'] # Klagenfurt
50
51
  it_is_correct_for 'Bosnia and Herzegovina', :samples => ['+387 66 666 666',
51
52
  '+387 37 123 456',
52
53
  '+387 33 222 111']
@@ -251,6 +252,7 @@ describe 'plausibility' do
251
252
  it_is_correct_for 'Gabonese Republic', :samples => '+241 1 627 739'
252
253
  it_is_correct_for 'Gambia', :samples => '+220 989 5148'
253
254
  it_is_correct_for 'Germany', :samples => [
255
+ '+49 69 155 1',
254
256
  '+49 1577 536 8701'
255
257
  ]
256
258
  it_is_correct_for 'Georgia', :samples => ['+995 220 123 45',
@@ -33,13 +33,13 @@ describe 'country descriptions' do
33
33
  end
34
34
 
35
35
  describe 'Argentina' do
36
- it_splits '541112345678', ['54', '11', '1234', '5678']
37
- it_splits '542911234567', ['54', '291', '123', '4567']
38
- it_splits '542965123456', ['54', '2965', '12', '3456']
39
- it_splits '5491112345678', ['54', '911', '1234', '5678']
40
- it_splits '5492201234567', ['54', '9220', '123', '4567']
41
- it_splits '5492221123456', ['54', '92221', '12', '3456']
42
- it_splits '548001234567', ['54', '800', '123', '4567']
36
+ it_splits '541112345678', ['54', '11', '1234', '5678'] # 2-digit area code / landline
37
+ it_splits '542911234567', ['54', '291', '123', '4567'] # 3-digit area code / landline
38
+ it_splits '542903123456', ['54', '2903', '12', '3456'] # 4-digit area code / landline
39
+ it_splits '5491112345678', ['54', '911', '1234', '5678'] # 2-digit area code / international mobile
40
+ it_splits '5492201234567', ['54', '9220', '123', '4567'] # 3-digit area code / international mobile
41
+ it_splits '5492221123456', ['54', '92221', '12', '3456'] # 4-digit area code / international mobile
42
+ it_splits '548001234567', ['54', '800', '123', '4567'] # Non-geographic number
43
43
  end
44
44
 
45
45
  describe 'Austria' do
@@ -23,7 +23,7 @@ describe Phony::Country do
23
23
  end
24
24
 
25
25
  context 'regression' do
26
- describe 'iceland' do
26
+ describe 'Iceland' do
27
27
  let(:country) do
28
28
  national_splitter = Phony::NationalSplitters::None.instance_for
29
29
  local_splitter = Phony::LocalSplitters::Fixed.instance_for [3, 4]
@@ -35,6 +35,14 @@ describe Phony::Country do
35
35
  country.split('112').should == [nil, false, '112']
36
36
  end
37
37
  end
38
+ describe 'San Marino' do
39
+ it 'normalizes correctly' do
40
+ Phony.normalize('+3780549903549').should == '3780549903549'
41
+ end
42
+ xit 'automatically adds the sole NC' do
43
+ Phony.normalize('+378903549').should == '3780549903549'
44
+ end
45
+ end
38
46
  end
39
47
 
40
48
  context "without special cases (with switzerland)" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.4
4
+ version: 2.18.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-28 00:00:00.000000000 Z
11
+ date: 2019-11-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Fast international phone number (E164 standard) normalizing, splitting
14
14
  and formatting. Lots of formatting options: International (+.., 00..), national
@@ -23,6 +23,7 @@ files:
23
23
  - lib/phony.rb
24
24
  - lib/phony/config.rb
25
25
  - lib/phony/countries.rb
26
+ - lib/phony/countries/argentina.rb
26
27
  - lib/phony/countries/austria.rb
27
28
  - lib/phony/countries/bangladesh.rb
28
29
  - lib/phony/countries/belarus.rb
@@ -113,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.7.6
117
+ rubygems_version: 3.0.3
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Fast international phone number (E164 standard) normalizing, splitting and