phony 2.15.49 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/phony.rb +35 -6
- data/lib/phony/countries/indonesia.rb +2 -1
- data/spec/functional/plausibility_spec.rb +66 -66
- data/spec/lib/phony/countries_spec.rb +1 -0
- data/spec/lib/phony/local_splitters/regex_spec.rb +5 -5
- data/spec/lib/phony/national_splitters/default_spec.rb +1 -1
- data/spec/lib/phony_spec.rb +74 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d831c513f17ed24daad1ad6bd38a46c6b37deb16
|
4
|
+
data.tar.gz: 304941e9a21b1947471bcf3f2fc6de9dc5294ce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04743bc50ad6da4c0936878ed2a9eb4b2e560de7e36622e41e741da77a7ddd9e1d9f3893db71113045e68217a69ed71ca5c441b29f47d7f7c69562a910de1ff8
|
7
|
+
data.tar.gz: 00dc3f70d706c77aa3d31df5306491d01bf1aefd2cb79bc78ef1977ab15b6184d27f470723b7e3254754e727c3b1c831b300bd65a9b302e717456bc95da32578
|
data/lib/phony.rb
CHANGED
@@ -76,9 +76,31 @@ module Phony
|
|
76
76
|
# @example
|
77
77
|
# Phony.normalize("Fnork!") # Raises a Phony::NormalizationError.
|
78
78
|
#
|
79
|
-
class NormalizationError <
|
80
|
-
def initialize
|
81
|
-
super %Q{Phony could not normalize the given number. Is
|
79
|
+
class NormalizationError < ArgumentError
|
80
|
+
def initialize
|
81
|
+
super %Q{Phony could not normalize the given number. Is it a phone number?}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Raised in case Phony can't split a given number.
|
86
|
+
#
|
87
|
+
# @example
|
88
|
+
# Phony.split("Fnork!") # Raises a Phony::SplittingError.
|
89
|
+
#
|
90
|
+
class SplittingError < ArgumentError
|
91
|
+
def initialize number
|
92
|
+
super %Q{Phony could not split the given number. Is #{number.blank? ? 'it' : number.inspect} a phone number?}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Raised in case Phony can't format a given number.
|
97
|
+
#
|
98
|
+
# @example
|
99
|
+
# Phony.format("Fnork!") # Raises a Phony::FormattingError.
|
100
|
+
#
|
101
|
+
class FormattingError < ArgumentError
|
102
|
+
def initialize
|
103
|
+
super %Q{Phony could not format the given number. Is it a phone number?}
|
82
104
|
end
|
83
105
|
end
|
84
106
|
|
@@ -121,6 +143,7 @@ module Phony
|
|
121
143
|
#
|
122
144
|
def normalize phone_number, options = {}
|
123
145
|
raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.normalize(number)." unless phone_number
|
146
|
+
|
124
147
|
normalize! phone_number.dup, options
|
125
148
|
end
|
126
149
|
# A destructive version of {#normalize}.
|
@@ -143,7 +166,7 @@ module Phony
|
|
143
166
|
def normalize! phone_number, options = {}
|
144
167
|
@codes.normalize phone_number, options
|
145
168
|
rescue
|
146
|
-
raise NormalizationError.new
|
169
|
+
raise NormalizationError.new
|
147
170
|
end
|
148
171
|
|
149
172
|
# Splits the phone number into pieces according to the country codes.
|
@@ -162,7 +185,8 @@ module Phony
|
|
162
185
|
#
|
163
186
|
def split phone_number
|
164
187
|
raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.split(number)." unless phone_number
|
165
|
-
|
188
|
+
|
189
|
+
split! phone_number.dup, phone_number
|
166
190
|
end
|
167
191
|
# A destructive version of {#split}.
|
168
192
|
#
|
@@ -178,8 +202,11 @@ module Phony
|
|
178
202
|
# @example Split a NANP number.
|
179
203
|
# Phony.split!("13015550100") # => ["1", "301", "555", "0100"]
|
180
204
|
#
|
181
|
-
def split! phone_number
|
205
|
+
def split! phone_number, error_number = nil
|
182
206
|
@codes.split phone_number
|
207
|
+
rescue
|
208
|
+
# NB The error_number (reference) is used because phone_number is destructively handled.
|
209
|
+
raise SplittingError.new(error_number)
|
183
210
|
end
|
184
211
|
|
185
212
|
# Formats a normalized E164 number according to a country's formatting scheme.
|
@@ -231,6 +258,8 @@ module Phony
|
|
231
258
|
#
|
232
259
|
def format! phone_number, options = {}
|
233
260
|
@codes.format phone_number, options
|
261
|
+
rescue
|
262
|
+
raise FormattingError.new
|
234
263
|
end
|
235
264
|
alias formatted format
|
236
265
|
alias formatted! format!
|
@@ -34,7 +34,8 @@ Phony.define do
|
|
34
34
|
match(/\A(81\d|82\d|83\d|84\d|85\d|86\d|87\d|88\d|89\d)\d+\z/) >> matched_split( # mobile
|
35
35
|
/\A\d{6}\z/ => [3,3],
|
36
36
|
/\A\d{7}\z/ => [3,4],
|
37
|
-
/\A\d
|
37
|
+
/\A\d{8}\z/ => [4,4],
|
38
|
+
/\A\d+\z/ => [4,5]) |
|
38
39
|
one_of(%w(9)) >> matched_split( # geographic
|
39
40
|
/\A\d{7}\z/ => [4,3],
|
40
41
|
/\A\d+\z/ => [3,3,3]) |
|
@@ -25,11 +25,11 @@ describe 'plausibility' do
|
|
25
25
|
incorrect = [shortest.sub(/\d\s*\z/, '')] # , longest + '0']
|
26
26
|
|
27
27
|
correct.each do |value|
|
28
|
-
Phony.plausible?(value).should
|
28
|
+
Phony.plausible?(value).should be_truthy,
|
29
29
|
"It should validate #{value}, but does not."
|
30
30
|
end
|
31
31
|
incorrect.each do |value|
|
32
|
-
Phony.plausible?(value).should
|
32
|
+
Phony.plausible?(value).should be_falsey,
|
33
33
|
"It should not validate #{value}, but does."
|
34
34
|
end
|
35
35
|
end
|
@@ -38,7 +38,7 @@ describe 'plausibility' do
|
|
38
38
|
invalid = [*sample]
|
39
39
|
|
40
40
|
invalid.each do |value|
|
41
|
-
Phony.plausible?(value).should
|
41
|
+
Phony.plausible?(value).should be_falsey,
|
42
42
|
"It should not validate #{value}, but does."
|
43
43
|
end
|
44
44
|
end
|
@@ -54,14 +54,14 @@ describe 'plausibility' do
|
|
54
54
|
it_is_correct_for 'Cook Islands', :samples => '+682 71928'
|
55
55
|
it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
|
56
56
|
it 'is correct for Croatia' do
|
57
|
-
Phony.plausible?('+385 21 695 900').should
|
58
|
-
Phony.plausible?('+385 1 4566 666').should
|
59
|
-
Phony.plausible?('+385 99 444 999').should
|
60
|
-
Phony.plausible?('+385 91 896 7509').should
|
61
|
-
Phony.plausible?('+385 800 1234').should
|
62
|
-
Phony.plausible?('+385 800 123 456').should
|
63
|
-
Phony.plausible?('+385 60 12 345').should
|
64
|
-
Phony.plausible?('+385 62 123 456').should
|
57
|
+
Phony.plausible?('+385 21 695 900').should be_truthy # Landline
|
58
|
+
Phony.plausible?('+385 1 4566 666').should be_truthy # Landline (Zagreb)
|
59
|
+
Phony.plausible?('+385 99 444 999').should be_truthy # Mobile
|
60
|
+
Phony.plausible?('+385 91 896 7509').should be_truthy # Mobile
|
61
|
+
Phony.plausible?('+385 800 1234').should be_truthy # Toll free
|
62
|
+
Phony.plausible?('+385 800 123 456').should be_truthy # Toll free
|
63
|
+
Phony.plausible?('+385 60 12 345').should be_truthy # Premium rate
|
64
|
+
Phony.plausible?('+385 62 123 456').should be_truthy # Premium, personal and UAN
|
65
65
|
end
|
66
66
|
it_is_correct_for "Côte d'Ivoire", :samples => '+225 9358 8764'
|
67
67
|
it_is_correct_for 'Democratic Republic of Timor-Leste', :samples => ['+670 465 7886', '+670 7465 7886']
|
@@ -69,30 +69,30 @@ describe 'plausibility' do
|
|
69
69
|
it_is_correct_for 'Diego Garcia', :samples => '+246 123 7686'
|
70
70
|
it_is_correct_for 'Djibouti', :samples => '+253 3671 1431'
|
71
71
|
it 'is correct for Ecuador' do
|
72
|
-
Phony.plausible?('+593 22 000 0000').should
|
73
|
-
Phony.plausible?('+593 23 000 0000').should
|
74
|
-
Phony.plausible?('+593 26 000 0000').should
|
75
|
-
Phony.plausible?('+593 27 000 0000').should
|
76
|
-
Phony.plausible?('+593 44 000 0000').should
|
77
|
-
Phony.plausible?('+593 45 000 0000').should
|
78
|
-
Phony.plausible?('+593 47 000 0000').should
|
79
|
-
Phony.plausible?('+593 2 200 0000').should
|
80
|
-
Phony.plausible?('+593 2 300 0000').should
|
81
|
-
Phony.plausible?('+593 2 400 0000').should
|
82
|
-
Phony.plausible?('+593 2 500 0000').should
|
83
|
-
Phony.plausible?('+593 2 700 0000').should
|
84
|
-
Phony.plausible?('+593 3 000 0000').should
|
85
|
-
Phony.plausible?('+593 4 000 0000').should
|
86
|
-
Phony.plausible?('+593 4 500 0000').should
|
87
|
-
Phony.plausible?('+593 4 600 0000').should
|
88
|
-
Phony.plausible?('+593 5 200 0000').should
|
89
|
-
Phony.plausible?('+593 5 300 0000').should
|
90
|
-
Phony.plausible?('+593 6 200 0000').should
|
91
|
-
Phony.plausible?('+593 7 200 0000').should
|
92
|
-
Phony.plausible?('+593 7 300 0000').should
|
93
|
-
Phony.plausible?('+593 7 400 0000').should
|
94
|
-
Phony.plausible?('+593 7 600 0000').should
|
95
|
-
Phony.plausible?('+593 9 0000 0000').should
|
72
|
+
Phony.plausible?('+593 22 000 0000').should be_truthy
|
73
|
+
Phony.plausible?('+593 23 000 0000').should be_truthy
|
74
|
+
Phony.plausible?('+593 26 000 0000').should be_truthy
|
75
|
+
Phony.plausible?('+593 27 000 0000').should be_truthy
|
76
|
+
Phony.plausible?('+593 44 000 0000').should be_truthy
|
77
|
+
Phony.plausible?('+593 45 000 0000').should be_truthy
|
78
|
+
Phony.plausible?('+593 47 000 0000').should be_truthy
|
79
|
+
Phony.plausible?('+593 2 200 0000').should be_truthy
|
80
|
+
Phony.plausible?('+593 2 300 0000').should be_truthy
|
81
|
+
Phony.plausible?('+593 2 400 0000').should be_truthy
|
82
|
+
Phony.plausible?('+593 2 500 0000').should be_truthy
|
83
|
+
Phony.plausible?('+593 2 700 0000').should be_truthy
|
84
|
+
Phony.plausible?('+593 3 000 0000').should be_truthy
|
85
|
+
Phony.plausible?('+593 4 000 0000').should be_truthy
|
86
|
+
Phony.plausible?('+593 4 500 0000').should be_truthy
|
87
|
+
Phony.plausible?('+593 4 600 0000').should be_truthy
|
88
|
+
Phony.plausible?('+593 5 200 0000').should be_truthy
|
89
|
+
Phony.plausible?('+593 5 300 0000').should be_truthy
|
90
|
+
Phony.plausible?('+593 6 200 0000').should be_truthy
|
91
|
+
Phony.plausible?('+593 7 200 0000').should be_truthy
|
92
|
+
Phony.plausible?('+593 7 300 0000').should be_truthy
|
93
|
+
Phony.plausible?('+593 7 400 0000').should be_truthy
|
94
|
+
Phony.plausible?('+593 7 600 0000').should be_truthy
|
95
|
+
Phony.plausible?('+593 9 0000 0000').should be_truthy # mobile
|
96
96
|
end
|
97
97
|
it_is_correct_for 'Equatorial Guinea', :samples => ['+240 222 201 123',
|
98
98
|
'+240 335 201 123']
|
@@ -102,21 +102,21 @@ describe 'plausibility' do
|
|
102
102
|
it_is_correct_for 'Faroe Islands', :samples => '+298 969 597'
|
103
103
|
it_is_correct_for 'Fiji (Republic of)', :samples => '+679 998 2441'
|
104
104
|
it 'is correct for Finland' do
|
105
|
-
Phony.plausible?('+358 50 123 4').should
|
106
|
-
Phony.plausible?('+358 50 123 45').should
|
107
|
-
Phony.plausible?('+358 50 123 45 6').should
|
108
|
-
Phony.plausible?('+358 50 123 45 67').should
|
109
|
-
Phony.plausible?('+358 50 123 45 678').should
|
110
|
-
Phony.plausible?('+358 49 123 456 789').should
|
111
|
-
Phony.plausible?('+358 18 1234').should
|
112
|
-
Phony.plausible?('+358 9 1234').should
|
113
|
-
Phony.plausible?('+358 9 123 45').should
|
114
|
-
Phony.plausible?('+358 9 123 456').should
|
115
|
-
Phony.plausible?('+358 9 123 4567').should
|
116
|
-
Phony.plausible?('+358 20 1470 740').should
|
117
|
-
Phony.plausible?('+358 29 123 4567').should
|
118
|
-
Phony.plausible?('+358 75323 1234').should
|
119
|
-
Phony.plausible?('+358 50 123 456 789').should
|
105
|
+
Phony.plausible?('+358 50 123 4').should be_truthy
|
106
|
+
Phony.plausible?('+358 50 123 45').should be_truthy
|
107
|
+
Phony.plausible?('+358 50 123 45 6').should be_truthy
|
108
|
+
Phony.plausible?('+358 50 123 45 67').should be_truthy
|
109
|
+
Phony.plausible?('+358 50 123 45 678').should be_truthy
|
110
|
+
Phony.plausible?('+358 49 123 456 789').should be_truthy
|
111
|
+
Phony.plausible?('+358 18 1234').should be_truthy
|
112
|
+
Phony.plausible?('+358 9 1234').should be_truthy
|
113
|
+
Phony.plausible?('+358 9 123 45').should be_truthy
|
114
|
+
Phony.plausible?('+358 9 123 456').should be_truthy
|
115
|
+
Phony.plausible?('+358 9 123 4567').should be_truthy
|
116
|
+
Phony.plausible?('+358 20 1470 740').should be_truthy
|
117
|
+
Phony.plausible?('+358 29 123 4567').should be_truthy
|
118
|
+
Phony.plausible?('+358 75323 1234').should be_truthy
|
119
|
+
Phony.plausible?('+358 50 123 456 789').should be_falsey
|
120
120
|
end
|
121
121
|
it_is_correct_for 'French Guiana (French Department of)', :samples => '+594 594 123 456'
|
122
122
|
it_is_correct_for "French Polynesia (Territoire français d'outre-mer)", :samples => '+689 87 27 84 00'
|
@@ -177,9 +177,9 @@ describe 'plausibility' do
|
|
177
177
|
'+961 81 123 456']
|
178
178
|
it_is_correct_for 'Lesotho', :samples => '+266 7612 6866'
|
179
179
|
it 'is correct for Liberia' do
|
180
|
-
Phony.plausible?('+231 2 123 4567').should
|
181
|
-
Phony.plausible?('+231 4 123 456').should
|
182
|
-
Phony.plausible?('+231 77 123 4567').should
|
180
|
+
Phony.plausible?('+231 2 123 4567').should be_truthy
|
181
|
+
Phony.plausible?('+231 4 123 456').should be_truthy
|
182
|
+
Phony.plausible?('+231 77 123 4567').should be_truthy
|
183
183
|
end
|
184
184
|
it_is_correct_for 'Macao', :samples => ['+853 28 12 3456',
|
185
185
|
'+853 8 123 4567',
|
@@ -219,8 +219,8 @@ describe 'plausibility' do
|
|
219
219
|
'+977 98 1234 5678']
|
220
220
|
it_is_correct_for "New Caledonia (Territoire français d'outre-mer)", :samples => '+687 546 835'
|
221
221
|
it 'is correct for New Zealand' do
|
222
|
-
Phony.plausible?('+64800123123').should
|
223
|
-
Phony.plausible?('+648001231234').should
|
222
|
+
Phony.plausible?('+64800123123').should be_truthy # Free phone
|
223
|
+
Phony.plausible?('+648001231234').should be_truthy # Free phone
|
224
224
|
end
|
225
225
|
it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
|
226
226
|
it_is_correct_for 'Niger', :samples => '+227 1234 5678'
|
@@ -378,11 +378,11 @@ describe 'plausibility' do
|
|
378
378
|
'+967 77 123 4567',
|
379
379
|
'+967 58 1234']
|
380
380
|
it 'is correct for Zambia' do
|
381
|
-
Phony.plausible?('+260 211 123456').should
|
382
|
-
Phony.plausible?('+260 955 123456').should
|
383
|
-
Phony.plausible?('+260 967 123456').should
|
384
|
-
Phony.plausible?('+260 978 123456').should
|
385
|
-
Phony.plausible?('+260 800 123 456').should
|
381
|
+
Phony.plausible?('+260 211 123456').should be_truthy # Fixed
|
382
|
+
Phony.plausible?('+260 955 123456').should be_truthy # Mobile
|
383
|
+
Phony.plausible?('+260 967 123456').should be_truthy # Mobile
|
384
|
+
Phony.plausible?('+260 978 123456').should be_truthy # Mobile
|
385
|
+
Phony.plausible?('+260 800 123 456').should be_truthy # Toll free
|
386
386
|
end
|
387
387
|
it_is_correct_for 'Zimbabwe', :samples => [['+263 2582 123 456', '+263 2582 123'],
|
388
388
|
['+263 147 123 456', '+263 147 123'],
|
@@ -390,15 +390,15 @@ describe 'plausibility' do
|
|
390
390
|
'+263 86 1235 4567']
|
391
391
|
|
392
392
|
it 'is correct for Indonesia' do
|
393
|
-
Phony.plausible?('+62 22 000 0').should
|
394
|
-
Phony.plausible?('+62 22 000 00').should
|
395
|
-
Phony.plausible?('+62 22 000 0000').should
|
396
|
-
Phony.plausible?('+62 22 0000 0000').should
|
397
|
-
Phony.plausible?('+62 22 000 000 000').should
|
393
|
+
Phony.plausible?('+62 22 000 0').should be_falsey
|
394
|
+
Phony.plausible?('+62 22 000 00').should be_truthy
|
395
|
+
Phony.plausible?('+62 22 000 0000').should be_truthy
|
396
|
+
Phony.plausible?('+62 22 0000 0000').should be_truthy
|
397
|
+
Phony.plausible?('+62 22 000 000 000').should be_truthy
|
398
398
|
end
|
399
399
|
|
400
400
|
it 'is correct for Russia' do
|
401
|
-
Phony.plausible?('+7 3522 000 000').should
|
401
|
+
Phony.plausible?('+7 3522 000 000').should be_truthy
|
402
402
|
end
|
403
403
|
end
|
404
404
|
end
|
@@ -356,6 +356,7 @@ describe 'country descriptions' do
|
|
356
356
|
it_splits '62877123456', %w(62 877 123 456)
|
357
357
|
it_splits '62881123456', %w(62 881 123 456)
|
358
358
|
it_splits '6288112345656', %w(62 881 1234 5656)
|
359
|
+
it_splits '62881123456567', %w(62 881 1234 56567)
|
359
360
|
it_splits '628990344805', %w(62 899 034 4805)
|
360
361
|
it_splits '6291234567', %w(62 9 1234 567)
|
361
362
|
it_splits '629123456789', %w(62 9 123 456 789)
|
@@ -53,35 +53,35 @@ describe Phony::LocalSplitters::Regex do
|
|
53
53
|
context 'Local splitter without mappings' do
|
54
54
|
let(:local_splitter) { described_class.instance_for({})}
|
55
55
|
it 'returns false' do
|
56
|
-
result.should
|
56
|
+
result.should be_falsey
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'Mapping does not exist for a number' do
|
61
61
|
let(:local_splitter) { described_class.instance_for(/\A5/ => [1,2,3])}
|
62
62
|
it 'returns false' do
|
63
|
-
result.should
|
63
|
+
result.should be_falsey
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
context "Mapping exists, but the length is greater" do
|
68
68
|
let(:local_splitter) { described_class.instance_for(/\A123/ => [2,2])}
|
69
69
|
it 'returns false' do
|
70
|
-
result.should
|
70
|
+
result.should be_falsey
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
context "Mapping exists, but the length is less" do
|
75
75
|
let(:local_splitter) { described_class.instance_for(/\A123/ => [2,2,3])}
|
76
76
|
it 'returns false' do
|
77
|
-
result.should
|
77
|
+
result.should be_falsey
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
context 'Mapping exists and the length is equal' do
|
82
82
|
let(:local_splitter) { described_class.instance_for(/\A123/ => [2,2,2])}
|
83
83
|
it 'returns true' do
|
84
|
-
result.should
|
84
|
+
result.should be_truthy
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Phony do
|
4
|
+
|
5
|
+
describe described_class::NormalizationError do
|
6
|
+
it 'is correctly raised on normalize' do
|
7
|
+
expect do
|
8
|
+
described_class.normalize('000')
|
9
|
+
end.to raise_error(described_class::NormalizationError)
|
10
|
+
end
|
11
|
+
it 'is correctly raised on normalize' do
|
12
|
+
expect do
|
13
|
+
described_class.normalize('000')
|
14
|
+
end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
|
15
|
+
end
|
16
|
+
it 'is correctly raised on normalize!' do
|
17
|
+
expect do
|
18
|
+
described_class.normalize!('000')
|
19
|
+
end.to raise_error(described_class::NormalizationError)
|
20
|
+
end
|
21
|
+
it 'is correctly raised on normalize!' do
|
22
|
+
expect do
|
23
|
+
described_class.normalize!('000')
|
24
|
+
end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe described_class::SplittingError do
|
29
|
+
it 'is correctly raised on split' do
|
30
|
+
expect do
|
31
|
+
described_class.split('000')
|
32
|
+
end.to raise_error(described_class::SplittingError)
|
33
|
+
end
|
34
|
+
it 'is correctly raised on split' do
|
35
|
+
expect do
|
36
|
+
described_class.split('000')
|
37
|
+
end.to raise_error(%Q{Phony could not split the given number. Is "000" a phone number?})
|
38
|
+
end
|
39
|
+
it 'is correctly raised on split!' do
|
40
|
+
expect do
|
41
|
+
described_class.split!('000')
|
42
|
+
end.to raise_error(described_class::SplittingError)
|
43
|
+
end
|
44
|
+
it 'is correctly raised on split!' do
|
45
|
+
expect do
|
46
|
+
described_class.split!('000')
|
47
|
+
end.to raise_error(%Q{Phony could not split the given number. Is it a phone number?})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe described_class::FormattingError do
|
52
|
+
it 'is correctly raised on format' do
|
53
|
+
expect do
|
54
|
+
described_class.format('000')
|
55
|
+
end.to raise_error(described_class::FormattingError)
|
56
|
+
end
|
57
|
+
it 'is correctly raised on format' do
|
58
|
+
expect do
|
59
|
+
described_class.format('000')
|
60
|
+
end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
|
61
|
+
end
|
62
|
+
it 'is correctly raised on format!' do
|
63
|
+
expect do
|
64
|
+
described_class.format!('000')
|
65
|
+
end.to raise_error(described_class::FormattingError)
|
66
|
+
end
|
67
|
+
it 'is correctly raised on format!' do
|
68
|
+
expect do
|
69
|
+
described_class.format!('000')
|
70
|
+
end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
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.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-08 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
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- spec/lib/phony/national_splitters/regex_spec.rb
|
92
92
|
- spec/lib/phony/national_splitters/variable_spec.rb
|
93
93
|
- spec/lib/phony/vanity_spec.rb
|
94
|
+
- spec/lib/phony_spec.rb
|
94
95
|
homepage: http://github.com/floere/phony
|
95
96
|
licenses:
|
96
97
|
- MIT
|
@@ -131,3 +132,4 @@ test_files:
|
|
131
132
|
- spec/lib/phony/national_splitters/regex_spec.rb
|
132
133
|
- spec/lib/phony/national_splitters/variable_spec.rb
|
133
134
|
- spec/lib/phony/vanity_spec.rb
|
135
|
+
- spec/lib/phony_spec.rb
|