phony 2.18.7 → 2.18.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phony/countries.rb +13 -7
- data/lib/phony/countries/austria.rb +2 -2
- data/lib/phony/countries/japan.rb +1 -1
- data/lib/phony/dsl.rb +2 -2
- data/spec/functional/plausibility_spec.rb +7 -1
- data/spec/lib/phony/countries_spec.rb +2 -0
- data/spec/lib/phony/country_codes_spec.rb +4 -1
- data/spec/lib/phony/country_spec.rb +10 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb28b6f9cce0d35aae61c35e0c45f2f7afce7fd6e1c39bf014e6242e8e6fbed6
|
4
|
+
data.tar.gz: 4ab901070528ccb0c3dc5e1e0a0db329d85dfa4bf67c97af51fac0794b2d5bcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e9bdc965a6046a2ea6e8c4e5e94310dc2d6d1fac4e7640f4a13005d17784974efcaa462951aaabdb574ec0185ef10e850fb0120950ebb3ab86487afa9c2f095
|
7
|
+
data.tar.gz: afb3c2b8fb427099a565369b6e2755dbb67502dc6116aabbfa34bfa74a68ea84231f188be016492ba210835cb6e6c894c0188cd6e39ae09d7875e24394603fcf
|
data/lib/phony/countries.rb
CHANGED
@@ -386,14 +386,19 @@ Phony.define do
|
|
386
386
|
country '233', fixed(2) >> split(3,4)
|
387
387
|
|
388
388
|
# Nigeria
|
389
|
-
#
|
389
|
+
# 3 4 split for mobile and 1 digit NDC, 3 2 or 3 3 otherwise
|
390
|
+
# Many local numbers with no splitting
|
390
391
|
#
|
391
|
-
# mobile telephony number allocation taken from:
|
392
|
+
# mobile telephony number allocation taken from:
|
393
|
+
# https://www.ncc.gov.ng/technical-regulation/standards/numbering and
|
394
|
+
# https://www.itu.int/oth/T020200009C/en
|
392
395
|
country '234',
|
393
|
-
match(/^([7-9]0\d)\d+$/)
|
394
|
-
match(/^(81\d)\d+$/)
|
395
|
-
one_of('1', '2'
|
396
|
-
|
396
|
+
match(/^([7-9]0\d)\d+$/) >> split(3,4) | # Mobile
|
397
|
+
match(/^(81\d)\d+$/) >> split(3,4) | # Mobile
|
398
|
+
one_of('1', '2') >> split(3,3..4) | # Lagos, Ibadan
|
399
|
+
one_of('9') >> split(3,4) | # Abuja
|
400
|
+
one_of((30..79).map(&:to_s)) >> split(3,2..3) | # 2-digit NDC
|
401
|
+
one_of(%w(82 83 84 85 86 87 88 89)) >> split(3,3) # 2-digit NDC
|
397
402
|
|
398
403
|
country '235', none >> split(4,4) # Chad http://www.wtng.info/wtng-235-td.html
|
399
404
|
country '236', none >> split(4,4) # Central African Republic http://www.wtng.info/wtng-236-cf.html
|
@@ -731,11 +736,12 @@ Phony.define do
|
|
731
736
|
# Monaco
|
732
737
|
#
|
733
738
|
country '377',
|
734
|
-
one_of('6')
|
739
|
+
one_of('6') >> split(2,2,2,2) | # mobile
|
735
740
|
fixed(2) >> split(2,2,2)
|
736
741
|
|
737
742
|
# San Marino
|
738
743
|
country '378',
|
744
|
+
trunk('', :normalize => false) |
|
739
745
|
none >> matched_split(
|
740
746
|
/\A\d{6}\z/ => [3,3],
|
741
747
|
/\A\d+\z/ => [3,3,4]
|
@@ -85,7 +85,7 @@ service = [
|
|
85
85
|
'939'
|
86
86
|
]
|
87
87
|
|
88
|
-
# https://www.rtr.at/en/tk/E129/
|
88
|
+
# https://www.rtr.at/en/tk/E129/Austrian_Numbering_Plan_2011-03-30.pdf
|
89
89
|
#
|
90
90
|
# TODO Add more details.
|
91
91
|
#
|
@@ -97,7 +97,7 @@ Phony.define do
|
|
97
97
|
one_of('800') >> split(6..10) | # Free number length is 9..13
|
98
98
|
one_of(corporate_2digit) >> split(3..11) | # Corporate number length is 5..13
|
99
99
|
one_of(corporate) >> split(2..10) | # Corporate number length is 5..13
|
100
|
-
one_of(ndcs) >> split(
|
100
|
+
one_of(ndcs) >> split(5..10) |
|
101
101
|
one_of('663') >> split(6..8) | # 6..8 digit mobile.
|
102
102
|
one_of(mobile) >> split(4,3..9) |
|
103
103
|
one_of(mobile_2digit) >> split(7..7) | # Separate as mobile contains 676 - 67 violates the prefix rule.
|
@@ -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) |
|
data/lib/phony/dsl.rb
CHANGED
@@ -46,7 +46,8 @@ describe 'plausibility' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'specific countries' do
|
49
|
-
it_is_correct_for 'Austria', :samples => '+43 720 116987' # VoIP
|
49
|
+
it_is_correct_for 'Austria', :samples => ['+43 720 116987', # VoIP
|
50
|
+
'+43 463 12345'] # Klagenfurt
|
50
51
|
it_is_correct_for 'Bosnia and Herzegovina', :samples => ['+387 66 666 666',
|
51
52
|
'+387 37 123 456',
|
52
53
|
'+387 33 222 111']
|
@@ -354,6 +355,11 @@ describe 'plausibility' do
|
|
354
355
|
end
|
355
356
|
it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
|
356
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']
|
357
363
|
it_is_correct_for 'Niue', :samples => '+683 3791'
|
358
364
|
it_is_correct_for 'Oman', :samples => ['+968 24 423 123',
|
359
365
|
'+968 25 423 123']
|
@@ -1103,6 +1103,8 @@ describe 'country descriptions' do
|
|
1103
1103
|
describe 'Nigeria' do
|
1104
1104
|
it_splits '23411231234', %w(234 1 123 1234) # Lagos
|
1105
1105
|
|
1106
|
+
it_splits '23445123456', %w(234 45 123 456) # Ogoja
|
1107
|
+
|
1106
1108
|
# mobile numbers
|
1107
1109
|
it_splits '2347007661234', %w(234 700 766 1234)
|
1108
1110
|
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
|
@@ -23,7 +23,7 @@ describe Phony::Country do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'regression' do
|
26
|
-
describe '
|
26
|
+
describe 'Iceland' do
|
27
27
|
let(:country) do
|
28
28
|
national_splitter = Phony::NationalSplitters::None.instance_for
|
29
29
|
local_splitter = Phony::LocalSplitters::Fixed.instance_for [3, 4]
|
@@ -35,6 +35,14 @@ describe Phony::Country do
|
|
35
35
|
country.split('112').should == [nil, false, '112']
|
36
36
|
end
|
37
37
|
end
|
38
|
+
describe 'San Marino' do
|
39
|
+
it 'normalizes correctly' do
|
40
|
+
Phony.normalize('+3780549903549').should == '3780549903549'
|
41
|
+
end
|
42
|
+
xit 'automatically adds the sole NC' do
|
43
|
+
Phony.normalize('+378903549').should == '3780549903549'
|
44
|
+
end
|
45
|
+
end
|
38
46
|
end
|
39
47
|
|
40
48
|
context "without special cases (with switzerland)" do
|
@@ -81,4 +89,4 @@ describe Phony::Country do
|
|
81
89
|
end
|
82
90
|
end
|
83
91
|
|
84
|
-
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.
|
4
|
+
version: 2.18.12
|
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
|
+
date: 2019-12-15 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
|
@@ -114,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
|
118
|
-
rubygems_version: 2.7.6
|
117
|
+
rubygems_version: 3.0.6
|
119
118
|
signing_key:
|
120
119
|
specification_version: 4
|
121
120
|
summary: Fast international phone number (E164 standard) normalizing, splitting and
|