phony 2.18.12 → 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: eb28b6f9cce0d35aae61c35e0c45f2f7afce7fd6e1c39bf014e6242e8e6fbed6
4
- data.tar.gz: 4ab901070528ccb0c3dc5e1e0a0db329d85dfa4bf67c97af51fac0794b2d5bcb
3
+ metadata.gz: db67ba76e70a6de9c44cc306e4e07eac25c092b456b7a89fbbccd4f5298172b0
4
+ data.tar.gz: f94e5219ec1808746635853d3cafdca6c91895330bf6b201b259301736b3e3eb
5
5
  SHA512:
6
- metadata.gz: 8e9bdc965a6046a2ea6e8c4e5e94310dc2d6d1fac4e7640f4a13005d17784974efcaa462951aaabdb574ec0185ef10e850fb0120950ebb3ab86487afa9c2f095
7
- data.tar.gz: afb3c2b8fb427099a565369b6e2755dbb67502dc6116aabbfa34bfa74a68ea84231f188be016492ba210835cb6e6c894c0188cd6e39ae09d7875e24394603fcf
6
+ metadata.gz: 1119176e19553809a782b8300f263a4791bdb0cd45cf82356ba9dff7871ddc31866628de206734d830a6730eadd8cf1c0286aad0b8342ce95e0cbeb8383647ac
7
+ data.tar.gz: 1e2eaf69ad9f1b5d2160c0ad7b1b720f54d51c9ad2fcf9708fb23bf43ef91ddb812571a5962e7808ba3c309657acfc5849b95ed788bad629a953a6cf5c3e016f
@@ -71,6 +71,7 @@ six_digit_extended_range_mobile_prefixes = [
71
71
  ]
72
72
 
73
73
  seven_digit_mobile_prefixes = [
74
+ '18', # Seatel
74
75
  '31', # Metfone
75
76
  '38', # CooTel
76
77
  '39', # EMAXX
@@ -85,10 +86,6 @@ variable_length_extended_range_mobile_prefixes = [
85
86
  '12' # Mobitel
86
87
  ]
87
88
 
88
- mobile_prefixes_with_variable_length = [
89
- '18' # Seatel
90
- ]
91
-
92
89
  six_digit_total_single_digit_fixed_line_prefixes = [
93
90
  '2', # Telecom Cambodia
94
91
  '3', # Mobitel
@@ -126,7 +123,6 @@ seven_digit_total_double_digit_fixed_line_prefixes = [
126
123
 
127
124
  Phony.define do
128
125
  country '855', trunk('0', :normalize => true) |
129
- one_of(mobile_prefixes_with_variable_length) >> matched_split(/^9/ => [3, 4], /^[2-8]/ => [3, 3]) |
130
126
  one_of(variable_length_extended_range_mobile_prefixes) >> matched_split(/^1/ => [3, 4], /^[2-9]/ => [3, 3]) |
131
127
  one_of(six_digit_mobile_prefixes) >> matched_split(/^[2-9]/ => [3, 3]) |
132
128
  one_of(six_digit_extended_range_mobile_prefixes) >> matched_split(/^[1-9]/ => [3, 3]) |
@@ -19,7 +19,7 @@ ndcs = [
19
19
  '28', # Chengdu
20
20
  '29', # Xi'an
21
21
  ]
22
- mobile = %w{ 130 131 132 133 134 135 136 137 138 139 145 150 151 152 153 155 156 157 158 159 185 186 187 188 189 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 }
22
+ mobile = %w{ 130 131 132 133 134 135 136 137 138 139 145 146 147 148 149 150 151 152 153 155 156 157 158 159 162 165 166 167 170 171 172 173 174 175 176 177 178 180 181 182 183 184 185 186 187 188 189 190 191 192 193 195 196 197 198 199 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 }
23
23
  service = %w{ 110 114 119 120 122 999 } # Probably not exhaustive. TODO Look at http://www.eoc.com.cn/?action-viewnews-itemid-11493.
24
24
 
25
25
  Phony.define do
@@ -28,5 +28,8 @@ Phony.define do
28
28
  one_of(service) >> split(8) |
29
29
  one_of(mobile) >> split(4,4) |
30
30
  one_of(ndcs) >> split(4,4) |
31
- fixed(3) >> split(4,4)
31
+ fixed(3) >> matched_split(
32
+ /\A\d{7}\z/ => [3,4],
33
+ /\A\d{8}\z/ => [4,4]
34
+ )
32
35
  end
@@ -9,14 +9,14 @@
9
9
  #
10
10
  # References:
11
11
  # http://www.comreg.ie/_fileupload/publications/ComReg03147.pdf (2003)
12
+ # https://www.comreg.ie/media/dlm_uploads/2015/12/ComReg0804.pdf (2008)
12
13
  # http://www.comreg.ie/licensing_and_services/area_code_maps.552.1040.html
13
14
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_the_Republic_of_Ireland
14
15
  #
15
16
  ndcs_with_5_subscriber_digits = [
16
- '22', '23', '24', '25', '26', '27', '28', '29', # Mallow, Bandon, Youghal, Fermoy, Macroom, Bantry, Skibbereen, Kanturk
17
+ '22', '24', '25', '26', '27', '28', '29', # Mallow, Youghal, Fermoy, Macroom, Bantry, Skibbereen, Kanturk
17
18
  '402', # Arklow
18
19
  '404', # Wicklow
19
- '43', # Longford, Granard
20
20
  '47', # Monaghan, Clones
21
21
  '48', # Northern Ireland
22
22
  '502', # Portlaoise, Abbeyleix
@@ -24,12 +24,10 @@ ndcs_with_5_subscriber_digits = [
24
24
  '505', # Roscrea
25
25
  '506', # Tullamore
26
26
  '509', # Bin-
27
- '52', # Killenaule
28
27
  '54', # Legacy Ferns, Enniscorthy
29
28
  '55', # Legacy Gorey
30
29
  '62', # Tipperary, Cashel
31
30
  '63', # Charleville
32
- '64', # Killarney, Rathmore
33
31
  '67', # Nenagh
34
32
  '68', # Listowel
35
33
  '69', # Newcastle West
@@ -47,15 +45,19 @@ ndcs_with_6_subscriber_digits = [
47
45
  ndcs_with_7_subscriber_digits = [
48
46
  '1', # Dublin
49
47
  '21', # Cork, Coachford, Kinsale
48
+ '23', # Bandon
50
49
  '41', # Ardee
51
50
  '42', # Dundalk, Carrickmacross, Castleblaney
51
+ '43', # Longford, Granard
52
52
  '44', # Mullingar, Castlepollard, Tyrellspass
53
53
  '46', # Navan, Kells, Trim, Enfield, Edenderry
54
54
  '49', # Cavan, Cootehill, Oldcastle, Belturbet
55
+ '52', # Killenaule
55
56
  '53', # Wexford, Enniscorthy, Ferns, Gorey, Craanford
56
57
  '56', # Kilkenny, Castlecomer
57
58
  '58', # Dungarvan
58
59
  '59', # Carlow, Muine Bheag, Athy, Baltinglass
60
+ '64', # Killarney, Rathmore
59
61
  '65', # Ennistymon, Kilrush
60
62
  '66', # Tralee, Dingle, Killorglin, Cahirciveen
61
63
  '71', # Sligo, Manorhamilton, Carrick-on-Shannon
@@ -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
@@ -104,6 +104,7 @@ mobile = [
104
104
  '84', # Vinaphone
105
105
  '85', # Vinaphone
106
106
  '86', # Viettel
107
+ '87', # Itelecom
107
108
  '88', # Vinaphone
108
109
  '89', # MobiFone,
109
110
  '90', # MobiFone
@@ -102,7 +102,7 @@ Phony.define do
102
102
  match(/^(800|90\d)\d+$/) >> split(2,3) | # Toll free service and premium numbers
103
103
  match(/^(46[05678])\d{6}$/) >> split(2,2,2) | # Mobile (Lycamobile, Telenet, Join Experience, Proximus 0460)
104
104
  match(/^(4[789]\d)\d{6}$/) >> split(2,2,2) | # Mobile
105
- match(/^(456)\d{6}$/) >> split(2,2,2) | # Mobile Vikings
105
+ match(/^(45[56])\d{6}$/) >> split(2,2,2) | # Mobile Vikings and Voo
106
106
  one_of('2','3','4','9') >> split(3,2,2) | # Short NDCs
107
107
  fixed(2) >> split(2,2,2) # 2-digit NDCs
108
108
 
@@ -257,6 +257,7 @@ Phony.define do
257
257
  trunk('0') |
258
258
  # 7/10 digits for area code '2'.
259
259
  match(/\A(2)\d{10}\z/) >> split(10) |
260
+ match(/\A(2)\d{8}\z/) >> split(8) |
260
261
  one_of('2') >> split(7) |
261
262
  # mobile
262
263
  match(/\A([89]\d\d)\d{7}\z/) >> split(7) |
@@ -351,13 +352,13 @@ Phony.define do
351
352
 
352
353
  # Côte d'Ivoire
353
354
  # http://www.wtng.info/wtng-225-ci.html
354
- # 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
355
356
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Ivory_Coast
356
357
  #
357
358
  # There is no trunk code for this country and several of the mobile prefixes start with 0
358
359
  country '225',
359
360
  trunk('', :normalize => false) |
360
- fixed(2) >> split(2,2,2)
361
+ fixed(2) >> split(2,2,2,2)
361
362
 
362
363
  country '226', none >> split(4,4) # Burkina Faso http://www.wtng.info/wtng-226-bf.html
363
364
  country '227', none >> split(4,4) # Niger http://www.wtng.info/wtng-227-ne.html
@@ -382,8 +383,9 @@ Phony.define do
382
383
  # Ghana
383
384
  #
384
385
  # From http://www.itu.int/oth/T0202000052/en
386
+ # https://en.wikipedia.org/wiki/Telephone_numbers_in_Ghana
385
387
  #
386
- country '233', fixed(2) >> split(3,4)
388
+ country '233', trunk('0') | fixed(2) >> split(3,4)
387
389
 
388
390
  # Nigeria
389
391
  # 3 4 split for mobile and 1 digit NDC, 3 2 or 3 3 otherwise
@@ -395,6 +397,7 @@ Phony.define do
395
397
  country '234',
396
398
  match(/^([7-9]0\d)\d+$/) >> split(3,4) | # Mobile
397
399
  match(/^(81\d)\d+$/) >> split(3,4) | # Mobile
400
+ match(/^(91\d)\d+$/) >> split(3,4) | # Mobile
398
401
  one_of('1', '2') >> split(3,3..4) | # Lagos, Ibadan
399
402
  one_of('9') >> split(3,4) | # Abuja
400
403
  one_of((30..79).map(&:to_s)) >> split(3,2..3) | # 2-digit NDC
@@ -407,7 +410,9 @@ Phony.define do
407
410
  country '239', fixed(1) >> split(3,3) # Sao Tome and Principe, http://www.wtng.info/wtng-239-st.html
408
411
 
409
412
  country '240', none >> split(3,3,3) # Equatorial Guinea
410
- country '241', fixed(1) >> split(3,3) # Gabonese Republic http://www.wtng.info/wtng-241-ga.html
413
+ country '241',
414
+ match(/^(\d)\d{6}$/) >> split(3,3) | # Gabonese Republic http://www.wtng.info/wtng-241-ga.html
415
+ match(/^(\d\d)\d{6}$/) >> split(2,2,2) # 2019 update https://en.wikipedia.org/wiki/Telephone_numbers_in_Gabon
411
416
  country '242', # Congo http://www.wtng.info/wtng-242-cg.html
412
417
  trunk('', :normalize => false) |
413
418
  none >> split(4,5)
@@ -427,9 +432,9 @@ Phony.define do
427
432
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Rwanda
428
433
  country '250',
429
434
  trunk('0') |
430
- one_of('25') >> split(7) | # Geographic, fixed
431
- match(/^(7[238])/) >> split(7) | # Non-geographic, mobile
432
- 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
433
438
 
434
439
  country '251', fixed(2) >> split(3, 4) # Ethiopia http://www.wtng.info/wtng-251-et.html
435
440
 
@@ -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'
@@ -249,7 +249,14 @@ describe 'plausibility' do
249
249
  end
250
250
  it_is_correct_for 'French Guiana (French Department of)', :samples => '+594 594 123 456'
251
251
  it_is_correct_for "French Polynesia (Territoire français d'outre-mer)", :samples => '+689 87 27 84 00'
252
- it_is_correct_for 'Gabonese Republic', :samples => '+241 1 627 739'
252
+ it 'is correct for Gabon' do
253
+ Phony.plausible?('+241 1 627 739').should be_truthy
254
+ Phony.plausible?('+241 12 34 56 78').should be_truthy
255
+ end
256
+ # it_is_correct_for 'Gabonese Republic', :samples => [
257
+ # '+241 1 627 739',
258
+ # '+241 12 34 56 78',
259
+ # ]
253
260
  it_is_correct_for 'Gambia', :samples => '+220 989 5148'
254
261
  it_is_correct_for 'Germany', :samples => [
255
262
  '+49 69 155 1',
@@ -392,6 +399,12 @@ describe 'plausibility' do
392
399
  '+507 6 123 4567',
393
400
  '+507 2 123 456']
394
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']
395
408
  it_is_correct_for 'Saint Helena', :samples => '+290 5134'
396
409
  it_is_correct_for 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)', :samples => '+508 474 714'
397
410
  it_is_correct_for 'Salvador (El)', :samples => [
@@ -420,8 +433,10 @@ describe 'plausibility' do
420
433
  ['+381 11 123 456', '+381 11 123 4567'],
421
434
  '+381 72 123 456',
422
435
  '+381 60 123',
423
- '+381 60 123 4567',
436
+ ['+381 60 123 4567', '+381 69 123 456'],
424
437
  '+381 42 123 456',
438
+ '+381 677 123 456',
439
+ '+381 678 123 456',
425
440
  '+381 9 123 4567',
426
441
  '+381 60 123',
427
442
  '+381 60 123 456 7890',
@@ -607,6 +622,7 @@ describe 'plausibility' do
607
622
  end
608
623
 
609
624
  it 'is correct for Philippine' do
625
+ Phony.plausible?('+63 2 89889999').should be_truthy
610
626
  Phony.plausible?('+63 976 1234567').should be_truthy # mobile phone with area code 9
611
627
  Phony.plausible?('+63 876 1234567').should be_truthy # mobile phone with area code 8
612
628
  end
@@ -103,8 +103,16 @@ describe 'country descriptions' do
103
103
  it_splits '3295551914', ['32', '9', '555', '19', '14'] # Gent
104
104
  it_splits '3245551414', ['32', '4', '555', '14', '14'] # Liège
105
105
  it_splits '3216473200', ['32', '16', '47', '32', '00'] # Leuven
106
- it_splits '32475279584', ['32', '475', '27', '95', '84'] # mobile
107
- it_splits '32468279584', ['32', '468', '27', '95', '84'] # mobile (Telenet)
106
+ it_splits '32455123456', ['32', '455', '12', '34', '56'] # mobile (Voo)
107
+ it_splits '32456123456', ['32', '456', '12', '34', '56'] # mobile (MobileViking)
108
+ it_splits '32460123456', ['32', '460', '12', '34', '56'] # mobile (Proximus)
109
+ it_splits '32465123456', ['32', '465', '12', '34', '56'] # mobile (Lycamobile)
110
+ it_splits '32466123456', ['32', '466', '12', '34', '56'] # mobile (Vectone)
111
+ it_splits '32467123456', ['32', '467', '12', '34', '56'] # mobile (Telenet)
112
+ it_splits '32468123456', ['32', '468', '12', '34', '56'] # mobile (Telenet)
113
+ it_splits '32475123456', ['32', '475', '12', '34', '56'] # mobile (Proximus)
114
+ it_splits '32485123456', ['32', '485', '12', '34', '56'] # mobile (Telenet)
115
+ it_splits '32495123456', ['32', '495', '12', '34', '56'] # mobile (Orange)
108
116
  it_splits '3270123123', ['32', '70', '123', '123'] # Bus Service?
109
117
  it_splits '3278123123', ['32', '78', '123', '123'] # National rate service
110
118
  it_splits '3290123123', ['32', '901', '23', '123'] # National rate service
@@ -214,6 +222,21 @@ describe 'country descriptions' do
214
222
  describe 'China' do
215
223
  it_splits '862112345678', ['86', '21', '1234', '5678'] # Shanghai
216
224
  it_splits '8675582193447', ['86', '755', '8219', '3447'] # Shenzhen
225
+ it_splits '869511234567', ['86', '951', '123', '4567'] # Yinchuan
226
+
227
+ context 'mobile numbers' do
228
+ %w{
229
+ 130 131 132 133 134 135 136 137 138 139
230
+ 145 146 147 148 149
231
+ 150 151 152 153 155 156 157 158 159
232
+ 162 165 166 167
233
+ 170 171 172 173 174 175 176 177 178
234
+ 180 181 182 183 184 185 186 187 188 189
235
+ 190 191 192 193 195 196 197 198 199
236
+ }.each do |prefix|
237
+ it_splits "86#{prefix}12345678", ['86', prefix, '1234', '5678']
238
+ end
239
+ end
217
240
  end
218
241
  describe 'Colombia' do
219
242
  it_splits '5711234567', ['57', '1', '123', '4567']
@@ -598,6 +621,7 @@ describe 'country descriptions' do
598
621
  end
599
622
  describe 'Philippines' do
600
623
  it_splits '6321234567', ['63', '2', '1234567']
624
+ it_splits '63289889999', ['63', '2', '89889999']
601
625
  it_splits '6321234567890', ['63', '2', '1234567890']
602
626
  it_splits '632123456789012', ['63', '2', '123456789012']
603
627
  it_splits '639121234567', ['63', '912', '1234567']
@@ -653,6 +677,7 @@ describe 'country descriptions' do
653
677
  it_splits '250781234567', ['250', '78', '1234567'] # mobile
654
678
  it_splits '250721234567', ['250', '72', '1234567'] # mobile
655
679
  it_splits '250731234567', ['250', '73', '1234567'] # mobile
680
+ it_splits '250791234567', ['250', '79', '1234567'] # mobile
656
681
  it_splits '250251234567', ['250', '25', '1234567'] # fixed
657
682
  it_splits '25006123456', ['250', '06', '123456'] # fixed
658
683
  end
@@ -871,8 +896,8 @@ describe 'country descriptions' do
871
896
  it_splits '50622345678', %w(506 2 234 5678)
872
897
  end
873
898
  describe "Côte d'Ivoire" do
874
- it_splits '22507335518', ['225', '07', '33', '55', '18']
875
- 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']
876
901
  end
877
902
  describe 'Democratic Republic of Timor-Leste' do
878
903
  it_splits '6701742945', ['670', false, '174', '2945']
@@ -935,6 +960,7 @@ describe 'country descriptions' do
935
960
  end
936
961
  describe 'Gabonese Republic' do
937
962
  it_splits '2411834375', ['241', '1', '834', '375']
963
+ it_splits '24174012345', ['241', '74', '01', '23', '45']
938
964
  end
939
965
  describe 'Gambia' do
940
966
  it_splits '2206683355', ['220', false, '668', '3355']
@@ -1139,6 +1165,17 @@ describe 'country descriptions' do
1139
1165
  it_splits '2349087661234', %w(234 908 766 1234)
1140
1166
  it_splits '2349097661234', %w(234 909 766 1234)
1141
1167
 
1168
+ it_splits '2349107661234', %w(234 910 766 1234)
1169
+ it_splits '2349117661234', %w(234 911 766 1234)
1170
+ it_splits '2349127661234', %w(234 912 766 1234)
1171
+ it_splits '2349137661234', %w(234 913 766 1234)
1172
+ it_splits '2349147661234', %w(234 914 766 1234)
1173
+ it_splits '2349157661234', %w(234 915 766 1234)
1174
+ it_splits '2349167661234', %w(234 916 766 1234)
1175
+ it_splits '2349177661234', %w(234 917 766 1234)
1176
+ it_splits '2349187661234', %w(234 918 766 1234)
1177
+ it_splits '2349197661234', %w(234 919 766 1234)
1178
+
1142
1179
  it_splits '2348107661234', %w(234 810 766 1234)
1143
1180
  it_splits '2348117661234', %w(234 811 766 1234)
1144
1181
  it_splits '2348127661234', %w(234 812 766 1234)
@@ -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.12
4
+ version: 2.18.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-15 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
@@ -95,11 +95,11 @@ files:
95
95
  - spec/lib/phony/national_splitters/variable_spec.rb
96
96
  - spec/lib/phony/vanity_spec.rb
97
97
  - spec/lib/phony_spec.rb
98
- homepage: http://github.com/floere/phony
98
+ homepage: https://github.com/floere/phony
99
99
  licenses:
100
100
  - MIT
101
101
  metadata: {}
102
- post_install_message:
102
+ post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
105
105
  - lib
@@ -114,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.0.6
118
- signing_key:
117
+ rubygems_version: 3.0.3
118
+ signing_key:
119
119
  specification_version: 4
120
120
  summary: Fast international phone number (E164 standard) normalizing, splitting and
121
121
  formatting.