phony 2.17.0 → 2.20.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +34 -6
- data/lib/phony/config.rb +91 -0
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +4 -2
- data/lib/phony/countries/bangladesh.rb +2 -0
- data/lib/phony/countries/belarus.rb +2 -0
- data/lib/phony/countries/brazil.rb +4 -2
- data/lib/phony/countries/cambodia.rb +3 -5
- data/lib/phony/countries/china.rb +7 -2
- data/lib/phony/countries/croatia.rb +2 -0
- data/lib/phony/countries/georgia.rb +2 -0
- data/lib/phony/countries/germany.rb +5 -2
- 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 +27 -23
- data/lib/phony/countries/italy.rb +41 -18
- data/lib/phony/countries/japan.rb +60 -8
- data/lib/phony/countries/kyrgyzstan.rb +2 -0
- data/lib/phony/countries/latvia.rb +2 -0
- data/lib/phony/countries/libya.rb +3 -1
- 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 +7 -1
- 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 +3 -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 +7 -1
- data/lib/phony/countries/zimbabwe.rb +2 -0
- data/lib/phony/countries.rb +108 -65
- data/lib/phony/country.rb +11 -3
- data/lib/phony/country_codes.rb +16 -3
- data/lib/phony/dsl.rb +5 -3
- data/lib/phony/local_splitters/fixed.rb +2 -0
- data/lib/phony/national_code.rb +1 -1
- data/lib/phony/national_splitters/none.rb +1 -3
- data/lib/phony/trunk_code.rb +5 -5
- data/lib/phony.rb +62 -57
- data/spec/functional/config_spec.rb +44 -0
- data/spec/functional/plausibility_spec.rb +104 -19
- data/spec/lib/phony/countries_spec.rb +107 -35
- data/spec/lib/phony/country_codes_spec.rb +82 -58
- data/spec/lib/phony/country_spec.rb +29 -9
- data/spec/lib/phony/dsl_spec.rb +7 -3
- data/spec/lib/phony/local_splitters/regex_spec.rb +19 -15
- data/spec/lib/phony/national_code_spec.rb +15 -45
- data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -16
- data/spec/lib/phony/national_splitters/none_spec.rb +3 -3
- data/spec/lib/phony/national_splitters/variable_spec.rb +9 -13
- data/spec/lib/phony/trunk_code_spec.rb +85 -0
- data/spec/lib/phony/vanity_spec.rb +4 -4
- metadata +23 -18
@@ -4,7 +4,7 @@ describe Phony::NationalSplitters::None do
|
|
4
4
|
|
5
5
|
describe 'instance_for' do
|
6
6
|
it 'caches' do
|
7
|
-
described_class.instance_for.
|
7
|
+
expect(described_class.instance_for).to eq described_class.instance_for
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -13,13 +13,13 @@ describe Phony::NationalSplitters::None do
|
|
13
13
|
|
14
14
|
describe 'split' do
|
15
15
|
it 'splits correctly into ndc and rest' do
|
16
|
-
splitter.split('123456789').
|
16
|
+
expect(splitter.split('123456789')).to eq [nil, false, '123456789']
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe 'length' do
|
21
21
|
it 'is always 0' do
|
22
|
-
splitter.length.
|
22
|
+
expect(splitter.length).to be_zero
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -4,34 +4,30 @@ describe Phony::NationalSplitters::Variable do
|
|
4
4
|
|
5
5
|
describe 'split' do
|
6
6
|
context 'normal' do
|
7
|
-
|
8
|
-
@splitter = Phony::NationalSplitters::Variable.new 4, ['1', '316', '67', '68', '669', '711']
|
9
|
-
end
|
7
|
+
let(:splitter) { Phony::NationalSplitters::Variable.new 4, ['1', '316', '67', '68', '669', '711'] }
|
10
8
|
it "handles Vienna" do
|
11
|
-
|
9
|
+
expect(splitter.split('198110')).to eq [nil, '1', '98110']
|
12
10
|
end
|
13
11
|
it "handles some mobile services" do
|
14
|
-
|
12
|
+
expect(splitter.split('66914093902')).to eq [nil, '669', '14093902']
|
15
13
|
end
|
16
14
|
it "handles Graz" do
|
17
|
-
|
15
|
+
expect(splitter.split('3161234567891')).to eq [nil, '316', '1234567891']
|
18
16
|
end
|
19
17
|
it "handles Rohrau" do
|
20
|
-
|
18
|
+
expect(splitter.split('2164123456789')).to eq [nil, '2164', '123456789']
|
21
19
|
end
|
22
20
|
it 'has an NDC length of 3' do
|
23
|
-
|
21
|
+
expect(splitter.length).to eq (1..3)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
context 'special handling for using the variable size splitter for Swiss service numbers' do
|
27
|
-
|
28
|
-
@splitter = Phony::NationalSplitters::Variable.new 2, ['800']
|
29
|
-
end
|
25
|
+
let(:splitter) { Phony::NationalSplitters::Variable.new 2, ['800'] }
|
30
26
|
it "should handle swiss service numbers" do
|
31
|
-
|
27
|
+
expect(splitter.split('800223344')).to eq [nil, '800', '223344']
|
32
28
|
end
|
33
29
|
it 'has an NDC length of 3' do
|
34
|
-
|
30
|
+
expect(splitter.length).to eq (3..3)
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
@@ -0,0 +1,85 @@
|
|
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
|
@@ -8,22 +8,22 @@ describe Phony::Vanity do
|
|
8
8
|
|
9
9
|
describe '.replace' do
|
10
10
|
it 'replaces letters with digits' do
|
11
|
-
vanity.replace('1-800-HELLO').
|
11
|
+
expect(vanity.replace('1-800-HELLO')).to eq '1-800-43556'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '.vanity?' do
|
16
16
|
it 'returns true on a vanity number' do
|
17
|
-
vanity.vanity?('800HELLOES').
|
17
|
+
expect(vanity.vanity?('800HELLOES')).to eq true
|
18
18
|
end
|
19
19
|
it 'returns false on a non-vanity number' do
|
20
|
-
vanity.vanity?('8004355637').
|
20
|
+
expect(vanity.vanity?('8004355637')).to eq false
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '.normalized' do
|
25
25
|
it 'normalizes the vanity number' do
|
26
|
-
vanity.normalized('1-800-HELLO').
|
26
|
+
expect(vanity.normalized('1-800-HELLO')).to eq '1800HELLO'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
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.20.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-22 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
|
@@ -90,13 +93,14 @@ files:
|
|
90
93
|
- spec/lib/phony/national_splitters/none_spec.rb
|
91
94
|
- spec/lib/phony/national_splitters/regex_spec.rb
|
92
95
|
- spec/lib/phony/national_splitters/variable_spec.rb
|
96
|
+
- spec/lib/phony/trunk_code_spec.rb
|
93
97
|
- spec/lib/phony/vanity_spec.rb
|
94
98
|
- spec/lib/phony_spec.rb
|
95
|
-
homepage:
|
99
|
+
homepage: https://github.com/floere/phony
|
96
100
|
licenses:
|
97
101
|
- MIT
|
98
102
|
metadata: {}
|
99
|
-
post_install_message:
|
103
|
+
post_install_message:
|
100
104
|
rdoc_options: []
|
101
105
|
require_paths:
|
102
106
|
- lib
|
@@ -111,25 +115,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
115
|
- !ruby/object:Gem::Version
|
112
116
|
version: '0'
|
113
117
|
requirements: []
|
114
|
-
|
115
|
-
|
116
|
-
signing_key:
|
118
|
+
rubygems_version: 3.4.19
|
119
|
+
signing_key:
|
117
120
|
specification_version: 4
|
118
121
|
summary: Fast international phone number (E164 standard) normalizing, splitting and
|
119
122
|
formatting.
|
120
123
|
test_files:
|
121
|
-
- spec/
|
122
|
-
- spec/
|
123
|
-
- spec/lib/phony/national_code_spec.rb
|
124
|
+
- spec/functional/config_spec.rb
|
125
|
+
- spec/functional/plausibility_spec.rb
|
124
126
|
- spec/lib/phony/countries_spec.rb
|
127
|
+
- spec/lib/phony/country_codes_spec.rb
|
128
|
+
- spec/lib/phony/country_spec.rb
|
125
129
|
- spec/lib/phony/dsl_spec.rb
|
126
|
-
- spec/lib/phony/
|
130
|
+
- spec/lib/phony/local_splitters/fixed_spec.rb
|
131
|
+
- spec/lib/phony/local_splitters/regex_spec.rb
|
132
|
+
- spec/lib/phony/national_code_spec.rb
|
133
|
+
- spec/lib/phony/national_splitters/default_spec.rb
|
134
|
+
- spec/lib/phony/national_splitters/fixed_spec.rb
|
127
135
|
- spec/lib/phony/national_splitters/none_spec.rb
|
128
136
|
- spec/lib/phony/national_splitters/regex_spec.rb
|
129
|
-
- spec/lib/phony/national_splitters/
|
130
|
-
- spec/lib/phony/
|
131
|
-
- spec/lib/phony/country_codes_spec.rb
|
132
|
-
- spec/lib/phony/local_splitters/regex_spec.rb
|
133
|
-
- spec/lib/phony/local_splitters/fixed_spec.rb
|
137
|
+
- spec/lib/phony/national_splitters/variable_spec.rb
|
138
|
+
- spec/lib/phony/trunk_code_spec.rb
|
134
139
|
- spec/lib/phony/vanity_spec.rb
|
135
|
-
- spec/
|
140
|
+
- spec/lib/phony_spec.rb
|