phony 2.19.5 → 2.19.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 992055cdb02a340ea072dfd5909e05fb5cab8bd2c223764539527a1b13635404
4
- data.tar.gz: 2357031c39a1a1345fb84ef4800115f867c815627a018dc029660165f3f2c04c
3
+ metadata.gz: 30b195be2f2aafc2cda3d6f6f32f1f8b5c5af7dc11d63e03cb329fb4fdf40556
4
+ data.tar.gz: 6f4cc992009707e109eb9c50efea3b6c38fd2c7452434d23aa44b401559ffd1c
5
5
  SHA512:
6
- metadata.gz: 7a4c94d5e5af075704d1a4651160f98f00346a8885f4bb9a38b9d47bdec0749bb2c3b3442d3ece7e5fe9aa624e93ad21c26f780114c8e06a89de04ca2dd662dd
7
- data.tar.gz: 38f16122cad2ee8b1ecdc909c12c3383d6a69072d5ddcbdfca49a88420df60d0e8874bb69f74b9da2804631951145625a4b843214ce925bdbc3a5b0e72d86426
6
+ metadata.gz: 77892f621ff0ad9455ad7eabaf6a8f2beee67f79fc09ade1913295c92f649e4c5790a5dc6336a32cb095f136b0bf46c2f9a1582f196ee8a988d4465ea1640a02
7
+ data.tar.gz: 6f585de726af1584d89eeec8dd41e6dbb25cf740acf144149ada1a8bd5d461149c8eea341629fe0746fbecfecab38990eb0dc5b992efe7c94832fae6472c41f4
@@ -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+$/) >> split(3,3) | # Premium and national rate Services
102
- match(/^(800|90\d)\d+$/) >> split(2,3) | # Toll free service and premium numbers
103
- match(/^(46[05678])\d{6}$/) >> split(2,2,2) | # Mobile (Lycamobile, Telenet, Join Experience, Proximus 0460)
104
- match(/^(4[789]\d)\d{6}$/) >> split(2,2,2) | # Mobile
105
- match(/^(45[56])\d{6}$/) >> split(2,2,2) | # Mobile Vikings and Voo
106
- one_of('2','3','4','9') >> split(3,2,2) | # Short NDCs
107
- fixed(2) >> split(2,2,2) # 2-digit NDCs
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
  #
@@ -486,27 +487,31 @@ Phony.define do
486
487
  # Zambia
487
488
  # http://www.wtng.info/wtng-260-zm.html
488
489
  # https://github.com/googlei18n/libphonenumber/
490
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Zambia
489
491
  country '260',
490
- match(/^([79][5678]\d)/) >> split(6) | # Mobile
492
+ trunk('0') |
493
+ match(/^(76|77|95|96|97)/) >> split(3, 4) | # Mobile
491
494
  match(/^(800)/) >> split(3,3) | # Toll free
492
495
  match(/^(21[1-8])/) >> split(6) # Fixed
493
496
 
494
- # Madagascar http://www.wtng.info/wtng-261-mg.html
497
+ # Madagascar
498
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Madagascar
495
499
  # http://www.itu.int/oth/T020200007F/en
496
500
  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
- )
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
510
515
 
511
516
  country '262', # Reunion / Mayotte (new) http://www.wtng.info/wtng-262-fr.html
512
517
  trunk('0') |
@@ -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'],
@@ -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)
@@ -851,9 +852,9 @@ describe 'country descriptions' do
851
852
  end
852
853
  describe 'Zambia' do
853
854
  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
855
+ it_splits '260955123456', ['260', '95', '512', '3456'] # Mobile
856
+ it_splits '260967123456', ['260', '96', '712', '3456'] # Mobile
857
+ it_splits '260978123456', ['260', '97', '812', '3456'] # Mobile
857
858
  it_splits '260800123456', ['260', '800', '123', '456'] # Toll free
858
859
  end
859
860
  describe 'New Zealand' do
@@ -1053,9 +1054,10 @@ describe 'country descriptions' do
1053
1054
  it_splits '218911234456', %w(218 91 1234 456)
1054
1055
  end
1055
1056
  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)]
1057
+ it_splits '261202254716', ['261', '20', *%w(22 547 16)]
1058
+ it_splits '261320254716', ['261', '32', *%w(02 547 16)]
1059
+ it_splits '261330254716', ['261', '33', *%w(02 547 16)]
1060
+ it_splits '261340254716', ['261', '34', *%w(02 547 16)]
1059
1061
  end
1060
1062
  describe 'Malawi' do
1061
1063
  it_splits '2651725123', ['265', false, '1725', '123']
@@ -1433,7 +1435,7 @@ describe 'country descriptions' do
1433
1435
  describe 'Universal International Freephone' do
1434
1436
  it_splits '80012345678', ['800', false, '12345678']
1435
1437
  end
1436
-
1438
+
1437
1439
  describe 'Shared-Cost Service' do
1438
1440
  it_splits '80812345678', ['808', false, '12345678']
1439
1441
  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.5
4
+ version: 2.19.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: 2021-09-29 00:00:00.000000000 Z
11
+ date: 2022-02-15 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