phony 2.18.3 → 2.20.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.textile +5 -1
  3. data/lib/phony/countries/argentina.rb +355 -0
  4. data/lib/phony/countries/austria.rb +2 -2
  5. data/lib/phony/countries/cambodia.rb +1 -5
  6. data/lib/phony/countries/china.rb +5 -2
  7. data/lib/phony/countries/germany.rb +1 -1
  8. data/lib/phony/countries/ireland.rb +6 -4
  9. data/lib/phony/countries/italy.rb +34 -17
  10. data/lib/phony/countries/japan.rb +58 -8
  11. data/lib/phony/countries/libya.rb +1 -1
  12. data/lib/phony/countries/serbia.rb +5 -1
  13. data/lib/phony/countries/taiwan.rb +1 -0
  14. data/lib/phony/countries/vietnam.rb +1 -0
  15. data/lib/phony/countries.rb +83 -53
  16. data/lib/phony/country.rb +8 -2
  17. data/lib/phony/country_codes.rb +15 -2
  18. data/lib/phony/dsl.rb +2 -2
  19. data/lib/phony/local_splitters/fixed.rb +2 -0
  20. data/lib/phony/national_code.rb +1 -1
  21. data/lib/phony/national_splitters/none.rb +1 -3
  22. data/lib/phony/trunk_code.rb +5 -5
  23. data/lib/phony.rb +1 -0
  24. data/spec/functional/config_spec.rb +5 -5
  25. data/spec/functional/plausibility_spec.rb +82 -16
  26. data/spec/lib/phony/countries_spec.rb +86 -23
  27. data/spec/lib/phony/country_codes_spec.rb +82 -58
  28. data/spec/lib/phony/country_spec.rb +29 -9
  29. data/spec/lib/phony/dsl_spec.rb +6 -2
  30. data/spec/lib/phony/local_splitters/regex_spec.rb +12 -15
  31. data/spec/lib/phony/national_code_spec.rb +15 -45
  32. data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -16
  33. data/spec/lib/phony/national_splitters/none_spec.rb +3 -3
  34. data/spec/lib/phony/national_splitters/variable_spec.rb +9 -13
  35. data/spec/lib/phony/trunk_code_spec.rb +85 -0
  36. data/spec/lib/phony/vanity_spec.rb +4 -4
  37. metadata +21 -19
@@ -4,34 +4,30 @@ describe Phony::NationalSplitters::Variable do
4
4
 
5
5
  describe 'split' do
6
6
  context 'normal' do
7
- before(:each) do
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
- @splitter.split('198110').should == [nil, '1', '98110']
9
+ expect(splitter.split('198110')).to eq [nil, '1', '98110']
12
10
  end
13
11
  it "handles some mobile services" do
14
- @splitter.split('66914093902').should == [nil, '669', '14093902']
12
+ expect(splitter.split('66914093902')).to eq [nil, '669', '14093902']
15
13
  end
16
14
  it "handles Graz" do
17
- @splitter.split('3161234567891').should == [nil, '316', '1234567891']
15
+ expect(splitter.split('3161234567891')).to eq [nil, '316', '1234567891']
18
16
  end
19
17
  it "handles Rohrau" do
20
- @splitter.split('2164123456789').should == [nil, '2164', '123456789']
18
+ expect(splitter.split('2164123456789')).to eq [nil, '2164', '123456789']
21
19
  end
22
20
  it 'has an NDC length of 3' do
23
- @splitter.length.should == (1..3)
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
- before(:each) do
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
- @splitter.split('800223344').should == [nil, '800', '223344']
27
+ expect(splitter.split('800223344')).to eq [nil, '800', '223344']
32
28
  end
33
29
  it 'has an NDC length of 3' do
34
- @splitter.length.should == (3..3)
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').should == '1-800-43556'
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').should == true
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').should == false
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').should == '1800HELLO'
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.18.3
4
+ version: 2.20.5
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: 2019-06-03 00:00:00.000000000 Z
11
+ date: 2023-05-06 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
@@ -23,6 +23,7 @@ files:
23
23
  - lib/phony.rb
24
24
  - lib/phony/config.rb
25
25
  - lib/phony/countries.rb
26
+ - lib/phony/countries/argentina.rb
26
27
  - lib/phony/countries/austria.rb
27
28
  - lib/phony/countries/bangladesh.rb
28
29
  - lib/phony/countries/belarus.rb
@@ -92,13 +93,14 @@ files:
92
93
  - spec/lib/phony/national_splitters/none_spec.rb
93
94
  - spec/lib/phony/national_splitters/regex_spec.rb
94
95
  - spec/lib/phony/national_splitters/variable_spec.rb
96
+ - spec/lib/phony/trunk_code_spec.rb
95
97
  - spec/lib/phony/vanity_spec.rb
96
98
  - spec/lib/phony_spec.rb
97
- homepage: http://github.com/floere/phony
99
+ homepage: https://github.com/floere/phony
98
100
  licenses:
99
101
  - MIT
100
102
  metadata: {}
101
- post_install_message:
103
+ post_install_message:
102
104
  rdoc_options: []
103
105
  require_paths:
104
106
  - lib
@@ -113,26 +115,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
115
  - !ruby/object:Gem::Version
114
116
  version: '0'
115
117
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.7.6
118
- signing_key:
118
+ rubygems_version: 3.3.26
119
+ signing_key:
119
120
  specification_version: 4
120
121
  summary: Fast international phone number (E164 standard) normalizing, splitting and
121
122
  formatting.
122
123
  test_files:
123
- - spec/lib/phony_spec.rb
124
- - spec/lib/phony/country_spec.rb
125
- - spec/lib/phony/national_code_spec.rb
124
+ - spec/functional/config_spec.rb
125
+ - spec/functional/plausibility_spec.rb
126
126
  - spec/lib/phony/countries_spec.rb
127
+ - spec/lib/phony/country_codes_spec.rb
128
+ - spec/lib/phony/country_spec.rb
127
129
  - spec/lib/phony/dsl_spec.rb
128
- - spec/lib/phony/national_splitters/variable_spec.rb
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
129
135
  - spec/lib/phony/national_splitters/none_spec.rb
130
136
  - spec/lib/phony/national_splitters/regex_spec.rb
131
- - spec/lib/phony/national_splitters/fixed_spec.rb
132
- - spec/lib/phony/national_splitters/default_spec.rb
133
- - spec/lib/phony/country_codes_spec.rb
134
- - spec/lib/phony/local_splitters/regex_spec.rb
135
- - 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
136
139
  - spec/lib/phony/vanity_spec.rb
137
- - spec/functional/config_spec.rb
138
- - spec/functional/plausibility_spec.rb
140
+ - spec/lib/phony_spec.rb