phony 2.20.13 → 2.20.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phony/config.rb +25 -26
- data/lib/phony/countries/argentina.rb +311 -314
- data/lib/phony/countries/austria.rb +71 -72
- data/lib/phony/countries/bangladesh.rb +27 -28
- data/lib/phony/countries/belarus.rb +110 -111
- data/lib/phony/countries/brazil.rb +92 -92
- data/lib/phony/countries/cambodia.rb +9 -9
- data/lib/phony/countries/china.rb +22 -21
- data/lib/phony/countries/croatia.rb +6 -5
- data/lib/phony/countries/georgia.rb +84 -84
- data/lib/phony/countries/germany.rb +4067 -4068
- data/lib/phony/countries/guinea.rb +8 -8
- data/lib/phony/countries/india.rb +31 -34
- data/lib/phony/countries/indonesia.rb +57 -46
- data/lib/phony/countries/ireland.rb +4 -5
- data/lib/phony/countries/italy.rb +54 -53
- data/lib/phony/countries/japan.rb +456 -456
- data/lib/phony/countries/kyrgyzstan.rb +109 -109
- data/lib/phony/countries/latvia.rb +34 -34
- data/lib/phony/countries/libya.rb +106 -106
- data/lib/phony/countries/malaysia.rb +12 -12
- data/lib/phony/countries/moldova.rb +42 -42
- data/lib/phony/countries/montenegro.rb +24 -20
- data/lib/phony/countries/myanmar.rb +39 -39
- data/lib/phony/countries/namibia.rb +35 -29
- data/lib/phony/countries/nepal.rb +60 -62
- data/lib/phony/countries/netherlands.rb +13 -13
- data/lib/phony/countries/pakistan.rb +135 -111
- data/lib/phony/countries/paraguay.rb +135 -135
- data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +125 -128
- data/lib/phony/countries/saudi_arabia.rb +5 -5
- data/lib/phony/countries/serbia.rb +47 -39
- data/lib/phony/countries/somalia.rb +18 -18
- data/lib/phony/countries/south_korea.rb +16 -13
- data/lib/phony/countries/sweden.rb +28 -28
- data/lib/phony/countries/taiwan.rb +20 -19
- data/lib/phony/countries/tajikistan.rb +70 -70
- data/lib/phony/countries/turkmenistan.rb +65 -65
- data/lib/phony/countries/ukraine.rb +607 -607
- data/lib/phony/countries/united_kingdom.rb +66 -66
- data/lib/phony/countries/uruguay.rb +40 -41
- data/lib/phony/countries/vietnam.rb +18 -17
- data/lib/phony/countries/zimbabwe.rb +31 -31
- data/lib/phony/countries.rb +440 -443
- data/lib/phony/country.rb +42 -44
- data/lib/phony/country_codes.rb +61 -60
- data/lib/phony/dsl.rb +23 -26
- data/lib/phony/local_splitters/fixed.rb +20 -29
- data/lib/phony/local_splitters/regex.rb +28 -31
- data/lib/phony/national_code.rb +7 -10
- data/lib/phony/national_splitters/default.rb +9 -11
- data/lib/phony/national_splitters/dsl.rb +8 -18
- data/lib/phony/national_splitters/fixed.rb +11 -14
- data/lib/phony/national_splitters/none.rb +7 -11
- data/lib/phony/national_splitters/regex.rb +13 -17
- data/lib/phony/national_splitters/variable.rb +36 -38
- data/lib/phony/trunk_code.rb +16 -18
- data/lib/phony/vanity.rb +12 -13
- data/lib/phony.rb +84 -84
- metadata +5 -39
- data/spec/functional/config_spec.rb +0 -44
- data/spec/functional/plausibility_spec.rb +0 -689
- data/spec/lib/phony/countries_spec.rb +0 -1459
- data/spec/lib/phony/country_codes_spec.rb +0 -227
- data/spec/lib/phony/country_spec.rb +0 -104
- data/spec/lib/phony/dsl_spec.rb +0 -28
- data/spec/lib/phony/local_splitters/fixed_spec.rb +0 -56
- data/spec/lib/phony/local_splitters/regex_spec.rb +0 -94
- data/spec/lib/phony/national_code_spec.rb +0 -61
- data/spec/lib/phony/national_splitters/default_spec.rb +0 -34
- data/spec/lib/phony/national_splitters/fixed_spec.rb +0 -45
- data/spec/lib/phony/national_splitters/none_spec.rb +0 -28
- data/spec/lib/phony/national_splitters/regex_spec.rb +0 -23
- data/spec/lib/phony/national_splitters/variable_spec.rb +0 -35
- data/spec/lib/phony/trunk_code_spec.rb +0 -85
- data/spec/lib/phony/vanity_spec.rb +0 -30
- data/spec/lib/phony_spec.rb +0 -70
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::NationalSplitters::Regex do
|
4
|
-
|
5
|
-
describe 'instance_for' do
|
6
|
-
it 'caches correctly (not)' do
|
7
|
-
described_class.instance_for(//).should_not equal(described_class.instance_for(//))
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'split' do
|
12
|
-
context 'without on_fail' do
|
13
|
-
let(:splitter) { described_class.instance_for(/^(123)\d+$/) }
|
14
|
-
end
|
15
|
-
context 'with on_fail 2' do
|
16
|
-
let(:splitter) { described_class.instance_for(/^(123)\d+$/, 2) }
|
17
|
-
it 'uses the on_fail_take' do
|
18
|
-
splitter.split('23456789').should == [nil, '23', '456789']
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::NationalSplitters::Variable do
|
4
|
-
|
5
|
-
describe 'split' do
|
6
|
-
context 'normal' do
|
7
|
-
let(:splitter) { Phony::NationalSplitters::Variable.new 4, ['1', '316', '67', '68', '669', '711'] }
|
8
|
-
it "handles Vienna" do
|
9
|
-
expect(splitter.split('198110')).to eq [nil, '1', '98110']
|
10
|
-
end
|
11
|
-
it "handles some mobile services" do
|
12
|
-
expect(splitter.split('66914093902')).to eq [nil, '669', '14093902']
|
13
|
-
end
|
14
|
-
it "handles Graz" do
|
15
|
-
expect(splitter.split('3161234567891')).to eq [nil, '316', '1234567891']
|
16
|
-
end
|
17
|
-
it "handles Rohrau" do
|
18
|
-
expect(splitter.split('2164123456789')).to eq [nil, '2164', '123456789']
|
19
|
-
end
|
20
|
-
it 'has an NDC length of 3' do
|
21
|
-
expect(splitter.length).to eq (1..3)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
context 'special handling for using the variable size splitter for Swiss service numbers' do
|
25
|
-
let(:splitter) { Phony::NationalSplitters::Variable.new 2, ['800'] }
|
26
|
-
it "should handle swiss service numbers" do
|
27
|
-
expect(splitter.split('800223344')).to eq [nil, '800', '223344']
|
28
|
-
end
|
29
|
-
it 'has an NDC length of 3' do
|
30
|
-
expect(splitter.length).to eq (3..3)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::TrunkCode do
|
4
|
-
|
5
|
-
describe '#format' do
|
6
|
-
it 'is correct' do
|
7
|
-
code = described_class.new('0')
|
8
|
-
expect(code.format('%s %s')).to eq '0'
|
9
|
-
end
|
10
|
-
it 'is correct' do
|
11
|
-
code = described_class.new('0', format: true)
|
12
|
-
expect(code.format('%s %s')).to eq '0'
|
13
|
-
end
|
14
|
-
it 'is correct' do
|
15
|
-
code = described_class.new('0', format: false)
|
16
|
-
expect(code.format('%s %s')).to eq nil
|
17
|
-
end
|
18
|
-
it 'is correct' do
|
19
|
-
code = described_class.new('06')
|
20
|
-
expect(code.format('%s %s')).to eq '06'
|
21
|
-
end
|
22
|
-
it 'is correct' do
|
23
|
-
code = described_class.new('06', format: true)
|
24
|
-
expect(code.format('%s %s')).to eq '06'
|
25
|
-
end
|
26
|
-
it 'is correct' do
|
27
|
-
code = described_class.new('06', format: false)
|
28
|
-
expect(code.format('%s %s')).to eq nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#normalize' do
|
33
|
-
it 'is correct' do
|
34
|
-
code = described_class.new('0')
|
35
|
-
expect(code.normalize('0123')).to eq '0123'
|
36
|
-
end
|
37
|
-
it 'is correct' do
|
38
|
-
code = described_class.new('0', normalize: true)
|
39
|
-
expect(code.normalize('0123')).to eq '0123'
|
40
|
-
end
|
41
|
-
it 'is correct' do
|
42
|
-
code = described_class.new('0', normalize: false)
|
43
|
-
expect(code.normalize('0123')).to eq '0123'
|
44
|
-
end
|
45
|
-
it 'is correct' do
|
46
|
-
code = described_class.new('06')
|
47
|
-
expect(code.normalize('06123')).to eq '06123'
|
48
|
-
end
|
49
|
-
it 'is correct' do
|
50
|
-
code = described_class.new('06', normalize: true)
|
51
|
-
expect(code.normalize('06123')).to eq '06123'
|
52
|
-
end
|
53
|
-
it 'is correct' do
|
54
|
-
code = described_class.new('06', normalize: false)
|
55
|
-
expect(code.normalize('0123')).to eq '0123'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#split' do
|
60
|
-
it 'is correct' do
|
61
|
-
code = described_class.new('0')
|
62
|
-
expect(code.split('0123')).to eq [code, '0123']
|
63
|
-
end
|
64
|
-
it 'is correct' do
|
65
|
-
code = described_class.new('0', split: true)
|
66
|
-
expect(code.split('0123')).to eq [code, '123']
|
67
|
-
end
|
68
|
-
it 'is correct' do
|
69
|
-
code = described_class.new('0', split: false)
|
70
|
-
expect(code.split('0123')).to eq [code, '0123']
|
71
|
-
end
|
72
|
-
it 'is correct' do
|
73
|
-
code = described_class.new('06')
|
74
|
-
expect(code.split('06123')).to eq [code, '06123']
|
75
|
-
end
|
76
|
-
it 'is correct' do
|
77
|
-
code = described_class.new('06', split: true)
|
78
|
-
expect(code.split('06123')).to eq [code, '123']
|
79
|
-
end
|
80
|
-
it 'is correct' do
|
81
|
-
code = described_class.new('06', split: false)
|
82
|
-
expect(code.split('06123')).to eq [code, '06123']
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Phony::Vanity do
|
6
|
-
|
7
|
-
let(:vanity) { described_class }
|
8
|
-
|
9
|
-
describe '.replace' do
|
10
|
-
it 'replaces letters with digits' do
|
11
|
-
expect(vanity.replace('1-800-HELLO')).to eq '1-800-43556'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '.vanity?' do
|
16
|
-
it 'returns true on a vanity number' do
|
17
|
-
expect(vanity.vanity?('800HELLOES')).to eq true
|
18
|
-
end
|
19
|
-
it 'returns false on a non-vanity number' do
|
20
|
-
expect(vanity.vanity?('8004355637')).to eq false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '.normalized' do
|
25
|
-
it 'normalizes the vanity number' do
|
26
|
-
expect(vanity.normalized('1-800-HELLO')).to eq '1800HELLO'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/spec/lib/phony_spec.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Phony::NormalizationError do
|
4
|
-
it 'is correctly raised on normalize' do
|
5
|
-
expect do
|
6
|
-
Phony.normalize('000')
|
7
|
-
end.to raise_error(Phony::NormalizationError)
|
8
|
-
end
|
9
|
-
it 'is correctly raised on normalize' do
|
10
|
-
expect do
|
11
|
-
Phony.normalize('000')
|
12
|
-
end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
|
13
|
-
end
|
14
|
-
it 'is correctly raised on normalize!' do
|
15
|
-
expect do
|
16
|
-
Phony.normalize!('000')
|
17
|
-
end.to raise_error(Phony::NormalizationError)
|
18
|
-
end
|
19
|
-
it 'is correctly raised on normalize!' do
|
20
|
-
expect do
|
21
|
-
Phony.normalize!('000')
|
22
|
-
end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe Phony::SplittingError do
|
27
|
-
it 'is correctly raised on split' do
|
28
|
-
expect do
|
29
|
-
Phony.split('000')
|
30
|
-
end.to raise_error(Phony::SplittingError)
|
31
|
-
end
|
32
|
-
it 'is correctly raised on split' do
|
33
|
-
expect do
|
34
|
-
Phony.split('000')
|
35
|
-
end.to raise_error(%Q{Phony could not split the given number. Is "000" a phone number?})
|
36
|
-
end
|
37
|
-
it 'is correctly raised on split!' do
|
38
|
-
expect do
|
39
|
-
Phony.split!('000')
|
40
|
-
end.to raise_error(Phony::SplittingError)
|
41
|
-
end
|
42
|
-
it 'is correctly raised on split!' do
|
43
|
-
expect do
|
44
|
-
Phony.split!('000')
|
45
|
-
end.to raise_error(%Q{Phony could not split the given number. Is it a phone number?})
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe Phony::FormattingError do
|
50
|
-
it 'is correctly raised on format' do
|
51
|
-
expect do
|
52
|
-
Phony.format('000')
|
53
|
-
end.to raise_error(Phony::FormattingError)
|
54
|
-
end
|
55
|
-
it 'is correctly raised on format' do
|
56
|
-
expect do
|
57
|
-
Phony.format('000')
|
58
|
-
end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
|
59
|
-
end
|
60
|
-
it 'is correctly raised on format!' do
|
61
|
-
expect do
|
62
|
-
Phony.format!('000')
|
63
|
-
end.to raise_error(Phony::FormattingError)
|
64
|
-
end
|
65
|
-
it 'is correctly raised on format!' do
|
66
|
-
expect do
|
67
|
-
Phony.format!('000')
|
68
|
-
end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
|
69
|
-
end
|
70
|
-
end
|