phony 2.19.3 → 2.19.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phony/countries/italy.rb +1 -0
- data/lib/phony/countries/libya.rb +1 -1
- data/lib/phony/countries/taiwan.rb +1 -0
- data/lib/phony/countries.rb +34 -25
- data/lib/phony/country_codes.rb +1 -1
- data/lib/phony/local_splitters/fixed.rb +2 -0
- data/spec/functional/plausibility_spec.rb +24 -11
- data/spec/lib/phony/countries_spec.rb +22 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d971b51de8e8d0581c884f90238d00bbdeeee7ca248ae3b93ce75e5b759114fd
|
4
|
+
data.tar.gz: d37f03c8ca22a2fcf76b046a38cfd6cc6334d79cd377bb221e1610352b331ee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '028169288dfdcd908210a144add1c6d6eb082703602fd4eaa069c9ca952fe8e3e8c0c46764244af569cf90ba5fb535681369b700e3f273bebde591c534e544d3'
|
7
|
+
data.tar.gz: dc281117fa228352a099b3dc28e77d13c7d8145ef93f50ab721817e6b0a6024a32e4f4587c191529142ba987498b62d9a1bd3b9c4cfbf3ae72f2537b70e375ab
|
@@ -111,6 +111,6 @@ Phony.define do
|
|
111
111
|
one_of(ndcs_with_5_subscriber_numbers) >> split(3,2) |
|
112
112
|
one_of(ndcs_with_6_subscriber_numbers) >> split(3,3) |
|
113
113
|
one_of(ndcs_with_7_subscriber_numbers) >> split(4,3) |
|
114
|
-
one_of(%w(91 92)) >> split(4,3) | # mobile
|
114
|
+
one_of(%w(91 92 94 95)) >> split(4,3) | # mobile
|
115
115
|
fixed(2) >> split(3,3)
|
116
116
|
end
|
@@ -11,6 +11,7 @@ Phony.define do
|
|
11
11
|
match(/\A(836)\d{5}\z/) >> split(1,4) | # 馬祖, start with 0836, plus 5 digits
|
12
12
|
match(/\A(82)\d{6}\z/) >> split(2,4) | # 金門, start with 082, plus 6 digits
|
13
13
|
match(/\A(89)\d{6}\z/) >> split(2,4) | # 臺東, start with 089, plus 6 digits
|
14
|
+
match(/\A(80\d)\d{6}\z/)>> split(3,4) | # Toll-free number
|
14
15
|
match(/\A(8)\d{7}\z/) >> split(3,4) | # 屏東, start with 08, plus 7 digits
|
15
16
|
match(/\A(49)\d{7}\z/) >> split(3,4) | # 南投, start with 049, plus 7 digits
|
16
17
|
one_of(%w(4)) >> matched_split(
|
data/lib/phony/countries.rb
CHANGED
@@ -96,15 +96,16 @@ Phony.define do
|
|
96
96
|
# Belgium.
|
97
97
|
#
|
98
98
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Belgium
|
99
|
+
# https://www.bipt.be/operators/publication/national-numbering-plan
|
99
100
|
#
|
100
101
|
country '32', trunk('0') |
|
101
|
-
match(/^(7[08])\d+$/)
|
102
|
-
match(/^(800|90\d)\d+$/)
|
103
|
-
match(/^(46[
|
104
|
-
match(/^(4[789]\d)\d{6}$/)
|
105
|
-
match(/^(45[56])\d{6}$/)
|
106
|
-
one_of('2','3','4','9')
|
107
|
-
fixed(2)
|
102
|
+
match(/^(7[08])\d+$/) >> split(3,3) | # Premium and national rate Services
|
103
|
+
match(/^(800|90\d)\d+$/) >> split(2,3) | # Toll free service and premium numbers
|
104
|
+
match(/^(46[056789])\d{6}$/) >> split(2,2,2) | # Mobile (Lycamobile, Telenet, Join Experience, Proximus 0460)
|
105
|
+
match(/^(4[789]\d)\d{6}$/) >> split(2,2,2) | # Mobile
|
106
|
+
match(/^(45[56])\d{6}$/) >> split(2,2,2) | # Mobile Vikings and Voo
|
107
|
+
one_of('2','3','4','9') >> split(3,2,2) | # Short NDCs
|
108
|
+
fixed(2) >> split(2,2,2) # 2-digit NDCs
|
108
109
|
|
109
110
|
# France.
|
110
111
|
#
|
@@ -154,6 +155,7 @@ Phony.define do
|
|
154
155
|
#
|
155
156
|
country '41',
|
156
157
|
trunk('0', normalize: true) |
|
158
|
+
match(/^(860)\d+$/) >> split(2, 3, 2, 2) | # Voice Mail access
|
157
159
|
match(/^(8(?:00|4[0248]))\d+$/) >> split(3,3) | # Freecall/Shared Cost
|
158
160
|
match(/^(90[016])\d+$/) >> split(3,3) | # Business
|
159
161
|
fixed(2) >> split(3,2,2)
|
@@ -485,27 +487,31 @@ Phony.define do
|
|
485
487
|
# Zambia
|
486
488
|
# http://www.wtng.info/wtng-260-zm.html
|
487
489
|
# https://github.com/googlei18n/libphonenumber/
|
490
|
+
# https://en.wikipedia.org/wiki/Telephone_numbers_in_Zambia
|
488
491
|
country '260',
|
489
|
-
|
492
|
+
trunk('0') |
|
493
|
+
match(/^(76|77|95|96|97)/) >> split(3, 4) | # Mobile
|
490
494
|
match(/^(800)/) >> split(3,3) | # Toll free
|
491
495
|
match(/^(21[1-8])/) >> split(6) # Fixed
|
492
496
|
|
493
|
-
# Madagascar
|
497
|
+
# Madagascar
|
498
|
+
# https://en.wikipedia.org/wiki/Telephone_numbers_in_Madagascar
|
494
499
|
# http://www.itu.int/oth/T020200007F/en
|
495
500
|
country '261',
|
496
|
-
none >> matched_split(
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
)
|
501
|
+
# none >> matched_split(
|
502
|
+
# /\A20\d+\z/ => [2,2,3,2], # Telecom Malagasy (Telma)
|
503
|
+
# /\A32\d+\z/ => [2,2,3,2], # mobile Orange Madagascar
|
504
|
+
# /\A33\d+\z/ => [2,2,3,2], # mobile Airtel Madagascar
|
505
|
+
# /\A34\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
|
506
|
+
# /\A38\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
|
507
|
+
# /\A39\d+\z => [2,2,3,2] # mobile Blueline
|
508
|
+
# ),
|
509
|
+
match(/\A(20)\d+\z/) >> split(2,3,2) | # fix Telecom Malagasy (Telma)
|
510
|
+
match(/\A(32)\d+\z/) >> split(2,3,2) | # mobile Orange Madagascar
|
511
|
+
match(/\A(33)\d+\z/) >> split(2,3,2) | # mobile Airtel Madagascar
|
512
|
+
match(/\A(34)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
|
513
|
+
match(/\A(38)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
|
514
|
+
match(/\A(39)\d+\z/) >> split(2,3,2) # mobile Blueline Madagascar
|
509
515
|
|
510
516
|
country '262', # Reunion / Mayotte (new) http://www.wtng.info/wtng-262-fr.html
|
511
517
|
trunk('0') |
|
@@ -971,7 +977,7 @@ Phony.define do
|
|
971
977
|
/\A800\d+\z/ => [3,3], # freephone
|
972
978
|
/\A830\d+\z/ => [3,3], # shared cost
|
973
979
|
/\A60\d+\z/ => [3,3], # wireless geographic
|
974
|
-
/\A(72|75|76|77)\d+\z/ => [3,4], # mobile
|
980
|
+
/\A(71|72|75|76|77)\d+\z/ => [3,4], # mobile
|
975
981
|
/\A84\d+\z/ => [3,4], # wireless geographic
|
976
982
|
/\A\d+\z/ => [2,3] # geographic
|
977
983
|
)
|
@@ -992,7 +998,10 @@ Phony.define do
|
|
992
998
|
country '698', todo # -
|
993
999
|
country '699', todo # -
|
994
1000
|
|
995
|
-
|
1001
|
+
# International Freephone Service
|
1002
|
+
# https://www.itu.int/en/ITU-T/inr/unum/Pages/uifn.aspx
|
1003
|
+
country '800', none >> split(8)
|
1004
|
+
|
996
1005
|
country '801', todo # -
|
997
1006
|
country '802', todo # -
|
998
1007
|
country '803', todo # -
|
@@ -1000,7 +1009,7 @@ Phony.define do
|
|
1000
1009
|
country '805', todo # -
|
1001
1010
|
country '806', todo # -
|
1002
1011
|
country '807', todo # -
|
1003
|
-
country '808',
|
1012
|
+
country '808', none >> split(12) # International Shared Cost Service (ISCS)
|
1004
1013
|
country '809', todo # -
|
1005
1014
|
|
1006
1015
|
country '830', todo # -
|
data/lib/phony/country_codes.rb
CHANGED
@@ -97,7 +97,7 @@ module Phony
|
|
97
97
|
|
98
98
|
# False if it fails the basic check.
|
99
99
|
#
|
100
|
-
return false unless (4..16) === normalized.size
|
100
|
+
return false unless (4..16) === normalized.size # unless hints[:check_length] == false
|
101
101
|
|
102
102
|
country, cc, rest = partial_split normalized
|
103
103
|
|
@@ -280,6 +280,7 @@ describe 'plausibility' do
|
|
280
280
|
it_is_correct_for 'Guinea-Bissau', :samples => '+245 44 728 6998'
|
281
281
|
it_is_correct_for 'Guyana', :samples => '+592 263 1234'
|
282
282
|
it_is_correct_for 'Honduras (Republic of)', :samples => '+504 12 961 637'
|
283
|
+
it_is_correct_for 'Italy', :samples => ['+39 0574 1234']
|
283
284
|
it_is_correct_for 'Iraq', :samples => ['+964 1 123 4567',
|
284
285
|
'+964 21 113 456',
|
285
286
|
'+964 71 1234 5678']
|
@@ -324,10 +325,19 @@ describe 'plausibility' do
|
|
324
325
|
it_is_correct_for 'Macedonia', :samples => ['+389 2 123 4567',
|
325
326
|
'+389 7 124 3456',
|
326
327
|
'+389 7 234 5678']
|
327
|
-
it_is_correct_for 'Madagascar', :samples => ['+261 20
|
328
|
-
'+261
|
329
|
-
'+261
|
330
|
-
'+261
|
328
|
+
it_is_correct_for 'Madagascar', :samples => ['+261 20 23 456 78',
|
329
|
+
'+261 32 34 546 78',
|
330
|
+
'+261 33 34 546 78',
|
331
|
+
'+261 34 34 546 78',
|
332
|
+
'+261 38 34 546 78']
|
333
|
+
it 'is incorrect for Madagascar' do
|
334
|
+
Phony.plausible?('+261 20 012 345 678').should be_falsey
|
335
|
+
Phony.plausible?('+261 20 12 434 569').should be_falsey
|
336
|
+
Phony.plausible?('+261 51 23 4567 8').should be_falsey
|
337
|
+
Phony.plausible?('+261 34 345 46789').should be_falsey
|
338
|
+
Phony.plausible?('+261 34 345 467').should be_falsey
|
339
|
+
end
|
340
|
+
|
331
341
|
it_is_correct_for 'Malawi', :samples => ['+265 1725 123',
|
332
342
|
'+265 213 456 789',
|
333
343
|
'+265 9123 456',
|
@@ -507,7 +517,10 @@ describe 'plausibility' do
|
|
507
517
|
it_is_correct_for 'Lybia', :samples => ['+218 205 123 45',
|
508
518
|
'+218 22 123 456',
|
509
519
|
'+218 21 1234 456',
|
510
|
-
'+218 91 1234 456'
|
520
|
+
'+218 91 1234 456',
|
521
|
+
'+218 92 1234 456',
|
522
|
+
'+218 94 1234 456',
|
523
|
+
'+218 95 1234 456']
|
511
524
|
it_is_correct_for 'Mongolia', :samples => ['+976 11 123 45',
|
512
525
|
['+976 121 12 34', '+976 121 12 345'],
|
513
526
|
'+976 70 123 456',
|
@@ -568,12 +581,12 @@ describe 'plausibility' do
|
|
568
581
|
'+967 58 1234']
|
569
582
|
it 'is correct for Zambia' do
|
570
583
|
Phony.plausible?('+260 211 123456').should be_truthy # Fixed
|
571
|
-
Phony.plausible?('+260
|
572
|
-
Phony.plausible?('+260
|
573
|
-
Phony.plausible?('+260
|
574
|
-
Phony.plausible?('+260
|
575
|
-
Phony.plausible?('+260
|
576
|
-
Phony.plausible?('+260
|
584
|
+
Phony.plausible?('+260 96 512 4567').should be_truthy # MTN Mobile
|
585
|
+
Phony.plausible?('+260 97 712 3456').should be_truthy # Airtel Mobile
|
586
|
+
Phony.plausible?('+260 95 512 4567').should be_truthy # Zamtel Mobile
|
587
|
+
Phony.plausible?('+260 96 512 456').should be_falsy # MTN Mobile (Too short)
|
588
|
+
Phony.plausible?('+260 97 812 345').should be_falsy # Airtel Mobile (Too short)
|
589
|
+
Phony.plausible?('+260 95 512 345').should be_falsy # Zamtel Mobile (Too short)
|
577
590
|
Phony.plausible?('+260 800 123 456').should be_truthy # Toll free
|
578
591
|
end
|
579
592
|
it_is_correct_for 'Zimbabwe', :samples => [['+263 2582 123 456', '+263 2582 123'],
|
@@ -110,6 +110,7 @@ describe 'country descriptions' do
|
|
110
110
|
it_splits '32466123456', ['32', '466', '12', '34', '56'] # mobile (Vectone)
|
111
111
|
it_splits '32467123456', ['32', '467', '12', '34', '56'] # mobile (Telenet)
|
112
112
|
it_splits '32468123456', ['32', '468', '12', '34', '56'] # mobile (Telenet)
|
113
|
+
it_splits '32469123456', ['32', '469', '12', '34', '56'] # mobile ()
|
113
114
|
it_splits '32475123456', ['32', '475', '12', '34', '56'] # mobile (Proximus)
|
114
115
|
it_splits '32485123456', ['32', '485', '12', '34', '56'] # mobile (Telenet)
|
115
116
|
it_splits '32495123456', ['32', '495', '12', '34', '56'] # mobile (Orange)
|
@@ -469,6 +470,7 @@ describe 'country descriptions' do
|
|
469
470
|
it_splits '3903123391', ['39', '031', '23391'] # Como
|
470
471
|
it_splits '390909709511', ['39', '090', '9709511'] # Barcellona
|
471
472
|
it_splits '390471811353', ['39', '0471', '811', '353'] # Bolzano
|
473
|
+
it_splits '3905745730', ['39', '0574', '5730'] # Prato
|
472
474
|
end
|
473
475
|
describe 'Japan' do
|
474
476
|
it_splits '81312345678', %w(81 3 1234 5678) # Tokyo
|
@@ -762,6 +764,7 @@ describe 'country descriptions' do
|
|
762
764
|
describe 'Switzerland' do
|
763
765
|
it_splits '41443643532', ['41', '44', '364', '35', '32'] # Zurich (usually)
|
764
766
|
it_splits '41800334455', ['41', '800', '334', '455'] # Service number
|
767
|
+
it_splits '41860443643532', ['41', '860', '44', '364', '35', '32'] # Voicemail access
|
765
768
|
it_splits '41900123456', ['41', '900', '123', '456'] # Business Number
|
766
769
|
it_splits '41901123456', ['41', '901', '123', '456'] # Business Number Entertainment
|
767
770
|
it_splits '41906123456', ['41', '906', '123', '456'] # Business Number Adult Entertainment
|
@@ -850,9 +853,9 @@ describe 'country descriptions' do
|
|
850
853
|
end
|
851
854
|
describe 'Zambia' do
|
852
855
|
it_splits '260211123456', ['260', '211', '123456'] # Fixed
|
853
|
-
it_splits '260955123456', ['260', '
|
854
|
-
it_splits '260967123456', ['260', '
|
855
|
-
it_splits '260978123456', ['260', '
|
856
|
+
it_splits '260955123456', ['260', '95', '512', '3456'] # Mobile
|
857
|
+
it_splits '260967123456', ['260', '96', '712', '3456'] # Mobile
|
858
|
+
it_splits '260978123456', ['260', '97', '812', '3456'] # Mobile
|
856
859
|
it_splits '260800123456', ['260', '800', '123', '456'] # Toll free
|
857
860
|
end
|
858
861
|
describe 'New Zealand' do
|
@@ -1050,11 +1053,14 @@ describe 'country descriptions' do
|
|
1050
1053
|
it_splits '21822123456', %w(218 22 123 456)
|
1051
1054
|
it_splits '218211234456', %w(218 21 1234 456)
|
1052
1055
|
it_splits '218911234456', %w(218 91 1234 456)
|
1056
|
+
it_splits '218941234456', %w(218 94 1234 456)
|
1057
|
+
it_splits '218951234456', %w(218 95 1234 456)
|
1053
1058
|
end
|
1054
1059
|
describe 'Madagascar' do
|
1055
|
-
it_splits '
|
1056
|
-
it_splits '
|
1057
|
-
it_splits '
|
1060
|
+
it_splits '261202254716', ['261', '20', *%w(22 547 16)]
|
1061
|
+
it_splits '261320254716', ['261', '32', *%w(02 547 16)]
|
1062
|
+
it_splits '261330254716', ['261', '33', *%w(02 547 16)]
|
1063
|
+
it_splits '261340254716', ['261', '34', *%w(02 547 16)]
|
1058
1064
|
end
|
1059
1065
|
describe 'Malawi' do
|
1060
1066
|
it_splits '2651725123', ['265', false, '1725', '123']
|
@@ -1229,6 +1235,7 @@ describe 'country descriptions' do
|
|
1229
1235
|
describe 'Samoa (Independent State of)' do
|
1230
1236
|
it_splits '685800123', ['685', false, '800', '123']
|
1231
1237
|
it_splits '68561123', ['685', false, '61', '123']
|
1238
|
+
it_splits '6857112345', ['685', false, '711', '2345']
|
1232
1239
|
it_splits '6857212345', ['685', false, '721', '2345']
|
1233
1240
|
it_splits '685830123', ['685', false, '830', '123']
|
1234
1241
|
it_splits '685601234', ['685', false, '601', '234']
|
@@ -1317,6 +1324,7 @@ describe 'country descriptions' do
|
|
1317
1324
|
it_splits '88633123456', %w(886 3 312 3456)
|
1318
1325
|
it_splits '88637123456', %w(886 37 12 3456)
|
1319
1326
|
it_splits '88682712345', %w(886 82 71 2345)
|
1327
|
+
it_splits '886801123123', %w(886 801 123 123)
|
1320
1328
|
it_splits '88689712345', %w(886 89 71 2345)
|
1321
1329
|
it_splits '88682672345', %w(886 826 7 2345)
|
1322
1330
|
it_splits '88683672345', %w(886 836 7 2345)
|
@@ -1427,6 +1435,14 @@ describe 'country descriptions' do
|
|
1427
1435
|
it_splits number, ['263', prefix, '234', '5678']
|
1428
1436
|
end
|
1429
1437
|
end
|
1438
|
+
|
1439
|
+
describe 'Universal International Freephone' do
|
1440
|
+
it_splits '80012345678', ['800', false, '12345678']
|
1441
|
+
end
|
1442
|
+
|
1443
|
+
describe 'Shared-Cost Service' do
|
1444
|
+
it_splits '80812345678', ['808', false, '12345678']
|
1445
|
+
end
|
1430
1446
|
end
|
1431
1447
|
|
1432
1448
|
end
|
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.19.
|
4
|
+
version: 2.19.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-21 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
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.1.6
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Fast international phone number (E164 standard) normalizing, splitting and
|