phony 2.10.5 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 125ff1e9d966b0683eeaa62003d8e16f6484b235
4
- data.tar.gz: 4d13c383c23e7508bbdeb78940133a7f5ab431a3
3
+ metadata.gz: f33428121d0615a5ce85afb3ab4b5d84345632bd
4
+ data.tar.gz: c8eb442ccd1c658d6728a7b1a2c1dc3fff8e4b7b
5
5
  SHA512:
6
- metadata.gz: 207cb0b24be71b884f8c1715367fc31d4d179170d885aa817963701475ec11b052213afd2e84863569b8fd5855223ce7d91d35aa7e489c28e3b8c54b2acaf427
7
- data.tar.gz: 76e5420b85000cc96e691d83b8d23869198224523c098f812efc1a7dc9ead55c7e26b0491a8cac47418ad1a11c6dc4de1f4b6de9f887b1549dfac567982d99c3
6
+ metadata.gz: f7115867a3578cf7c9e0b90d2d580bc2cfa4cdd04ae4ad8d21fa855033b4da7d1d89744c23079dcc3b01a9405a547e1720fc7907bcd37ef1fa8f683719f72fbb
7
+ data.tar.gz: 5fb4d549e393a87078d74157ac11ad4d234a4040bf817954723e81f609f07f0b9421575ccec084eb7b7a0f1c1b32eddac57eff412c260ecf1463b03ee0ed1d25
@@ -107,6 +107,7 @@ module Phony
107
107
  else
108
108
  format_local(local_space, parts) unless parts.empty?
109
109
  end
110
+
110
111
  format_cc_ndc format, space, cc, trunk, ndc, local
111
112
 
112
113
  # cc_ndc = cc_ndc.slice 0...cc_ndc.rindex(space.to_s) if parts.empty?
@@ -128,7 +129,7 @@ module Phony
128
129
  trunk = trunk % space if trunk && trunk.size > 1
129
130
  ndc && !ndc.empty? ?
130
131
  @national_format % [trunk, ndc, space, local] :
131
- @national_format % [trunk, nil, nil, nil]
132
+ @national_format % [trunk, nil, nil, local]
132
133
  when :local
133
134
  local
134
135
  end
@@ -34,152 +34,155 @@ describe 'Phony#format' do
34
34
  end
35
35
  end
36
36
  describe 'default' do
37
- it 'should format Swiss numbers' do
37
+ it 'formats Swiss numbers' do
38
38
  Phony.format('41443643532').should eql '+41 44 364 35 32'
39
39
  end
40
- it 'should format Swiss national numbers' do
40
+ it 'formats Swiss national numbers' do
41
41
  Phony.format('41443643532', :format => :national).should eql '044 364 35 32'
42
42
  end
43
43
  # TODO
44
44
  #
45
- it 'should format Swiss service numbers' do
45
+ it 'formats Swiss service numbers' do
46
46
  Phony.format('41800112233').should eql '+41 800 112 233'
47
47
  end
48
- it 'should format Austrian numbers' do
48
+ it 'formats Austrian numbers' do
49
49
  Phony.format('43198110').should eql '+43 1 98110'
50
50
  end
51
- it 'should format American numbers' do
51
+ it 'formats Danish national numbers' do
52
+ Phony.format('4540506070', format: :national).should eql '40 50 60 70'
53
+ end
54
+ it 'formats American numbers' do
52
55
  Phony.format('18705551122').should eql '+1 870 555 1122'
53
56
  end
54
- it 'should format New Zealand 021 6-digit mobile numbers' do
57
+ it 'formats New Zealand 021 6-digit mobile numbers' do
55
58
  Phony.format('6421123456').should eql '+64 21 123 456'
56
59
  end
57
- it 'should format New Zealand 021 7-digit mobile numbers' do
60
+ it 'formats New Zealand 021 7-digit mobile numbers' do
58
61
  Phony.format('64211234567').should eql '+64 21 123 4567'
59
62
  end
60
- it 'should format New Zealand 021 8-digit mobile numbers' do
63
+ it 'formats New Zealand 021 8-digit mobile numbers' do
61
64
  Phony.format('642112345678').should eql '+64 21 12 345 678'
62
65
  end
63
- it 'should format New Zealand landline numbers' do
66
+ it 'formats New Zealand landline numbers' do
64
67
  Phony.format('6493791234').should eql '+64 9 379 1234'
65
68
  end
66
- it 'should format Indian numbers' do
69
+ it 'formats Indian numbers' do
67
70
  Phony.format('914433993939').should eql '+91 44 339 93 939'
68
71
  end
69
- it 'should format Russian numbers' do
72
+ it 'formats Russian numbers' do
70
73
  Phony.format(Phony.normalize('+370 800 12345'), :format => :international).should eql '+370 800 12 345'
71
74
  end
72
- it 'should format Russian numbers' do
75
+ it 'formats Russian numbers' do
73
76
  Phony.format(Phony.normalize('+7 812 123 4567'), :format => :international).should eql '+7 812 123-45-67'
74
77
  end
75
- it 'should format Russian numbers' do
78
+ it 'formats Russian numbers' do
76
79
  Phony.format(Phony.normalize('+370 800 12345'), :format => :national).should eql '8800 12 345'
77
80
  end
78
- it 'should format Russian numbers' do
81
+ it 'formats Russian numbers' do
79
82
  Phony.format(Phony.normalize('+7 812 123 4567'), :format => :national).should eql '8812 123-45-67'
80
83
  end
81
84
  end
82
85
  describe 'international' do
83
- it 'should format north american numbers' do
86
+ it 'formats north american numbers' do
84
87
  Phony.format('18091231234', :format => :international).should eql '+1 809 123 1234'
85
88
  end
86
- it 'should format austrian numbers' do
89
+ it 'formats austrian numbers' do
87
90
  Phony.format('43198110', :format => :international).should eql '+43 1 98110'
88
91
  end
89
- it 'should format austrian numbers' do
92
+ it 'formats austrian numbers' do
90
93
  Phony.format('43198110', :format => :international_absolute).should eql '+43 1 98110'
91
94
  end
92
- it 'should format french numbers' do
95
+ it 'formats french numbers' do
93
96
  Phony.format('33142278186', :format => :+).should eql '+33 1 42 27 81 86'
94
97
  end
95
- it 'should format austrian numbers' do
98
+ it 'formats austrian numbers' do
96
99
  Phony.format('43198110', :format => :international_relative).should eql '0043 1 98110'
97
100
  end
98
- it 'should format liechtensteiner numbers' do
101
+ it 'formats liechtensteiner numbers' do
99
102
  Phony.format('4233841148', :format => :international_relative).should eql '00423 384 11 48'
100
103
  end
101
104
  context 'with no spaces' do
102
- it 'should format north american numbers' do
105
+ it 'formats north american numbers' do
103
106
  Phony.format('18091231234', :format => :international, :spaces => '').should eql '+18091231234'
104
107
  end
105
- it 'should format austrian numbers' do
108
+ it 'formats austrian numbers' do
106
109
  Phony.format('43198110', :format => :international, :spaces => '').should eql '+43198110'
107
110
  end
108
- it 'should format austrian numbers' do
111
+ it 'formats austrian numbers' do
109
112
  Phony.format('43198110', :format => :international_absolute, :spaces => '').should eql '+43198110'
110
113
  end
111
- it 'should format french numbers' do
114
+ it 'formats french numbers' do
112
115
  Phony.format('33142278186', :format => :+, :spaces => '').should eql '+33142278186'
113
116
  end
114
- it 'should format austrian numbers' do
117
+ it 'formats austrian numbers' do
115
118
  Phony.format('43198110', :format => :international_relative, :spaces => '').should eql '0043198110'
116
119
  end
117
- it 'should format liechtensteiner numbers' do
120
+ it 'formats liechtensteiner numbers' do
118
121
  Phony.format('4233841148', :format => :international_relative, :spaces => '').should eql '004233841148'
119
122
  end
120
123
  end
121
124
  context 'with special spaces' do
122
- it 'should format swiss numbers' do
125
+ it 'formats swiss numbers' do
123
126
  Phony.format('41443643532', :format => :international).should eql '+41 44 364 35 32'
124
127
  end
125
- it 'should format north american numbers' do
128
+ it 'formats north american numbers' do
126
129
  Phony.format('18091231234', :format => :international, :spaces => :-).should eql '+1-809-123-1234'
127
130
  end
128
- it 'should format austrian numbers' do
131
+ it 'formats austrian numbers' do
129
132
  Phony.format('43198110', :format => :international, :spaces => :-).should eql '+43-1-98110'
130
133
  end
131
- it 'should format austrian numbers' do
134
+ it 'formats austrian numbers' do
132
135
  Phony.format('43198110', :format => :international_absolute, :spaces => :-).should eql '+43-1-98110'
133
136
  end
134
- it 'should format french numbers' do
137
+ it 'formats french numbers' do
135
138
  Phony.format('33142278186', :format => :+, :spaces => :-).should eql '+33-1-42-27-81-86'
136
139
  end
137
- it 'should format austrian numbers' do
140
+ it 'formats austrian numbers' do
138
141
  Phony.format('43198110', :format => :international_relative, :spaces => :-).should eql '0043-1-98110'
139
142
  end
140
- it 'should format liechtensteiner numbers' do
143
+ it 'formats liechtensteiner numbers' do
141
144
  Phony.format('4233841148', :format => :international_relative, :spaces => :-).should eql '00423-384-11-48'
142
145
  end
143
146
  end
144
147
  describe "'unsupported' countries" do
145
- it 'should format as a single block' do
148
+ it 'formats as a single block' do
146
149
  Phony.format('88132155605220').should eql '+881 32155605220'
147
150
  end
148
- it 'should format as a single block, regardless of format' do
151
+ it 'formats as a single block, regardless of format' do
149
152
  Phony.format('8811819372205', :format => :international).should eql '+881 1819372205'
150
153
  end
151
- it 'should format as a single block, respecting custom spaces' do
154
+ it 'formats as a single block, respecting custom spaces' do
152
155
  Phony.format('8811819372205', :spaces => :-).should eql '+881-1819372205'
153
156
  end
154
- it 'should format as a single block, even without spaces' do
157
+ it 'formats as a single block, even without spaces' do
155
158
  Phony.format('8811819372205', :spaces => '').should eql '+8811819372205'
156
159
  end
157
160
  end
158
161
  end
159
162
  describe 'national' do
160
- it 'should format swiss numbers' do
163
+ it 'formats swiss numbers' do
161
164
  Phony.format('41443643532', :format => :national).should eql '044 364 35 32'
162
165
  end
163
166
  # TODO
164
167
  #
165
- it 'should format swiss service numbers' do
168
+ it 'formats swiss service numbers' do
166
169
  Phony.format('41800112233', :format => :national).should eql '0800 112 233'
167
170
  end
168
- it 'should format austrian numbers' do
171
+ it 'formats austrian numbers' do
169
172
  Phony.format('43198110', :format => :national).should eql '01 98110'
170
173
  end
171
- it 'should format US numbers with a leading trunk 1' do
174
+ it 'formats US numbers with a leading trunk 1' do
172
175
  Phony.format('14159224711', :format => :national).should eql '1 415 922 4711'
173
176
  end
174
- it 'should format Dutch numbers with a trunk code' do
177
+ it 'formats Dutch numbers with a trunk code' do
175
178
  Phony.format('311012341234', :format => :national).should eql '010 123 41234'
176
179
  end
177
180
  end
178
181
  describe 'local' do
179
- it 'should format swiss numbers' do
182
+ it 'formats swiss numbers' do
180
183
  Phony.format('41443643532', :format => :local).should eql '364 35 32'
181
184
  end
182
- it 'should format german numbers' do
185
+ it 'formats german numbers' do
183
186
  Phony.format('493038625454', :format => :local).should eql '386 25454'
184
187
  end
185
188
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.5
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke