phony 2.17.1 → 2.18.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +29 -5
- data/lib/phony.rb +62 -57
- data/lib/phony/config.rb +91 -0
- data/lib/phony/countries.rb +8 -13
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +2 -0
- data/lib/phony/countries/bangladesh.rb +2 -0
- data/lib/phony/countries/belarus.rb +2 -0
- data/lib/phony/countries/brazil.rb +2 -0
- data/lib/phony/countries/cambodia.rb +2 -0
- data/lib/phony/countries/china.rb +2 -0
- data/lib/phony/countries/croatia.rb +2 -0
- data/lib/phony/countries/georgia.rb +2 -0
- data/lib/phony/countries/germany.rb +4 -1
- data/lib/phony/countries/guinea.rb +8 -5
- data/lib/phony/countries/india.rb +2 -0
- data/lib/phony/countries/indonesia.rb +2 -0
- data/lib/phony/countries/ireland.rb +25 -23
- data/lib/phony/countries/italy.rb +6 -1
- data/lib/phony/countries/japan.rb +2 -0
- data/lib/phony/countries/kyrgyzstan.rb +2 -0
- data/lib/phony/countries/latvia.rb +2 -0
- data/lib/phony/countries/libya.rb +2 -0
- data/lib/phony/countries/malaysia.rb +2 -0
- data/lib/phony/countries/moldova.rb +2 -0
- data/lib/phony/countries/montenegro.rb +2 -0
- data/lib/phony/countries/myanmar.rb +2 -0
- data/lib/phony/countries/namibia.rb +2 -0
- data/lib/phony/countries/nepal.rb +2 -0
- data/lib/phony/countries/netherlands.rb +2 -0
- data/lib/phony/countries/pakistan.rb +2 -0
- data/lib/phony/countries/paraguay.rb +2 -0
- data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +2 -0
- data/lib/phony/countries/saudi_arabia.rb +2 -0
- data/lib/phony/countries/serbia.rb +2 -0
- data/lib/phony/countries/somalia.rb +2 -0
- data/lib/phony/countries/south_korea.rb +7 -2
- data/lib/phony/countries/sweden.rb +2 -0
- data/lib/phony/countries/taiwan.rb +2 -0
- data/lib/phony/countries/tajikistan.rb +2 -0
- data/lib/phony/countries/turkmenistan.rb +2 -0
- data/lib/phony/countries/ukraine.rb +2 -0
- data/lib/phony/countries/united_kingdom.rb +5 -2
- data/lib/phony/countries/uruguay.rb +2 -0
- data/lib/phony/countries/vietnam.rb +3 -1
- data/lib/phony/countries/zimbabwe.rb +2 -0
- data/lib/phony/country.rb +3 -1
- data/lib/phony/country_codes.rb +1 -1
- data/lib/phony/dsl.rb +3 -1
- data/spec/functional/config_spec.rb +44 -0
- data/spec/functional/plausibility_spec.rb +6 -1
- data/spec/lib/phony/countries_spec.rb +18 -15
- data/spec/lib/phony/dsl_spec.rb +2 -2
- data/spec/lib/phony/local_splitters/regex_spec.rb +7 -0
- metadata +6 -2
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
describe 'Phony::Config' do
|
4
|
+
describe 'load' do
|
5
|
+
before do
|
6
|
+
# NOTE We redefine Phony as if it was not loaded for this set of tests.
|
7
|
+
Object.__send__(:remove_const, :Phony) if Object.constants.include?(:Phony)
|
8
|
+
|
9
|
+
load 'phony/config.rb'
|
10
|
+
end
|
11
|
+
after(:all) do
|
12
|
+
# After running this suite, we load all of Phony for the following tests.
|
13
|
+
load 'phony/config.rb'
|
14
|
+
|
15
|
+
Phony::Config.load
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'does not fail when loading all' do
|
19
|
+
Phony::Config.load
|
20
|
+
|
21
|
+
Phony.split('15551115511').should == ['1', '555', '111', '5511']
|
22
|
+
end
|
23
|
+
it 'raises when a CC is used that has not been loaded.' do
|
24
|
+
Phony::Config.load('41')
|
25
|
+
|
26
|
+
expect { Phony.split('15551115511') }.to raise_error
|
27
|
+
end
|
28
|
+
it 'raises when a CC is used that has not been loaded.' do
|
29
|
+
Phony::Config.load(only: ['41'])
|
30
|
+
|
31
|
+
expect { Phony.split('15551115511') }.to raise_error
|
32
|
+
end
|
33
|
+
it 'raises when a CC is used that has not been loaded.' do
|
34
|
+
Phony::Config.load(except: ['1'])
|
35
|
+
|
36
|
+
expect { Phony.split('15551115511') }.to raise_error
|
37
|
+
end
|
38
|
+
it 'does not raise when a CC is used that has been loaded.' do
|
39
|
+
Phony::Config.load(except: ['41'])
|
40
|
+
|
41
|
+
Phony.split('15551115511').should == ['1', '555', '111', '5511']
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -251,7 +251,7 @@ describe 'plausibility' do
|
|
251
251
|
it_is_correct_for 'Gabonese Republic', :samples => '+241 1 627 739'
|
252
252
|
it_is_correct_for 'Gambia', :samples => '+220 989 5148'
|
253
253
|
it_is_correct_for 'Germany', :samples => [
|
254
|
-
'+49
|
254
|
+
'+49 1577 536 8701'
|
255
255
|
]
|
256
256
|
it_is_correct_for 'Georgia', :samples => ['+995 220 123 45',
|
257
257
|
'+995 32 123 4567',
|
@@ -598,6 +598,11 @@ describe 'plausibility' do
|
|
598
598
|
Phony.plausible?('+81 120 123 123').should be_truthy
|
599
599
|
Phony.plausible?('+81 800 123 1234').should be_truthy
|
600
600
|
end
|
601
|
+
|
602
|
+
it 'is correct for Philippine' do
|
603
|
+
Phony.plausible?('+63 976 1234567').should be_truthy # mobile phone with area code 9
|
604
|
+
Phony.plausible?('+63 876 1234567').should be_truthy # mobile phone with area code 8
|
605
|
+
end
|
601
606
|
end
|
602
607
|
end
|
603
608
|
end
|
@@ -33,13 +33,13 @@ describe 'country descriptions' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'Argentina' do
|
36
|
-
it_splits '541112345678', ['54', '11', '1234', '5678']
|
37
|
-
it_splits '542911234567', ['54', '291', '123', '4567']
|
38
|
-
it_splits '
|
39
|
-
it_splits '5491112345678', ['54', '911', '1234', '5678']
|
40
|
-
it_splits '5492201234567', ['54', '9220', '123', '4567']
|
41
|
-
it_splits '5492221123456', ['54', '92221', '12', '3456']
|
42
|
-
it_splits '548001234567', ['54', '800', '123', '4567']
|
36
|
+
it_splits '541112345678', ['54', '11', '1234', '5678'] # 2-digit area code / landline
|
37
|
+
it_splits '542911234567', ['54', '291', '123', '4567'] # 3-digit area code / landline
|
38
|
+
it_splits '542903123456', ['54', '2903', '12', '3456'] # 4-digit area code / landline
|
39
|
+
it_splits '5491112345678', ['54', '911', '1234', '5678'] # 2-digit area code / international mobile
|
40
|
+
it_splits '5492201234567', ['54', '9220', '123', '4567'] # 3-digit area code / international mobile
|
41
|
+
it_splits '5492221123456', ['54', '92221', '12', '3456'] # 4-digit area code / international mobile
|
42
|
+
it_splits '548001234567', ['54', '800', '123', '4567'] # Non-geographic number
|
43
43
|
end
|
44
44
|
|
45
45
|
describe 'Austria' do
|
@@ -291,7 +291,7 @@ describe 'country descriptions' do
|
|
291
291
|
it_splits '49800222340010', ['49', '800', '222', '340010'] # Service number
|
292
292
|
|
293
293
|
it_splits '4915111231234', ['49', '151', '1123', '1234'] # Mobile number
|
294
|
-
it_splits '4915771231234', ['49', '
|
294
|
+
it_splits '4915771231234', ['49', '1577', '123', '1234'] # Mobile number
|
295
295
|
it_splits '491601234567', ['49', '160', '1234', '567'] # Mobile number
|
296
296
|
it_splits '4916312345678', ['49', '163', '1234', '5678'] # Mobile number
|
297
297
|
it_splits '4915211231234', ['49', '1521', '123', '1234'] # Mobile number
|
@@ -401,6 +401,7 @@ describe 'country descriptions' do
|
|
401
401
|
it_splits '35311234567', ['353', '1', '123', '4567'] # Dublin, 7 digit subscriber #
|
402
402
|
it_splits '353539233333', ['353', '53', '923', '3333'] # Wexford, 7 digit subscriber
|
403
403
|
it_splits '3532212345', ['353', '22', '12345'] # Mallow, 5 digit subscriber #
|
404
|
+
it_splits '353441234567', ['353', '44', '123', '4567'] # Mullingar, Castlepollard, Tyrellspass 7 digit subscriber #
|
404
405
|
it_splits '35345123456', ['353', '45', '123456'] # Naas, 6 digit subscriber #
|
405
406
|
it_splits '353801234567', ['353', '80', '123', '4567'] # Mobile
|
406
407
|
it_splits '353761234567', ['353', '76', '123', '4567'] # VoIP
|
@@ -409,14 +410,16 @@ describe 'country descriptions' do
|
|
409
410
|
end
|
410
411
|
|
411
412
|
describe 'Israel (972)' do
|
412
|
-
it_splits '972100', ['972', '1', '00']
|
413
|
-
it_splits '97221231234', ['972', '2', '123', '1234']
|
414
|
-
it_splits '97282411234', ['972', '8', '241', '1234']
|
415
|
-
it_splits '97291231234', ['972', '9', '123', '1234']
|
416
|
-
it_splits '972501231234', ['972', '50', '123', '1234']
|
417
|
-
it_splits '972591231234', ['972', '59', '123', '1234']
|
418
|
-
it_splits '972771231234', ['972', '77', '123', '1234']
|
413
|
+
it_splits '972100', ['972', '1', '00'] # Police
|
414
|
+
it_splits '97221231234', ['972', '2', '123', '1234'] # Jerusalem Area
|
415
|
+
it_splits '97282411234', ['972', '8', '241', '1234'] # Gaza Strip (Palestine)
|
416
|
+
it_splits '97291231234', ['972', '9', '123', '1234'] # Sharon Area
|
417
|
+
it_splits '972501231234', ['972', '50', '123', '1234'] # Mobile (Pelephone)
|
418
|
+
it_splits '972591231234', ['972', '59', '123', '1234'] # Mobile Jawwal (Palestine)
|
419
|
+
it_splits '972771231234', ['972', '77', '123', '1234'] # Cable Phone Services
|
419
420
|
it_splits '9721700123123', ['972', '1', '700', '123', '123'] # Cable Phone Services
|
421
|
+
it_splits '972511234567', ['972', '51', '123', '4567'] # Mobile (We4G)
|
422
|
+
it_splits '972791111111', ['972', '79', '111', '1111'] # Landline (Hallo, Cellact, Telzar)
|
420
423
|
end
|
421
424
|
describe 'Israel (970)' do
|
422
425
|
it_splits '97021231234', ['970', '2', '123', '1234'] # Jerusalem Area
|
data/spec/lib/phony/dsl_spec.rb
CHANGED
@@ -16,8 +16,8 @@ describe Phony::DSL do
|
|
16
16
|
it 'checks for ( in regex' do
|
17
17
|
expect { dsl.match(/123/) }.to raise_error("Regexp /123/ needs a group in it that defines which digits belong to the NDC.")
|
18
18
|
end
|
19
|
-
it '
|
20
|
-
dsl.match(/(123)/).should
|
19
|
+
it 'should return a Phony::NationalSplitters::Regex' do
|
20
|
+
dsl.match(/(123)/).class.name.should == Phony::NationalSplitters::Regex.name
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -1,7 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
main = self
|
4
|
+
|
3
5
|
describe Phony::LocalSplitters::Regex do
|
4
6
|
|
7
|
+
before do
|
8
|
+
load 'spec_helper_extensions.rb'
|
9
|
+
main.send :include, SpecHelperExtensions
|
10
|
+
end
|
11
|
+
|
5
12
|
describe 'instance_for' do
|
6
13
|
it 'does not cache' do
|
7
14
|
described_class.instance_for({}).should_not equal(described_class.instance_for({}))
|
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.
|
4
|
+
version: 2.18.5
|
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-06-28 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
|
@@ -21,7 +21,9 @@ extra_rdoc_files:
|
|
21
21
|
files:
|
22
22
|
- README.textile
|
23
23
|
- lib/phony.rb
|
24
|
+
- lib/phony/config.rb
|
24
25
|
- lib/phony/countries.rb
|
26
|
+
- lib/phony/countries/argentina.rb
|
25
27
|
- lib/phony/countries/austria.rb
|
26
28
|
- lib/phony/countries/bangladesh.rb
|
27
29
|
- lib/phony/countries/belarus.rb
|
@@ -77,6 +79,7 @@ files:
|
|
77
79
|
- lib/phony/national_splitters/variable.rb
|
78
80
|
- lib/phony/trunk_code.rb
|
79
81
|
- lib/phony/vanity.rb
|
82
|
+
- spec/functional/config_spec.rb
|
80
83
|
- spec/functional/plausibility_spec.rb
|
81
84
|
- spec/lib/phony/countries_spec.rb
|
82
85
|
- spec/lib/phony/country_codes_spec.rb
|
@@ -132,4 +135,5 @@ test_files:
|
|
132
135
|
- spec/lib/phony/local_splitters/regex_spec.rb
|
133
136
|
- spec/lib/phony/local_splitters/fixed_spec.rb
|
134
137
|
- spec/lib/phony/vanity_spec.rb
|
138
|
+
- spec/functional/config_spec.rb
|
135
139
|
- spec/functional/plausibility_spec.rb
|