phony 2.18.18 → 2.18.23

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: 35e5d35fc8879631ec6f0602d0d5cb1e006790c2332a8f4ff536066bc2a5f3c4
4
- data.tar.gz: 302dbb2edb99ea91db4556161535c28b38d66726e1899197d8396baa41eec63f
3
+ metadata.gz: db67ba76e70a6de9c44cc306e4e07eac25c092b456b7a89fbbccd4f5298172b0
4
+ data.tar.gz: f94e5219ec1808746635853d3cafdca6c91895330bf6b201b259301736b3e3eb
5
5
  SHA512:
6
- metadata.gz: 4e87c3f22321a3c86093f607ee00316ad0ff4fae588f309bd8ff8b609a125deda1199fe1db5b53f166a318aeaa46704eecf8f70ec53de1c97402e7c8ba8eb44b
7
- data.tar.gz: d9a68e78d43829f1f7e7b42602adee5cc3c3c57ad83aa8b879e55fa7e75136a54b34ed7e5f73e5fe0651bc7cfdc1e0f12f5d6497609ad10f8571092f7c7c7f81
6
+ metadata.gz: 1119176e19553809a782b8300f263a4791bdb0cd45cf82356ba9dff7871ddc31866628de206734d830a6730eadd8cf1c0286aad0b8342ce95e0cbeb8383647ac
7
+ data.tar.gz: 1e2eaf69ad9f1b5d2160c0ad7b1b720f54d51c9ad2fcf9708fb23bf43ef91ddb812571a5962e7808ba3c309657acfc5849b95ed788bad629a953a6cf5c3e016f
@@ -352,13 +352,13 @@ Phony.define do
352
352
 
353
353
  # Côte d'Ivoire
354
354
  # http://www.wtng.info/wtng-225-ci.html
355
- # http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000310001PDFE.pdf
355
+ # https://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000310006PDFE.pdf
356
356
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Ivory_Coast
357
357
  #
358
358
  # There is no trunk code for this country and several of the mobile prefixes start with 0
359
359
  country '225',
360
360
  trunk('', :normalize => false) |
361
- fixed(2) >> split(2,2,2)
361
+ fixed(2) >> split(2,2,2,2)
362
362
 
363
363
  country '226', none >> split(4,4) # Burkina Faso http://www.wtng.info/wtng-226-bf.html
364
364
  country '227', none >> split(4,4) # Niger http://www.wtng.info/wtng-227-ne.html
@@ -432,9 +432,9 @@ Phony.define do
432
432
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Rwanda
433
433
  country '250',
434
434
  trunk('0') |
435
- one_of('25') >> split(7) | # Geographic, fixed
436
- match(/^(7[238])/) >> split(7) | # Non-geographic, mobile
437
- one_of('06') >> split(6) # Satellite
435
+ one_of('25') >> split(7) | # Geographic, fixed
436
+ match(/^(7[2389])/) >> split(7) | # Non-geographic, mobile
437
+ one_of('06') >> split(6) # Satellite
438
438
 
439
439
  country '251', fixed(2) >> split(3, 4) # Ethiopia http://www.wtng.info/wtng-251-et.html
440
440
 
@@ -403,7 +403,7 @@ ndcs_with_5_subscriber_numbers = %w(
403
403
 
404
404
  Phony.define do
405
405
  country '81',
406
- trunk('0', :normalize => false, :format => true, :split => true) |
406
+ trunk('0') |
407
407
  one_of('20', '50', '60', '70', '90') >> split(4,4) | # mobile, VoIP telephony
408
408
  one_of(ndcs_with_5_subscriber_numbers) >> split(1,4) |
409
409
  one_of(ndcs_with_6_subscriber_numbers) >> split(2,4) |
@@ -8,6 +8,9 @@ Phony.define do
8
8
  trunk('0') |
9
9
  one_of(%w(800)) >> split(3,2) | # freephone
10
10
  one_of(%w(808)) >> split(3,2) | # payphone
11
+ one_of(%w(677 678)) >> matched_split(
12
+ /\A\d{4}\z/ => [3],
13
+ /\A\d+\z/ => [3,3]) |
11
14
  one_of(%w(230)) >> matched_split(
12
15
  /\A\d{4}\z/ => [4],
13
16
  /\A\d+\z/ => [3,2]) |
@@ -21,6 +24,7 @@ Phony.define do
21
24
  one_of(%w(72)) >> split(3,3) | # ISP
22
25
  one_of(%w(60 61 68 69)) >> matched_split(
23
26
  /\A\d{3}\z/ => [3],
27
+ /\A\d{6}\z/ => [3,3],
24
28
  /\A\d{7}\z/ => [3,4],
25
29
  /\A\d+\z/ => [3,3,4]) | # mobile, voicemail (mobile)
26
30
  one_of(%w(66 63)) >> matched_split(
@@ -40,4 +44,4 @@ Phony.define do
40
44
  fixed(2) >> matched_split(
41
45
  /\A\d{5}\z/ => [3,2],
42
46
  /\A\d+\z/ => [3,3])
43
- end
47
+ end
@@ -192,7 +192,7 @@ describe 'plausibility' do
192
192
  Phony.plausible?('+385 60 12 345').should be_truthy # Premium rate
193
193
  Phony.plausible?('+385 62 123 456').should be_truthy # Premium, personal and UAN
194
194
  end
195
- it_is_correct_for "Côte d'Ivoire", :samples => '+225 9358 8764'
195
+ it_is_correct_for "Côte d'Ivoire", :samples => '+225 01 9358 8764'
196
196
  it_is_correct_for 'Democratic Republic of Timor-Leste', :samples => ['+670 465 7886', '+670 7465 7886']
197
197
  it_is_correct_for 'Democratic Republic of the Congo', :samples => '+243 80 864 9794'
198
198
  it_is_correct_for 'Diego Garcia', :samples => '+246 123 7686'
@@ -399,6 +399,12 @@ describe 'plausibility' do
399
399
  '+507 6 123 4567',
400
400
  '+507 2 123 456']
401
401
  it_is_correct_for 'Reunion / Mayotte (new)', :samples => '+262 295 276 964'
402
+ it_is_correct_for 'Rwanda', :samples => ['+250 72 1234567',
403
+ '+250 73 1234567',
404
+ '+250 78 1234567',
405
+ '+250 79 1234567',
406
+ '+250 25 1234567',
407
+ '+250 06 123456']
402
408
  it_is_correct_for 'Saint Helena', :samples => '+290 5134'
403
409
  it_is_correct_for 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)', :samples => '+508 474 714'
404
410
  it_is_correct_for 'Salvador (El)', :samples => [
@@ -427,8 +433,10 @@ describe 'plausibility' do
427
433
  ['+381 11 123 456', '+381 11 123 4567'],
428
434
  '+381 72 123 456',
429
435
  '+381 60 123',
430
- '+381 60 123 4567',
436
+ ['+381 60 123 4567', '+381 69 123 456'],
431
437
  '+381 42 123 456',
438
+ '+381 677 123 456',
439
+ '+381 678 123 456',
432
440
  '+381 9 123 4567',
433
441
  '+381 60 123',
434
442
  '+381 60 123 456 7890',
@@ -677,6 +677,7 @@ describe 'country descriptions' do
677
677
  it_splits '250781234567', ['250', '78', '1234567'] # mobile
678
678
  it_splits '250721234567', ['250', '72', '1234567'] # mobile
679
679
  it_splits '250731234567', ['250', '73', '1234567'] # mobile
680
+ it_splits '250791234567', ['250', '79', '1234567'] # mobile
680
681
  it_splits '250251234567', ['250', '25', '1234567'] # fixed
681
682
  it_splits '25006123456', ['250', '06', '123456'] # fixed
682
683
  end
@@ -895,8 +896,8 @@ describe 'country descriptions' do
895
896
  it_splits '50622345678', %w(506 2 234 5678)
896
897
  end
897
898
  describe "Côte d'Ivoire" do
898
- it_splits '22507335518', ['225', '07', '33', '55', '18']
899
- it_splits '22537335518', ['225', '37', '33', '55', '18']
899
+ it_splits '2250107335518', ['225', '01', '07', '33', '55', '18']
900
+ it_splits '2250237335518', ['225', '02', '37', '33', '55', '18']
900
901
  end
901
902
  describe 'Democratic Republic of Timor-Leste' do
902
903
  it_splits '6701742945', ['670', false, '174', '2945']
@@ -1,32 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Phony::CountryCodes do
4
-
5
- before(:all) do
6
- @countries = Phony::CountryCodes.instance
7
- end
4
+
5
+ let(:countries) { Phony::CountryCodes.instance }
8
6
 
9
7
  describe '#[]' do
10
8
  it 'returns a country' do
11
- @countries['41'].class.should eql Phony::Country
9
+ countries['41'].class.should eql Phony::Country
12
10
  end
13
11
  end
14
12
 
15
13
  describe '#country_for' do
16
14
  it 'returns a country' do
17
- @countries.send(:country_for, '41').class.should eql Phony::Country
15
+ countries.send(:country_for, '41').class.should eql Phony::Country
18
16
  end
19
17
  end
20
18
 
21
19
  describe '#countrify' do
22
20
  it 'returns a country' do
23
- @countries.send(:countrify, '441231212', '41').should eql '41441231212'
21
+ countries.send(:countrify, '441231212', '41').should eql '41441231212'
24
22
  end
25
23
  end
26
24
  describe '#countrify!' do
27
25
  it 'in-place replaces the number' do
28
26
  number = '441231212'
29
- @countries.send(:countrify!, number, '41').should eql number
27
+ countries.send(:countrify!, number, '41').should eql number
30
28
 
31
29
  number.should == '41441231212'
32
30
  end
@@ -34,127 +32,127 @@ describe Phony::CountryCodes do
34
32
 
35
33
  describe '#vanity?' do
36
34
  it 'returns true if so' do
37
- @countries.vanity?('1800HELLOES').should eql true
35
+ countries.vanity?('1800HELLOES').should eql true
38
36
  end
39
37
  it 'returns false if not' do
40
- @countries.vanity?('18001234567').should eql false
38
+ countries.vanity?('18001234567').should eql false
41
39
  end
42
40
  end
43
41
 
44
42
  describe 'normalize' do
45
43
  it 'normalizes correctly' do
46
- @countries.normalize('0041-44-364-35-32').should eql '41443643532'
44
+ countries.normalize('0041-44-364-35-32').should eql '41443643532'
47
45
  end
48
46
  it 'normalizes correctly with CC option' do
49
- @countries.normalize('044-364-35-32', cc: '41').should eql '41443643532'
47
+ countries.normalize('044-364-35-32', cc: '41').should eql '41443643532'
50
48
  end
51
49
 
52
50
  context 'specific countries' do
53
51
  it 'handles Congo correctly' do
54
- @countries.normalize('+242 0571 73992').should eql '242057173992'
55
- @countries.normalize('+242 2221 15932').should eql '242222115932'
52
+ countries.normalize('+242 0571 73992').should eql '242057173992'
53
+ countries.normalize('+242 2221 15932').should eql '242222115932'
56
54
  end
57
55
  end
58
56
  end
59
57
 
60
58
  describe 'formatted' do
61
59
  it 'formats correctly' do
62
- @countries.formatted('41443643532', :format => :international, :spaces => :-).should eql '+41-44-364-35-32'
60
+ countries.formatted('41443643532', :format => :international, :spaces => :-).should eql '+41-44-364-35-32'
63
61
  end
64
62
  it 'formats correctly' do
65
- @countries.formatted('41443643532', :format => :international_relative, :spaces => :-).should eql '0041-44-364-35-32'
63
+ countries.formatted('41443643532', :format => :international_relative, :spaces => :-).should eql '0041-44-364-35-32'
66
64
  end
67
65
  it 'formats correctly' do
68
- @countries.formatted('41443643532', :format => :national, :spaces => :-).should eql '044-364-35-32'
66
+ countries.formatted('41443643532', :format => :national, :spaces => :-).should eql '044-364-35-32'
69
67
  end
70
68
  context 'specific' do
71
69
  it 'formats Ireland correctly' do
72
- @countries.formatted("3533451234", :format => :national).should eql '0345 1234'
70
+ countries.formatted("3533451234", :format => :national).should eql '0345 1234'
73
71
  end
74
72
  it 'formats Ireland correctly' do
75
- @countries.formatted("353411231234", :format => :national).should eql '041 123 1234'
73
+ countries.formatted("353411231234", :format => :national).should eql '041 123 1234'
76
74
  end
77
75
  it 'formats Spain correctly' do
78
- @countries.formatted("34123456789", :format => :national).should eql '123 456 789'
76
+ countries.formatted("34123456789", :format => :national).should eql '123 456 789'
79
77
  end
80
78
  it 'formats Cambodia correctly' do
81
- @countries.formatted('85512239123', :format => :national).should eql '012 239 123'
79
+ countries.formatted('85512239123', :format => :national).should eql '012 239 123'
82
80
  end
83
81
  it 'formats the US correctly' do
84
- @countries.formatted('18005551212', :format => :national, :spaces => :-).should eql '(800)-555-1212'
82
+ countries.formatted('18005551212', :format => :national, :spaces => :-).should eql '(800)-555-1212'
85
83
  end
86
84
  it 'formats the US correctly' do
87
- @countries.formatted('18005551212', :format => :national, :spaces => :-).should eql '(800)-555-1212'
85
+ countries.formatted('18005551212', :format => :national, :spaces => :-).should eql '(800)-555-1212'
88
86
  end
89
87
  end
90
88
  context 'default' do
91
89
  it "should format swiss numbers" do
92
- @countries.formatted('41443643532').should eql '+41 44 364 35 32'
90
+ countries.formatted('41443643532').should eql '+41 44 364 35 32'
93
91
  end
94
92
  it "should format swiss service numbers" do
95
- @countries.formatted('41800112233').should eql '+41 800 112 233'
93
+ countries.formatted('41800112233').should eql '+41 800 112 233'
96
94
  end
97
95
  it "should format austrian numbers" do
98
- @countries.formatted('43198110').should eql '+43 1 98110'
96
+ countries.formatted('43198110').should eql '+43 1 98110'
99
97
  end
100
98
  it "should format american numbers" do
101
- @countries.formatted('18705551122').should eql '+1 (870) 555-1122'
99
+ countries.formatted('18705551122').should eql '+1 (870) 555-1122'
102
100
  end
103
101
  it "should format irish numbers" do
104
- @countries.formatted('35311234567').should eql '+353 1 123 4567'
102
+ countries.formatted('35311234567').should eql '+353 1 123 4567'
105
103
  end
106
104
  end
107
105
  describe "international" do
108
106
  it "should format north american numbers" do
109
- @countries.formatted('18091231234', :format => :international).should eql '+1 (809) 123-1234'
107
+ countries.formatted('18091231234', :format => :international).should eql '+1 (809) 123-1234'
110
108
  end
111
109
  it "should format austrian numbers" do
112
- @countries.formatted('43198110', :format => :international).should eql '+43 1 98110'
110
+ countries.formatted('43198110', :format => :international).should eql '+43 1 98110'
113
111
  end
114
112
  it "should format austrian numbers" do
115
- @countries.formatted('43198110', :format => :international_absolute).should eql '+43 1 98110'
113
+ countries.formatted('43198110', :format => :international_absolute).should eql '+43 1 98110'
116
114
  end
117
115
  it "should format french numbers" do
118
- @countries.formatted('33142278186', :format => :+).should eql '+33 1 42 27 81 86'
116
+ countries.formatted('33142278186', :format => :+).should eql '+33 1 42 27 81 86'
119
117
  end
120
118
  it "should format austrian numbers" do
121
- @countries.formatted('43198110', :format => :international_relative).should eql '0043 1 98110'
119
+ countries.formatted('43198110', :format => :international_relative).should eql '0043 1 98110'
122
120
  end
123
121
  it 'should format liechtensteiner numbers' do
124
- @countries.formatted('4233841148', :format => :international_relative).should eql '00423 384 11 48'
122
+ countries.formatted('4233841148', :format => :international_relative).should eql '00423 384 11 48'
125
123
  end
126
124
  it "should format irish numbers" do
127
- @countries.formatted('35311234567', :format => :international).should eql '+353 1 123 4567'
125
+ countries.formatted('35311234567', :format => :international).should eql '+353 1 123 4567'
128
126
  end
129
127
  it "should format luxembourgian numbers" do
130
- @countries.formatted('352222809', :format => :international).should eql '+352 22 28 09'
128
+ countries.formatted('352222809', :format => :international).should eql '+352 22 28 09'
131
129
  end
132
130
  it "should format luxembourgian 4-digit ndc numbers" do
133
- @countries.formatted('35226222809', :format => :international).should eql '+352 2622 28 09'
131
+ countries.formatted('35226222809', :format => :international).should eql '+352 2622 28 09'
134
132
  end
135
133
  it "should format luxembourgian mobile numbers" do
136
- @countries.formatted('352621123456', :format => :international).should eql '+352 621 123 456'
134
+ countries.formatted('352621123456', :format => :international).should eql '+352 621 123 456'
137
135
  end
138
136
  it "should format luxembourgian city numbers" do
139
- @countries.formatted('3524123456', :format => :international).should eql '+352 41 23 45 6'
137
+ countries.formatted('3524123456', :format => :international).should eql '+352 41 23 45 6'
140
138
  end
141
139
  it "should format luxembourgian machine to machine numbers" do
142
- @countries.formatted('352602112345678', :format => :international).should eql '+352 6021 12 34 56 78'
140
+ countries.formatted('352602112345678', :format => :international).should eql '+352 6021 12 34 56 78'
143
141
  end
144
142
  it "should format luxembourgian numbers" do
145
- @countries.formatted('352370431', :format => :international).should eql '+352 37 04 31'
143
+ countries.formatted('352370431', :format => :international).should eql '+352 37 04 31'
146
144
  end
147
145
  it "should format luxembourgian numbers" do
148
- @countries.formatted('35227855', :format => :international).should eql '+352 27 85 5'
146
+ countries.formatted('35227855', :format => :international).should eql '+352 27 85 5'
149
147
  end
150
148
  it "should format nigerian lagosian numbers" do
151
- @countries.formatted('23414480000', :format => :international).should eql '+234 1 448 0000'
149
+ countries.formatted('23414480000', :format => :international).should eql '+234 1 448 0000'
152
150
  end
153
151
  it "should format nigerian beninese numbers" do
154
- @countries.formatted('23452123456', :format => :international).should eql '+234 52 123 456'
152
+ countries.formatted('23452123456', :format => :international).should eql '+234 52 123 456'
155
153
  end
156
154
  it "should format nigerian mobile numbers" do
157
- @countries.formatted('2347061234567', :format => :international).should eql '+234 706 123 4567'
155
+ countries.formatted('2347061234567', :format => :international).should eql '+234 706 123 4567'
158
156
  end
159
157
  context 'with no spaces' do
160
158
  it "should format north american numbers" 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.18
4
+ version: 2.18.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-02 00:00:00.000000000 Z
11
+ date: 2021-06-08 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