phony 2.5.3 → 2.5.4
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 +8 -8
- data/lib/phony/countries/germany.rb +46 -43
- data/spec/functional/normalize_spec.rb +9 -9
- data/spec/functional/plausibility_spec.rb +4 -1
- data/spec/lib/phony/countries_spec.rb +15 -11
- data/spec/lib/phony_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjgwYTAxZTZiNTRiOTViNDdiZDI5OTA4ZmE3Nzc5MmQ4NjM2Y2IxYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTM2M2M1NmE3YmZhZTg4MDM2MGY3ZTlkYmU4ZmQzMGRjNGViMzdkYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWY2NWYyNjlhMTFmOWZhZDM3YWZiNTM1NjVmNGU1ZWIxYTQ4NWJmOGEyYjZl
|
10
|
+
ZTg5NDYwNjg3NDBmODRhYjYzMjk0ZWVjZDFiOTU2MTYyNWIyMWFmNjg3YTcy
|
11
|
+
Mjk4ZmQ1NzIzZmY1MjJkYzI4ZGU2OWZhMmJkZjczYjU5YTAwYjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzRiZjM0ZDUxNTE3OThiMzQyM2VkMDJjMjUwNjE0ZDU5MzhhYTIwYTZmNjM5
|
14
|
+
NWY5MzA5NWUzMmYzYTNiODg3OTdjMTRjZTBhNTE3YmM3MDc5OTAxODQ2MDc5
|
15
|
+
ZTQzZGQ3MWU2MmE5MWYzZDcxNGVlYWM3MGEzM2IyNDU4ZDgxYTE=
|
@@ -71,8 +71,6 @@ ndcs3 = [
|
|
71
71
|
'661', # Fulda
|
72
72
|
'671', # Bad Kreuznach
|
73
73
|
'681', # Saarbrücken
|
74
|
-
'700', # Personal Numbers
|
75
|
-
'701', # Personal Numbers, reserved
|
76
74
|
'711', # Stuttgart
|
77
75
|
'721', # Karlsruhe
|
78
76
|
'731', # Ulm
|
@@ -82,8 +80,6 @@ ndcs3 = [
|
|
82
80
|
'771', # Donaueschingen
|
83
81
|
'781', # Offenburg
|
84
82
|
'791', # Schwäbisch Hall
|
85
|
-
'800', # Toll-Free Numbers
|
86
|
-
'801', # Toll-Free Numbers, reserved
|
87
83
|
'811', # Hallbergmoos
|
88
84
|
'821', # Augsburg
|
89
85
|
'831', # Kempten
|
@@ -92,8 +88,6 @@ ndcs3 = [
|
|
92
88
|
'861', # Traunstein
|
93
89
|
'871', # Landshut
|
94
90
|
'881', # Weilheim in Oberbayern
|
95
|
-
'900', # Premium Rate Numbers
|
96
|
-
'901', # Premium Rate Numbers, reserved
|
97
91
|
'902', # Replacement for 0137/0138
|
98
92
|
'906', # Donauwörth
|
99
93
|
'911', # Nürnberg
|
@@ -3992,34 +3986,44 @@ ndcs4 = [
|
|
3992
3986
|
'9977',
|
3993
3987
|
'9978',
|
3994
3988
|
]
|
3995
|
-
|
3996
|
-
|
3997
|
-
|
3998
|
-
|
3999
|
-
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
4003
|
-
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4018
|
-
|
4019
|
-
|
4020
|
-
|
4021
|
-
|
4022
|
-
|
3989
|
+
mobile_3digits = [
|
3990
|
+
'150', # Group3G/Quam
|
3991
|
+
'151', # T-Mobile
|
3992
|
+
'152', # Vodafone
|
3993
|
+
'155', # E-Plus
|
3994
|
+
'156', # Mobilcom
|
3995
|
+
'157', # E-Plus
|
3996
|
+
'159', # O2
|
3997
|
+
'160', # T-Mobile
|
3998
|
+
'161', # C-Netz
|
3999
|
+
'162', # Vodafone
|
4000
|
+
'163', # E-Plus
|
4001
|
+
'164', # Cityruf
|
4002
|
+
'165', # Quix
|
4003
|
+
'166', # Telmi
|
4004
|
+
'168', # Scall
|
4005
|
+
'169', # Cityruf, Scall, Skyper (e*cityruf, e*message, e*skyper)
|
4006
|
+
'170', # T-Mobile
|
4007
|
+
'171', # T-Mobile
|
4008
|
+
'172', # Vodafone
|
4009
|
+
'173', # Vodafone
|
4010
|
+
'174', # Vodafone
|
4011
|
+
'175', # T-Mobile
|
4012
|
+
'176', # O2 Germany
|
4013
|
+
'177', # E-Plus
|
4014
|
+
'178', # E-Plus
|
4015
|
+
'179', # O2 Germany
|
4016
|
+
]
|
4017
|
+
|
4018
|
+
mobile_4digits = [
|
4019
|
+
'1520', # Vodafone
|
4020
|
+
'1521', # Lycamobile
|
4021
|
+
'1522', # Vodafone
|
4022
|
+
'1570', # vistream
|
4023
|
+
'1527', # E-Plus
|
4024
|
+
'1672', # Dolphin Telecom
|
4025
|
+
]
|
4026
|
+
|
4023
4027
|
service = [
|
4024
4028
|
'12', # Innovative Services
|
4025
4029
|
'130',
|
@@ -4073,19 +4077,18 @@ service = [
|
|
4073
4077
|
# http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000510001PDFE.pdf
|
4074
4078
|
# "Numbers assigned in the past, which are generally grandfathered, may be as short as five digits."
|
4075
4079
|
#
|
4076
|
-
# http://www.bundesnetzagentur.de/
|
4080
|
+
# http://www.bundesnetzagentur.de/cln_1422/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/Rufnummern_node.html
|
4077
4081
|
#
|
4078
4082
|
# TODO Define lower end of last part correctly.
|
4079
4083
|
#
|
4080
4084
|
Phony.define do
|
4081
4085
|
country '49',
|
4082
4086
|
trunk('0', normalize: true) |
|
4083
|
-
one_of(service)
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4087
|
-
one_of(
|
4088
|
-
one_of(
|
4089
|
-
|
4090
|
-
fixed(5) >> split(3,0..7)
|
4087
|
+
one_of(*service) >> split(3,4) |
|
4088
|
+
one_of(*mobile_4digits) >> split(3,4) |
|
4089
|
+
one_of(*mobile_3digits) >> split(4,3..4) |
|
4090
|
+
one_of(*ndcs2) >> split(3,2..10) |
|
4091
|
+
one_of(*ndcs3) >> split(3,1..9) |
|
4092
|
+
one_of(*ndcs4) >> split(3,0..8) |
|
4093
|
+
fixed(5) >> split(3,0..7)
|
4091
4094
|
end
|
@@ -8,31 +8,31 @@ describe 'Phony#normalize' do
|
|
8
8
|
it '#151' do
|
9
9
|
# Normalizes, but this is a non-real case.
|
10
10
|
#
|
11
|
-
Phony.normalize('1-111-111-1111').should
|
12
|
-
Phony.normalize('111-111-1111', cc: '1').should
|
11
|
+
Phony.normalize('1-111-111-1111').should eql '1111111111'
|
12
|
+
Phony.normalize('111-111-1111', cc: '1').should eql '1111111111'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'handles the US (with cc) correctly' do
|
17
|
-
Phony.normalize('+1 724 999 9999').should
|
17
|
+
Phony.normalize('+1 724 999 9999').should eql '17249999999'
|
18
18
|
end
|
19
19
|
it 'handles the Dutch number (without US cc) correctly' do
|
20
|
-
Phony.normalize('310 5552121').should
|
20
|
+
Phony.normalize('310 5552121').should eql '315552121'
|
21
21
|
end
|
22
22
|
it 'handles the US (with cc and cc option) correctly' do
|
23
|
-
Phony.normalize('+1 724 999 9999', cc: '1').should
|
23
|
+
Phony.normalize('+1 724 999 9999', cc: '1').should eql '17249999999'
|
24
24
|
end
|
25
25
|
it 'handles the US (without cc) correctly' do
|
26
|
-
Phony.normalize('(310) 555-2121', cc: '1').should
|
26
|
+
Phony.normalize('(310) 555-2121', cc: '1').should eql '13105552121'
|
27
27
|
end
|
28
28
|
it 'handles a German number with extra (0)' do
|
29
|
-
Phony.normalize('+49 (0) 209 22 33 44 55').should
|
29
|
+
Phony.normalize('+49 (0) 209 22 33 44 55').should eql '4920922334455'
|
30
30
|
end
|
31
31
|
it 'handles a German number with extra 0' do
|
32
|
-
Phony.normalize('+49 0 209 22 33 44 55').should
|
32
|
+
Phony.normalize('+49 0 209 22 33 44 55').should eql '4920922334455'
|
33
33
|
end
|
34
34
|
it 'handles Cambodian numbers with an extra 0' do
|
35
|
-
Phony.normalize('+855012239134').should
|
35
|
+
Phony.normalize('+855012239134').should eql "85512239134"
|
36
36
|
end
|
37
37
|
it 'should normalize a too short number' do
|
38
38
|
Phony.normalize('+972').should eql '972'
|
@@ -332,6 +332,9 @@ describe 'plausibility' do
|
|
332
332
|
Phony.plausible?('+49 31234 123456').should be_true
|
333
333
|
Phony.plausible?('+49 7141 12345670').should be_true
|
334
334
|
Phony.plausible?('+49 1609 1234567').should be_true # Bug: https://github.com/floere/phony/issues/146
|
335
|
+
Phony.plausible?('+49 800 1234567').should be_true
|
336
|
+
Phony.plausible?('+49 1805 878323').should be_true
|
337
|
+
|
335
338
|
# Following tests implement specifications from
|
336
339
|
# http://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/ONRufnr/NummernplanOrtsnetzrufnummern.pdf?__blob=publicationFile&v=2 (04.24.2014)
|
337
340
|
# Page 3
|
@@ -507,7 +510,7 @@ describe 'plausibility' do
|
|
507
510
|
it_is_correct_for 'Gabonese Republic', :samples => '+241 1 627 739'
|
508
511
|
it_is_correct_for 'Gambia', :samples => '+220 989 5148'
|
509
512
|
it_is_correct_for 'Germany', :samples => [
|
510
|
-
'+
|
513
|
+
'+49 157 753 6870'
|
511
514
|
]
|
512
515
|
it_is_correct_for 'Georgia', :samples => ['+995 220 123 45',
|
513
516
|
'+995 32 123 4567',
|
@@ -207,18 +207,22 @@ describe 'country descriptions' do
|
|
207
207
|
it_splits '995596123456', %w(995 596 123 456)
|
208
208
|
end
|
209
209
|
describe 'Germany' do
|
210
|
-
it_splits '493038625454', ['49', '30', '386', '25454']
|
211
|
-
it_splits '4932221764542', ['49', '32', '221', '764542']
|
212
|
-
it_splits '4922137683323', ['49', '221', '376', '83323']
|
213
|
-
it_splits '497614767676', ['49', '761', '476', '7676']
|
214
|
-
it_splits '4921535100', ['49', '2153', '510', '0']
|
215
|
-
it_splits '493434144602', ['49', '34341', '446', '02']
|
216
|
-
|
217
|
-
it_splits '
|
218
|
-
it_splits '
|
210
|
+
it_splits '493038625454', ['49', '30', '386', '25454'] # Berlin
|
211
|
+
it_splits '4932221764542', ['49', '32', '221', '764542'] # Non-Geographical
|
212
|
+
it_splits '4922137683323', ['49', '221', '376', '83323'] # Cologne
|
213
|
+
it_splits '497614767676', ['49', '761', '476', '7676'] # Freiburg im Breisgau
|
214
|
+
it_splits '4921535100', ['49', '2153', '510', '0'] # Nettetal-Lobberich
|
215
|
+
it_splits '493434144602', ['49', '34341', '446', '02'] # Geithain
|
216
|
+
|
217
|
+
it_splits '491805878323', ['49', '180', '587', '8323'] # Service number
|
218
|
+
it_splits '491815878323', ['49', '181', '587', '8323'] # Service number
|
219
|
+
it_splits '498001234567', ['49', '800', '123', '4567'] # Service number
|
220
|
+
|
221
|
+
it_splits '4915111231234', ['49', '151', '1123', '1234'] # Mobile number
|
222
|
+
it_splits '4915771231234', ['49', '157', '7123', '1234'] # Mobile number
|
223
|
+
it_splits '491601234567', ['49', '160', '1234', '567'] # Mobile number
|
224
|
+
it_splits '4916312345678', ['49', '163', '1234', '5678'] # Mobile number
|
219
225
|
it_splits '4915211231234', ['49', '1521', '123', '1234'] # Mobile number
|
220
|
-
it_splits '4915771231234', ['49', '1577', '123', '1234'] # Mobile number
|
221
|
-
it_splits '4916312312345', ['49', '163', '123', '12345'] # Mobile number
|
222
226
|
end
|
223
227
|
describe 'Ghana' do
|
224
228
|
it_splits '233302123456', ['233', '30', '212', '3456'] # Mobile Vodafone, Accra
|
data/spec/lib/phony_spec.rb
CHANGED
@@ -6,8 +6,8 @@ describe Phony do
|
|
6
6
|
|
7
7
|
describe 'regression' do
|
8
8
|
it 'best effort #152' do
|
9
|
-
described_class.split('39694805123').should
|
10
|
-
described_class.format('39694805123').should
|
9
|
+
described_class.split('39694805123').should eql ['39', '694805123', []]
|
10
|
+
described_class.format('39694805123').should eql '+39 694805123 '
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
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.5.
|
4
|
+
version: 2.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-14 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
|