phony 2.18.10 → 2.18.15

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: 65cd9d252c032ff5116a79fa6e5b670f7d482d16534c43d2369c951aeaa01003
4
- data.tar.gz: b1be2f32723b945d1854ea7b613e3121b95c5870e4704b3f0c42833f9c524271
3
+ metadata.gz: d8b68b69c83acc6190f9fc36b4d9d3b0db6878ddc4bdb2c7cfabae8a77ee3ddc
4
+ data.tar.gz: 1552ef3d9749adde09192d5951218ec399aac9bfe7d5a40c6c5ac50cac6003be
5
5
  SHA512:
6
- metadata.gz: e12dd75c0642fb9b50527957dbeb470fbc831e732f4e54b1a8ceafe05970db355ed0d4b4097f43bbb7ea98ca99d28aea382b10c51a345bf94976df981666c9e4
7
- data.tar.gz: 40d2961f1b3fec24505c376deb4252253af59c71eeda0c6b1bb35b4f5bce41a7c8ea99ad4a233e40974bc7cce6f2ae8dd403febf3f09006b4c69fb045635c3a9
6
+ metadata.gz: 375e4422e3e19806732fb2ccfee87905754b56822538ae2eaf357d3e9fdc6d3d3cbdf800d10ea202c45f9c5bfc5cd3fd634f40964b5248fe6bd46c1632aef4c7
7
+ data.tar.gz: 75f9f196bf936e481741a1c9f45f23bcc0d695843288505a57467d01edc8d0cdc1daa898083e12d402b582f0b8b46c22413d9b94e58714fe54bbed6cd352ab60
@@ -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,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
@@ -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
@@ -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
 
@@ -607,6 +607,7 @@ describe 'plausibility' do
607
607
  end
608
608
 
609
609
  it 'is correct for Philippine' do
610
+ Phony.plausible?('+63 2 89889999').should be_truthy
610
611
  Phony.plausible?('+63 976 1234567').should be_truthy # mobile phone with area code 9
611
612
  Phony.plausible?('+63 876 1234567').should be_truthy # mobile phone with area code 8
612
613
  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']
@@ -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.10
4
+ version: 2.18.15
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-20 00:00:00.000000000 Z
11
+ date: 2020-07-12 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