phony 2.19.4 → 2.19.8

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: fe07b2679b93f5f47130983d691b0c9cba7d99bc9cb83e68c62055dfc21b0c4d
4
- data.tar.gz: cacc529ee97eb80c8538912869e836035c6c2458f464a99b23b97d13c791cd87
3
+ metadata.gz: c0fc7753788d596736d26fddf4ff8688d33348e45512f3edea923b8fb35afa7c
4
+ data.tar.gz: 570d9d1012de2b6a854bafc238e385619365b4a559cea14f321ded2f0644c851
5
5
  SHA512:
6
- metadata.gz: effe3a2aa50125a4ecbabcb805dcb80c49f5b394ca5c8d443ea58eae124964e34bfa90309187dc91e934fb7df472d4884e036034c1a4d98387510ad81483892d
7
- data.tar.gz: 364893e401aaad1bbbc0bd3e5466e78dd3eb94b3e2780a98c781109643818c7ce89eacc9cece8925e72029ec07cf22a9dae496b260e9c7e3f88bf39993f0a588
6
+ metadata.gz: b22cf9c9b8bffe3222333461c919b5a04fab9b4d7f111c0679b79e602787a262b0716a432affa4b1a35710ab26e188f947420dcf35a7b893ae7af22e58d0e4c5
7
+ data.tar.gz: '008fcad42c6dec3854a15b6dfe9d4856b5a26950cd8a9bfa4495d056159dd0dc9b3e77320380e97350fd7d6ec7886af542c6435da21771c12889f82cbac6a962'
@@ -486,27 +486,31 @@ Phony.define do
486
486
  # Zambia
487
487
  # http://www.wtng.info/wtng-260-zm.html
488
488
  # https://github.com/googlei18n/libphonenumber/
489
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Zambia
489
490
  country '260',
490
- match(/^([79][5678]\d)/) >> split(6) | # Mobile
491
+ trunk('0') |
492
+ match(/^(76|77|95|96|97)/) >> split(3, 4) | # Mobile
491
493
  match(/^(800)/) >> split(3,3) | # Toll free
492
494
  match(/^(21[1-8])/) >> split(6) # Fixed
493
495
 
494
- # Madagascar http://www.wtng.info/wtng-261-mg.html
496
+ # Madagascar
497
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Madagascar
495
498
  # http://www.itu.int/oth/T020200007F/en
496
499
  country '261',
497
- none >> matched_split(
498
- /\A200\d+\z/ => [2,3,3,3], # Telecom Malagasy (Telma)
499
- /\A20\d+\z/ => [2,3,4], # Telecom Malagasy (Telma)
500
- /\A23\d+\z/ => [2,3,4], # Digitel
501
- /\A30\d+\z/ => [2,3,4], # mobile Madamobil (CDMA2000)
502
- /\A31\d+\z/ => [2,3,4], # mobile Airtel Madagascar
503
- /\A32\d+\z/ => [2,3,4], # mobile Orange Madagascar
504
- /\A33\d+\z/ => [2,3,4], # mobile Airtel Madagascar
505
- /\A34\d+\z/ => [2,3,4], # mobile Telecom Malagasy (Telma)
506
- /\A5\d+\z/ => [3,3,3], # pager
507
- /\A22\d+\z/ => [3,3,3], # satellite GULFSAT Téléphonie
508
- /\A6\d+\z/ => [3,3,3] # satellite
509
- )
500
+ # none >> matched_split(
501
+ # /\A20\d+\z/ => [2,2,3,2], # Telecom Malagasy (Telma)
502
+ # /\A32\d+\z/ => [2,2,3,2], # mobile Orange Madagascar
503
+ # /\A33\d+\z/ => [2,2,3,2], # mobile Airtel Madagascar
504
+ # /\A34\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
505
+ # /\A38\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
506
+ # /\A39\d+\z => [2,2,3,2] # mobile Blueline
507
+ # ),
508
+ match(/\A(20)\d+\z/) >> split(2,3,2) | # fix Telecom Malagasy (Telma)
509
+ match(/\A(32)\d+\z/) >> split(2,3,2) | # mobile Orange Madagascar
510
+ match(/\A(33)\d+\z/) >> split(2,3,2) | # mobile Airtel Madagascar
511
+ match(/\A(34)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
512
+ match(/\A(38)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
513
+ match(/\A(39)\d+\z/) >> split(2,3,2) # mobile Blueline Madagascar
510
514
 
511
515
  country '262', # Reunion / Mayotte (new) http://www.wtng.info/wtng-262-fr.html
512
516
  trunk('0') |
@@ -993,7 +997,10 @@ Phony.define do
993
997
  country '698', todo # -
994
998
  country '699', todo # -
995
999
 
996
- country '800', todo # International Freephone Service
1000
+ # International Freephone Service
1001
+ # https://www.itu.int/en/ITU-T/inr/unum/Pages/uifn.aspx
1002
+ country '800', none >> split(8)
1003
+
997
1004
  country '801', todo # -
998
1005
  country '802', todo # -
999
1006
  country '803', todo # -
@@ -1001,7 +1008,7 @@ Phony.define do
1001
1008
  country '805', todo # -
1002
1009
  country '806', todo # -
1003
1010
  country '807', todo # -
1004
- country '808', todo # International Shared Cost Service (ISCS)
1011
+ country '808', none >> split(12) # International Shared Cost Service (ISCS)
1005
1012
  country '809', todo # -
1006
1013
 
1007
1014
  country '830', todo # -
@@ -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
 
@@ -62,6 +62,8 @@ module Phony
62
62
  #
63
63
  #
64
64
  def plausible? rest, hints = {}
65
+ return true if hints[:check_length] == false
66
+
65
67
  @length === rest.inject(0) { |total, part| total + part.size }
66
68
  end
67
69
 
@@ -324,10 +324,19 @@ describe 'plausibility' do
324
324
  it_is_correct_for 'Macedonia', :samples => ['+389 2 123 4567',
325
325
  '+389 7 124 3456',
326
326
  '+389 7 234 5678']
327
- it_is_correct_for 'Madagascar', :samples => ['+261 20 012 345 678',
328
- '+261 20 124 3456',
329
- '+261 512 345 678',
330
- '+261 33 345 6789']
327
+ it_is_correct_for 'Madagascar', :samples => ['+261 20 23 456 78',
328
+ '+261 32 34 546 78',
329
+ '+261 33 34 546 78',
330
+ '+261 34 34 546 78',
331
+ '+261 38 34 546 78']
332
+ it 'is incorrect for Madagascar' do
333
+ Phony.plausible?('+261 20 012 345 678').should be_falsey
334
+ Phony.plausible?('+261 20 12 434 569').should be_falsey
335
+ Phony.plausible?('+261 51 23 4567 8').should be_falsey
336
+ Phony.plausible?('+261 34 345 46789').should be_falsey
337
+ Phony.plausible?('+261 34 345 467').should be_falsey
338
+ end
339
+
331
340
  it_is_correct_for 'Malawi', :samples => ['+265 1725 123',
332
341
  '+265 213 456 789',
333
342
  '+265 9123 456',
@@ -568,12 +577,12 @@ describe 'plausibility' do
568
577
  '+967 58 1234']
569
578
  it 'is correct for Zambia' do
570
579
  Phony.plausible?('+260 211 123456').should be_truthy # Fixed
571
- Phony.plausible?('+260 761 123456').should be_truthy # Mobile
572
- Phony.plausible?('+260 772 123456').should be_truthy # Mobile
573
- Phony.plausible?('+260 783 123456').should be_truthy # Mobile
574
- Phony.plausible?('+260 955 123456').should be_truthy # Mobile
575
- Phony.plausible?('+260 967 123456').should be_truthy # Mobile
576
- Phony.plausible?('+260 978 123456').should be_truthy # Mobile
580
+ Phony.plausible?('+260 96 512 4567').should be_truthy # MTN Mobile
581
+ Phony.plausible?('+260 97 712 3456').should be_truthy # Airtel Mobile
582
+ Phony.plausible?('+260 95 512 4567').should be_truthy # Zamtel Mobile
583
+ Phony.plausible?('+260 96 512 456').should be_falsy # MTN Mobile (Too short)
584
+ Phony.plausible?('+260 97 812 345').should be_falsy # Airtel Mobile (Too short)
585
+ Phony.plausible?('+260 95 512 345').should be_falsy # Zamtel Mobile (Too short)
577
586
  Phony.plausible?('+260 800 123 456').should be_truthy # Toll free
578
587
  end
579
588
  it_is_correct_for 'Zimbabwe', :samples => [['+263 2582 123 456', '+263 2582 123'],
@@ -851,9 +851,9 @@ describe 'country descriptions' do
851
851
  end
852
852
  describe 'Zambia' do
853
853
  it_splits '260211123456', ['260', '211', '123456'] # Fixed
854
- it_splits '260955123456', ['260', '955', '123456'] # Mobile
855
- it_splits '260967123456', ['260', '967', '123456'] # Mobile
856
- it_splits '260978123456', ['260', '978', '123456'] # Mobile
854
+ it_splits '260955123456', ['260', '95', '512', '3456'] # Mobile
855
+ it_splits '260967123456', ['260', '96', '712', '3456'] # Mobile
856
+ it_splits '260978123456', ['260', '97', '812', '3456'] # Mobile
857
857
  it_splits '260800123456', ['260', '800', '123', '456'] # Toll free
858
858
  end
859
859
  describe 'New Zealand' do
@@ -1053,9 +1053,10 @@ describe 'country descriptions' do
1053
1053
  it_splits '218911234456', %w(218 91 1234 456)
1054
1054
  end
1055
1055
  describe 'Madagascar' do
1056
- it_splits '26120012345678', ['261', false, '20', '012', '345', '678']
1057
- it_splits '261201243456', ['261', false, *%w(20 124 3456)]
1058
- it_splits '261512345678', ['261', false, *%w(512 345 678)]
1056
+ it_splits '261202254716', ['261', '20', *%w(22 547 16)]
1057
+ it_splits '261320254716', ['261', '32', *%w(02 547 16)]
1058
+ it_splits '261330254716', ['261', '33', *%w(02 547 16)]
1059
+ it_splits '261340254716', ['261', '34', *%w(02 547 16)]
1059
1060
  end
1060
1061
  describe 'Malawi' do
1061
1062
  it_splits '2651725123', ['265', false, '1725', '123']
@@ -1429,6 +1430,14 @@ describe 'country descriptions' do
1429
1430
  it_splits number, ['263', prefix, '234', '5678']
1430
1431
  end
1431
1432
  end
1433
+
1434
+ describe 'Universal International Freephone' do
1435
+ it_splits '80012345678', ['800', false, '12345678']
1436
+ end
1437
+
1438
+ describe 'Shared-Cost Service' do
1439
+ it_splits '80812345678', ['808', false, '12345678']
1440
+ end
1432
1441
  end
1433
1442
 
1434
1443
  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
4
+ version: 2.19.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2022-01-25 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.0.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