phony 2.19.1 → 2.19.5

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: cbadf1b4b8c2d79d7f32c069ee47175e879d57eaf582c93a6098efb068860945
4
- data.tar.gz: 644bf8449040256b95af0a1d47bcc15ce0ff35b8dfbc0ee36dd72bdaec20bc4c
3
+ metadata.gz: 992055cdb02a340ea072dfd5909e05fb5cab8bd2c223764539527a1b13635404
4
+ data.tar.gz: 2357031c39a1a1345fb84ef4800115f867c815627a018dc029660165f3f2c04c
5
5
  SHA512:
6
- metadata.gz: 994d683a1954d9136d9ee1fe9086e328c14b547c12db01beaf004c81beafa5625ae02f131269cfe6c945fb9666d544318663fa34b35f9d40a611066025583a82
7
- data.tar.gz: 43de3b0bf711cae8010b8b61c7c96b1ec89c88730044ae16acc68a6d866725e937811b33891a9663069f1f039d0c269fd1d1930413a168bce13957354694eba6
6
+ metadata.gz: 7a4c94d5e5af075704d1a4651160f98f00346a8885f4bb9a38b9d47bdec0749bb2c3b3442d3ece7e5fe9aa624e93ad21c26f780114c8e06a89de04ca2dd662dd
7
+ data.tar.gz: 38f16122cad2ee8b1ecdc909c12c3383d6a69072d5ddcbdfca49a88420df60d0e8874bb69f74b9da2804631951145625a4b843214ce925bdbc3a5b0e72d86426
@@ -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(
@@ -154,6 +154,7 @@ Phony.define do
154
154
  #
155
155
  country '41',
156
156
  trunk('0', normalize: true) |
157
+ match(/^(860)\d+$/) >> split(2, 3, 2, 2) | # Voice Mail access
157
158
  match(/^(8(?:00|4[0248]))\d+$/) >> split(3,3) | # Freecall/Shared Cost
158
159
  match(/^(90[016])\d+$/) >> split(3,3) | # Business
159
160
  fixed(2) >> split(3,2,2)
@@ -486,9 +487,9 @@ Phony.define do
486
487
  # http://www.wtng.info/wtng-260-zm.html
487
488
  # https://github.com/googlei18n/libphonenumber/
488
489
  country '260',
489
- match(/^(9(5[034589]|[67]\d))/) >> split(6) | # Mobile
490
- match(/^(800)/) >> split(3,3) | # Toll free
491
- match(/^(21[1-8])/) >> split(6) # Fixed
490
+ match(/^([79][5678]\d)/) >> split(6) | # Mobile
491
+ match(/^(800)/) >> split(3,3) | # Toll free
492
+ match(/^(21[1-8])/) >> split(6) # Fixed
492
493
 
493
494
  # Madagascar http://www.wtng.info/wtng-261-mg.html
494
495
  # http://www.itu.int/oth/T020200007F/en
@@ -992,7 +993,10 @@ Phony.define do
992
993
  country '698', todo # -
993
994
  country '699', todo # -
994
995
 
995
- country '800', todo # International Freephone Service
996
+ # International Freephone Service
997
+ # https://www.itu.int/en/ITU-T/inr/unum/Pages/uifn.aspx
998
+ country '800', none >> split(8)
999
+
996
1000
  country '801', todo # -
997
1001
  country '802', todo # -
998
1002
  country '803', todo # -
@@ -1000,7 +1004,7 @@ Phony.define do
1000
1004
  country '805', todo # -
1001
1005
  country '806', todo # -
1002
1006
  country '807', todo # -
1003
- country '808', todo # International Shared Cost Service (ISCS)
1007
+ country '808', none >> split(12) # International Shared Cost Service (ISCS)
1004
1008
  country '809', todo # -
1005
1009
 
1006
1010
  country '830', todo # -
data/lib/phony/country.rb CHANGED
@@ -97,6 +97,9 @@ module Phony
97
97
  end
98
98
  end
99
99
  def format_cc_ndc trunk, ndc, local, type, space, parentheses, use_trunk
100
+ # Note: We mark NDCs that are of type "none" with false (nil trips plausible?). This would result in false being printed.
101
+ # Therefore we set NDC to nil when formatting.
102
+ ndc = nil if ndc == false
100
103
  case type
101
104
  when String
102
105
  trunk &&= trunk.format(space, use_trunk)
@@ -125,6 +128,7 @@ module Phony
125
128
  end
126
129
  end
127
130
  def format_ndc ndc, parentheses
131
+ ndc = nil if ndc == false # TODO
128
132
  parentheses ? "(#{ndc})" : ndc
129
133
  end
130
134
  def format_with_ndc format, cc, ndc, local, space
@@ -31,9 +31,7 @@ module Phony
31
31
  # since using nil is dangerous and breaks
32
32
  # abstraction)
33
33
  #
34
- # Note: Actually, it might stay in.
35
- #
36
- # TODO Flip nil/false?
34
+ # Note: Decided it stays in. When formatting, it's turned into nil.
37
35
  #
38
36
  def split national_number
39
37
  [nil, false, national_number]
@@ -255,7 +255,7 @@ describe 'plausibility' do
255
255
  end
256
256
  # it_is_correct_for 'Gabonese Republic', :samples => [
257
257
  # '+241 1 627 739',
258
- # '+241 12 34 56 78',
258
+ # '+241 12 34 56 78',
259
259
  # ]
260
260
  it_is_correct_for 'Gambia', :samples => '+220 989 5148'
261
261
  it_is_correct_for 'Germany', :samples => [
@@ -568,6 +568,9 @@ describe 'plausibility' do
568
568
  '+967 58 1234']
569
569
  it 'is correct for Zambia' do
570
570
  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
571
574
  Phony.plausible?('+260 955 123456').should be_truthy # Mobile
572
575
  Phony.plausible?('+260 967 123456').should be_truthy # Mobile
573
576
  Phony.plausible?('+260 978 123456').should be_truthy # Mobile
@@ -762,6 +762,7 @@ describe 'country descriptions' do
762
762
  describe 'Switzerland' do
763
763
  it_splits '41443643532', ['41', '44', '364', '35', '32'] # Zurich (usually)
764
764
  it_splits '41800334455', ['41', '800', '334', '455'] # Service number
765
+ it_splits '41860443643532', ['41', '860', '44', '364', '35', '32'] # Voicemail access
765
766
  it_splits '41900123456', ['41', '900', '123', '456'] # Business Number
766
767
  it_splits '41901123456', ['41', '901', '123', '456'] # Business Number Entertainment
767
768
  it_splits '41906123456', ['41', '906', '123', '456'] # Business Number Adult Entertainment
@@ -1317,6 +1318,7 @@ describe 'country descriptions' do
1317
1318
  it_splits '88633123456', %w(886 3 312 3456)
1318
1319
  it_splits '88637123456', %w(886 37 12 3456)
1319
1320
  it_splits '88682712345', %w(886 82 71 2345)
1321
+ it_splits '886801123123', %w(886 801 123 123)
1320
1322
  it_splits '88689712345', %w(886 89 71 2345)
1321
1323
  it_splits '88682672345', %w(886 826 7 2345)
1322
1324
  it_splits '88683672345', %w(886 836 7 2345)
@@ -1427,6 +1429,14 @@ describe 'country descriptions' do
1427
1429
  it_splits number, ['263', prefix, '234', '5678']
1428
1430
  end
1429
1431
  end
1432
+
1433
+ describe 'Universal International Freephone' do
1434
+ it_splits '80012345678', ['800', false, '12345678']
1435
+ end
1436
+
1437
+ describe 'Shared-Cost Service' do
1438
+ it_splits '80812345678', ['808', false, '12345678']
1439
+ end
1430
1440
  end
1431
1441
 
1432
1442
  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.1
4
+ version: 2.19.5
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-06-09 00:00:00.000000000 Z
11
+ date: 2021-09-29 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