phony 2.18.9 → 2.18.14

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: 062a3448529e9cd54a3b989ab0522ee2035821af37c7b194a1b3167bdb8f1693
4
- data.tar.gz: 6f2b104415be34d29daf0569326a5a7480c6e44f243533e5e0ed51dbe554c699
3
+ metadata.gz: aeda5c706089f2345c5d9a474749f8088a728adedd86f84ce69443540b57612e
4
+ data.tar.gz: 3d2fd865a0bbd0572a8444988e7c53809a0688e98b85b218191cfdbcfe96758c
5
5
  SHA512:
6
- metadata.gz: c1e05a38ac40ddf8b69792071ceaf62fe90a66f79ee0ba6992f6022a4ab88ff5d33d33fa9276612e135231f3554f01eb83f551b5c163e7e2f0faf8e0a52417d0
7
- data.tar.gz: d2f5667fd4d32a6bd33961eca81928c2140a5383837f4a027203cad67afa34107560ea80291f35fee06fce9a43417f8e4272cc08b436eed6d5036c9f0aa18769
6
+ metadata.gz: 301e5a05da90d67f3943ca07d3a42b9def5c4c138b534235152e80b7450068315f1b635fda959c7f6b550fa6e5901ccff0aae9eaeae5d5126aa04cd46e7963ab
7
+ data.tar.gz: bc888bc9e4aa0920f5ba53c1ff264317c7cecb762cfc7f1c386dfa62c6daf6b60218efc5a51725d65a2379f5ac024cbbe62899b6724dff8a96dc4326bad5688e
@@ -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) |
@@ -382,18 +383,24 @@ 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
- # Wikipedia says 3 4 split, many local number with no splitting
391
+ # 3 4 split for mobile and 1 digit NDC, 3 2 or 3 3 otherwise
392
+ # Many local numbers with no splitting
390
393
  #
391
- # mobile telephony number allocation taken from: http://www.ncc.gov.ng/index.php?option=com_content&view=article&id=113&Itemid=102
394
+ # mobile telephony number allocation taken from:
395
+ # https://www.ncc.gov.ng/technical-regulation/standards/numbering and
396
+ # https://www.itu.int/oth/T020200009C/en
392
397
  country '234',
393
- match(/^([7-9]0\d)\d+$/) >> split(3,4) | # Mobile
394
- match(/^(81\d)\d+$/) >> split(3,4) | # Mobile
395
- one_of('1', '2', '9') >> split(3,4) | # Lagos, Ibadan and Abuja
396
- fixed(2) >> split(3,4) # 2-digit NDC
398
+ match(/^([7-9]0\d)\d+$/) >> split(3,4) | # Mobile
399
+ match(/^(81\d)\d+$/) >> split(3,4) | # Mobile
400
+ one_of('1', '2') >> split(3,3..4) | # Lagos, Ibadan
401
+ one_of('9') >> split(3,4) | # Abuja
402
+ one_of((30..79).map(&:to_s)) >> split(3,2..3) | # 2-digit NDC
403
+ one_of(%w(82 83 84 85 86 87 88 89)) >> split(3,3) # 2-digit NDC
397
404
 
398
405
  country '235', none >> split(4,4) # Chad http://www.wtng.info/wtng-235-td.html
399
406
  country '236', none >> split(4,4) # Central African Republic http://www.wtng.info/wtng-236-cf.html
@@ -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
@@ -403,7 +403,7 @@ ndcs_with_5_subscriber_numbers = %w(
403
403
 
404
404
  Phony.define do
405
405
  country '81',
406
- trunk('0') |
406
+ trunk('0', :normalize => false, :format => true, :split => true) |
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) |
@@ -12,9 +12,9 @@ module Phony
12
12
  #
13
13
  # Phony.define.country ...
14
14
  #
15
- def self.define
15
+ def self.define(&block)
16
16
  dsl = DSL.new
17
- dsl.instance_eval(&Proc.new) if block_given?
17
+ dsl.instance_eval(&block) if block_given?
18
18
  dsl
19
19
  end
20
20
 
@@ -355,6 +355,11 @@ describe 'plausibility' do
355
355
  end
356
356
  it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
357
357
  it_is_correct_for 'Niger', :samples => '+227 1234 5678'
358
+ it_is_correct_for 'Nigeria', :samples => ['+234 807 059 1111',
359
+ '+234 811 234 5678',
360
+ '+234 64 830 00',
361
+ '+234 1 280 444',
362
+ '+234 85 123 456']
358
363
  it_is_correct_for 'Niue', :samples => '+683 3791'
359
364
  it_is_correct_for 'Oman', :samples => ['+968 24 423 123',
360
365
  '+968 25 423 123']
@@ -602,6 +607,7 @@ describe 'plausibility' do
602
607
  end
603
608
 
604
609
  it 'is correct for Philippine' do
610
+ Phony.plausible?('+63 2 89889999').should be_truthy
605
611
  Phony.plausible?('+63 976 1234567').should be_truthy # mobile phone with area code 9
606
612
  Phony.plausible?('+63 876 1234567').should be_truthy # mobile phone with area code 8
607
613
  end
@@ -105,6 +105,7 @@ describe 'country descriptions' do
105
105
  it_splits '3216473200', ['32', '16', '47', '32', '00'] # Leuven
106
106
  it_splits '32475279584', ['32', '475', '27', '95', '84'] # mobile
107
107
  it_splits '32468279584', ['32', '468', '27', '95', '84'] # mobile (Telenet)
108
+ it_splits '32455123456', ['32', '455', '12', '34', '56'] # mobile (Voo)
108
109
  it_splits '3270123123', ['32', '70', '123', '123'] # Bus Service?
109
110
  it_splits '3278123123', ['32', '78', '123', '123'] # National rate service
110
111
  it_splits '3290123123', ['32', '901', '23', '123'] # National rate service
@@ -214,6 +215,21 @@ describe 'country descriptions' do
214
215
  describe 'China' do
215
216
  it_splits '862112345678', ['86', '21', '1234', '5678'] # Shanghai
216
217
  it_splits '8675582193447', ['86', '755', '8219', '3447'] # Shenzhen
218
+ it_splits '869511234567', ['86', '951', '123', '4567'] # Yinchuan
219
+
220
+ context 'mobile numbers' do
221
+ %w{
222
+ 130 131 132 133 134 135 136 137 138 139
223
+ 145 146 147 148 149
224
+ 150 151 152 153 155 156 157 158 159
225
+ 162 165 166 167
226
+ 170 171 172 173 174 175 176 177 178
227
+ 180 181 182 183 184 185 186 187 188 189
228
+ 190 191 192 193 195 196 197 198 199
229
+ }.each do |prefix|
230
+ it_splits "86#{prefix}12345678", ['86', prefix, '1234', '5678']
231
+ end
232
+ end
217
233
  end
218
234
  describe 'Colombia' do
219
235
  it_splits '5711234567', ['57', '1', '123', '4567']
@@ -598,6 +614,7 @@ describe 'country descriptions' do
598
614
  end
599
615
  describe 'Philippines' do
600
616
  it_splits '6321234567', ['63', '2', '1234567']
617
+ it_splits '63289889999', ['63', '2', '89889999']
601
618
  it_splits '6321234567890', ['63', '2', '1234567890']
602
619
  it_splits '632123456789012', ['63', '2', '123456789012']
603
620
  it_splits '639121234567', ['63', '912', '1234567']
@@ -1103,6 +1120,8 @@ describe 'country descriptions' do
1103
1120
  describe 'Nigeria' do
1104
1121
  it_splits '23411231234', %w(234 1 123 1234) # Lagos
1105
1122
 
1123
+ it_splits '23445123456', %w(234 45 123 456) # Ogoja
1124
+
1106
1125
  # mobile numbers
1107
1126
  it_splits '2347007661234', %w(234 700 766 1234)
1108
1127
  it_splits '2347017661234', %w(234 701 766 1234)
@@ -147,9 +147,12 @@ describe Phony::CountryCodes do
147
147
  it "should format luxembourgian numbers" do
148
148
  @countries.formatted('35227855', :format => :international).should eql '+352 27 85 5'
149
149
  end
150
- it "should format nigerian numbers" do
150
+ it "should format nigerian lagosian numbers" do
151
151
  @countries.formatted('23414480000', :format => :international).should eql '+234 1 448 0000'
152
152
  end
153
+ it "should format nigerian beninese numbers" do
154
+ @countries.formatted('23452123456', :format => :international).should eql '+234 52 123 456'
155
+ end
153
156
  it "should format nigerian mobile numbers" do
154
157
  @countries.formatted('2347061234567', :format => :international).should eql '+234 706 123 4567'
155
158
  end
@@ -89,4 +89,4 @@ describe Phony::Country do
89
89
  end
90
90
  end
91
91
 
92
- end
92
+ 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.18.9
4
+ version: 2.18.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-09 00:00:00.000000000 Z
11
+ date: 2020-06-11 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