phony 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/lib/phony/countries/austria.rb +2 -1
- data/lib/phony/countries/ireland.rb +2 -1
- data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +6 -6
- data/lib/phony/countries.rb +7 -3
- data/lib/phony/country.rb +6 -4
- data/lib/phony/national_splitters/fixed.rb +1 -1
- data/lib/phony/trunk_code.rb +12 -4
- data/spec/lib/phony/countries_spec.rb +8 -8
- data/spec/lib/phony/country_codes_spec.rb +6 -4
- data/spec/lib/phony/country_spec.rb +3 -3
- data/spec/lib/phony/national_code_spec.rb +4 -4
- data/spec/lib/phony/national_splitters/fixed_spec.rb +6 -6
- data/spec/lib/phony/national_splitters/regex_spec.rb +1 -1
- data/spec/lib/phony/national_splitters/variable_spec.rb +5 -5
- data/spec/lib/phony_spec.rb +30 -16
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MzYwODJhZmJkNjU2MGUyMDhmZDc2NDM1OGNkYmQ4MzJjN2U2NDYwOWNlMGNh
|
10
|
-
ZDViOGFiNGJjYWUwZTlkY2FkYjhiZjNhNTg1ODZlNjRhMDU2NjhjNDE0NjEz
|
11
|
-
ZjJhNDI1MGRlOWUwYWFmYzkyMTE1ODE4NmZhZDUzZWFkYmIxMDA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzU3Y2FlOGMwMTkzNTBhZDQyZTU0NDIyZDdkZWU5ZmVhMDY3MTgwZDI5ZDJl
|
14
|
-
NWMwNGU3YmQyZGFlMWMzNTJkYTI2YWYzYTIyNDY1MDgwY2M2YTJlMDI4NTdj
|
15
|
-
NWQ1MTc3YzRlZDEzZGExNDhlZDc2OTRjMjc4NTdmNTUyOGQwYjk=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ffd6c59da8ff1d1b85f32f5caf0203fa49795df3
|
4
|
+
data.tar.gz: c470c3d8f4d599afd2a99f9f85ad9dc2dda12751
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 40fc9bd07e284289fe77be2a92c78acd98713a495995a63779641960773f36ae211ca70215297b7846079014bbf38e486c22191aaef6c382c55f82856cf8b029
|
7
|
+
data.tar.gz: 25dd2c0b3a98cd81a6d4919856231a525b2bb3d241df085bccea5beba790edf152e7b7314e10b3ab5e32cf7c373f055965604aced8af2b1c94919a93a1ae080c
|
@@ -83,7 +83,8 @@ service = [
|
|
83
83
|
# TODO Add more details.
|
84
84
|
#
|
85
85
|
Phony.define do
|
86
|
-
country '43',
|
86
|
+
country '43', trunk('0') |
|
87
|
+
one_of('1') >> split(3..12) | # Vienna
|
87
88
|
one_of(service) >> split(9..9) |
|
88
89
|
one_of(corporate) >> split(5..5) |
|
89
90
|
one_of(ndcs) >> split(6..6) |
|
@@ -64,7 +64,8 @@ freefone = [
|
|
64
64
|
]
|
65
65
|
|
66
66
|
Phony.define do
|
67
|
-
country '353',
|
67
|
+
country '353', trunk('0') |
|
68
|
+
one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
|
68
69
|
one_of(ndcs_with_5_subscriber_digits) >> split(5) |
|
69
70
|
one_of(ndcs_with_6_subscriber_digits) >> split(6) |
|
70
71
|
one_of(freefone) >> split(6) |
|
@@ -119,10 +119,10 @@ ndcs_with_7_subscriber_digits = %w(342 343 347 351 383 391 473 495 496 498 499 8
|
|
119
119
|
Phony.define do
|
120
120
|
country '7',
|
121
121
|
trunk('8') |
|
122
|
-
one_of(ndcs_with_5_subscriber_digits) >> split(1,
|
123
|
-
one_of(ndcs_with_6_subscriber_digits) >> split(2,
|
124
|
-
one_of(ndcs_with_7_subscriber_digits) >> split(3,
|
125
|
-
one_of(%w(800)) >> split(3,
|
126
|
-
one_of(%w(995344 9971 99744 9976 997)) >> split(2,
|
127
|
-
fixed(3) >> split(2,
|
122
|
+
one_of(ndcs_with_5_subscriber_digits) >> split(1, 4) |
|
123
|
+
one_of(ndcs_with_6_subscriber_digits) >> split(2, 4) |
|
124
|
+
one_of(ndcs_with_7_subscriber_digits) >> split(3, 4) |
|
125
|
+
one_of(%w(800)) >> split(3, 4) | # Russia free number
|
126
|
+
one_of(%w(995344 9971 99744 9976 997)) >> split(2, 4) | # South Osetia
|
127
|
+
fixed(3) >> split(2, 5)
|
128
128
|
end
|
data/lib/phony/countries.rb
CHANGED
@@ -6,11 +6,14 @@
|
|
6
6
|
# As soon as a NDC matches, it goes on to the National part. Then breaks off.
|
7
7
|
# If the NDC does not match, it go on to the next (|, or "or") NDC.
|
8
8
|
#
|
9
|
+
# For the pre-ndc part, there's:
|
10
|
+
# * trunk: If the country has a trunk code (options normalize/split – remove trunk on these method, default false).
|
11
|
+
#
|
9
12
|
# Available matching/splitting methods:
|
10
13
|
# * none: Does not have a national destination code, e.g. Denmark, Iceland.
|
11
14
|
# * one_of: Matches one of the following numbers. Splits if it does.
|
12
15
|
# * match: Try to match the regex, and if it matches, splits it off.
|
13
|
-
# * fixed: Always splits off a fixed length ndc. (Always use last in a | chain as a catchall)
|
16
|
+
# * fixed: Always splits off a fixed length ndc. (Always use last in a | chain as a catchall)
|
14
17
|
#
|
15
18
|
# For the national number part, there are two:
|
16
19
|
# * split: Use this number group splitting.
|
@@ -28,8 +31,8 @@ Phony.define do
|
|
28
31
|
# USA, Canada, etc.
|
29
32
|
#
|
30
33
|
country '1',
|
31
|
-
trunk('1') |
|
32
|
-
fixed(3
|
34
|
+
trunk('1', normalize: true) | # http://en.wikipedia.org/wiki/Trunk_prefix
|
35
|
+
fixed(3) >> split(3,4),
|
33
36
|
:invalid_ndcs => ['911']
|
34
37
|
|
35
38
|
# Kazakhstan (Republic of) & Russsian Federation.
|
@@ -110,6 +113,7 @@ Phony.define do
|
|
110
113
|
# Switzerland.
|
111
114
|
#
|
112
115
|
country '41',
|
116
|
+
trunk('0', normalize: true) |
|
113
117
|
match(/^(8(00|4[0248]))\d+$/) >> split(3,3)|
|
114
118
|
fixed(2) >> split(3,2,2)
|
115
119
|
|
data/lib/phony/country.rb
CHANGED
@@ -14,7 +14,7 @@ module Phony
|
|
14
14
|
|
15
15
|
# Chain two codes together.
|
16
16
|
#
|
17
|
-
def |
|
17
|
+
def | other
|
18
18
|
self.codes = self.codes + other.codes
|
19
19
|
self
|
20
20
|
end
|
@@ -33,13 +33,15 @@ module Phony
|
|
33
33
|
# Note: If the ndc is nil, it will not return it.
|
34
34
|
#
|
35
35
|
def split national_number
|
36
|
+
trunk = nil
|
36
37
|
@codes.each do |code|
|
37
|
-
|
38
|
-
|
38
|
+
new_trunk, ndc, *rest = code.split national_number
|
39
|
+
trunk ||= new_trunk
|
40
|
+
return [trunk, ndc, *rest] if rest && !rest.empty?
|
39
41
|
end
|
40
42
|
# Best effort in error case.
|
41
43
|
#
|
42
|
-
[
|
44
|
+
[trunk, national_number, []]
|
43
45
|
end
|
44
46
|
def split_ndc national_number
|
45
47
|
@codes.each do |code|
|
data/lib/phony/trunk_code.rb
CHANGED
@@ -2,9 +2,17 @@ module Phony
|
|
2
2
|
|
3
3
|
class TrunkCode
|
4
4
|
|
5
|
+
# Parameters:
|
6
|
+
# * code: The trunk code, e.g. 0.
|
7
|
+
#
|
8
|
+
# Options:
|
9
|
+
# * normalize: Remove the trunk code when normalizing (only use if number scheme is defined unambiguously).
|
10
|
+
# * split: Remove the trunk code when splitting (only use if number scheme is defined unambiguously).
|
11
|
+
#
|
5
12
|
def initialize code, options = {}
|
13
|
+
@code = code
|
6
14
|
@trunk_code_replacement = /\A#{code}/
|
7
|
-
@normalize = options[:normalize]
|
15
|
+
@normalize = options[:normalize]
|
8
16
|
@split = options[:split]
|
9
17
|
end
|
10
18
|
|
@@ -20,12 +28,12 @@ module Phony
|
|
20
28
|
#
|
21
29
|
def split national_number
|
22
30
|
national_number.gsub! @trunk_code_replacement, EMPTY_STRING if @split
|
23
|
-
return [
|
31
|
+
return [@code, national_number]
|
24
32
|
end
|
25
33
|
|
26
34
|
def normalize national_number
|
27
|
-
|
28
|
-
national_number
|
35
|
+
national_number.gsub! @trunk_code_replacement, EMPTY_STRING if @normalize
|
36
|
+
return national_number
|
29
37
|
end
|
30
38
|
|
31
39
|
end
|
@@ -508,14 +508,14 @@ describe 'country descriptions' do
|
|
508
508
|
it_splits '40249123123', ['40', '249', '123', '123'] # Olt
|
509
509
|
end
|
510
510
|
describe 'Russia' do
|
511
|
-
it_splits '78122345678', ['7', '812', '234', '
|
512
|
-
it_splits '74012771077', ['7', '4012', '77', '
|
513
|
-
it_splits '78402411212', ['7', '84024', '1', '
|
514
|
-
it_splits '79296119119', ['7', '929', '611', '
|
515
|
-
it_splits '7840121212', ['7', '840', '12', '
|
516
|
-
it_splits '7799121212', ['7', '799', '12', '
|
517
|
-
it_splits '7995344121212', ['7','995344','12','
|
518
|
-
it_splits '7209175276', ['7', '209', '17', '
|
511
|
+
it_splits '78122345678', ['7', '812', '234', '5678'] # Russia 3-digit
|
512
|
+
it_splits '74012771077', ['7', '4012', '77', '1077'] # Russia 4-digit
|
513
|
+
it_splits '78402411212', ['7', '84024', '1', '1212'] # Russia 5-digit
|
514
|
+
it_splits '79296119119', ['7', '929', '611', '9119'] # Russia 3-digit, Megafon Mobile.
|
515
|
+
it_splits '7840121212', ['7', '840', '12', '1212'] # Abhasia
|
516
|
+
it_splits '7799121212', ['7', '799', '12', '1212'] # Kazachstan
|
517
|
+
it_splits '7995344121212', ['7','995344','12','1212'] # South Osetia
|
518
|
+
it_splits '7209175276', ['7', '209', '17', '5276'] # Fantasy number
|
519
519
|
end
|
520
520
|
describe 'Rwanda' do
|
521
521
|
it_splits '250781234567', ['250', '78', '1234567'] # mobile
|
@@ -40,7 +40,9 @@ describe Phony::CountryCodes do
|
|
40
40
|
old_format = @countries.national_format
|
41
41
|
@countries.national_format = '%s%s'
|
42
42
|
|
43
|
-
|
43
|
+
# Removes CC 1, but adds national call prefix 1.
|
44
|
+
#
|
45
|
+
@countries.formatted('11231231234', :format => :national).should eql '1123 123 1234'
|
44
46
|
|
45
47
|
@countries.national_format = old_format
|
46
48
|
end
|
@@ -63,13 +65,13 @@ describe Phony::CountryCodes do
|
|
63
65
|
@countries.formatted('41443643532', :format => :national, :spaces => :-).should eql '044-364-35-32'
|
64
66
|
end
|
65
67
|
context 'specific' do
|
66
|
-
it 'formats
|
68
|
+
it 'formats Ireland correctly' do
|
67
69
|
@countries.formatted("3533451234", :format => :national).should eql '0345 1234'
|
68
70
|
end
|
69
|
-
it 'formats
|
71
|
+
it 'formats Ireland correctly' do
|
70
72
|
@countries.formatted("353411231234", :format => :national).should eql '041 123 1234'
|
71
73
|
end
|
72
|
-
it 'formats
|
74
|
+
it 'formats Spain correctly' do
|
73
75
|
@countries.formatted("34123456789", :format => :national).should eql '123 456 789'
|
74
76
|
end
|
75
77
|
end
|
@@ -29,7 +29,7 @@ describe Phony::Country do
|
|
29
29
|
|
30
30
|
describe "split" do
|
31
31
|
it "should handle ZH" do
|
32
|
-
@switzerland.split('443643532').should == [
|
32
|
+
@switzerland.split('443643532').should == [nil, '44', '364', '35', '32']
|
33
33
|
end
|
34
34
|
end
|
35
35
|
describe 'normalize' do
|
@@ -54,10 +54,10 @@ describe Phony::Country do
|
|
54
54
|
|
55
55
|
describe "split" do
|
56
56
|
it "should handle ZH" do
|
57
|
-
@switzerland.split('443643532').should == [
|
57
|
+
@switzerland.split('443643532').should == [nil, '44', '364', '35', '32']
|
58
58
|
end
|
59
59
|
it "should handle 800" do
|
60
|
-
@switzerland.split('800333666').should == [
|
60
|
+
@switzerland.split('800333666').should == [nil, '800', '333', '666']
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -24,10 +24,10 @@ describe Phony::NationalCode do
|
|
24
24
|
@national = Phony::NationalCode.new national_splitter, local_splitter
|
25
25
|
end
|
26
26
|
it 'splits correctly' do
|
27
|
-
@national.split('443643532').should == [
|
27
|
+
@national.split('443643532').should == [nil, '44', '364', '35', '32']
|
28
28
|
end
|
29
29
|
it 'splits correctly' do
|
30
|
-
@national.split('44364353').should == [
|
30
|
+
@national.split('44364353').should == [nil, '44', '364', '35', '3']
|
31
31
|
end
|
32
32
|
it 'normalizes correctly' do
|
33
33
|
@national.normalize('044364353').should == '44364353'
|
@@ -44,10 +44,10 @@ describe Phony::NationalCode do
|
|
44
44
|
@national = Phony::NationalCode.new national_splitter, local_splitter
|
45
45
|
end
|
46
46
|
it 'splits correctly' do
|
47
|
-
@national.split('142278186').should == [
|
47
|
+
@national.split('142278186').should == [nil, '1', '42', '27', '81', '86']
|
48
48
|
end
|
49
49
|
it 'splits correctly' do
|
50
|
-
@national.split('14227818').should == [
|
50
|
+
@national.split('14227818').should == [nil, '1', '42', '27', '81', '8']
|
51
51
|
end
|
52
52
|
it 'normalizes correctly' do
|
53
53
|
@national.normalize('0142278186').should == '142278186'
|
@@ -16,13 +16,13 @@ describe Phony::NationalSplitters::Fixed do
|
|
16
16
|
@splitter = Phony::NationalSplitters::Fixed.new 2
|
17
17
|
end
|
18
18
|
it 'splits correctly' do
|
19
|
-
@splitter.split('443643532').should == [
|
19
|
+
@splitter.split('443643532').should == [nil, '44', '3643532']
|
20
20
|
end
|
21
21
|
it 'splits correctly even when the number is too long' do
|
22
|
-
@splitter.split('44364353211').should == [
|
22
|
+
@splitter.split('44364353211').should == [nil, '44', '364353211']
|
23
23
|
end
|
24
24
|
it 'splits correctly even when the number is too short' do
|
25
|
-
@splitter.split('443').should == [
|
25
|
+
@splitter.split('443').should == [nil, '44','3']
|
26
26
|
end
|
27
27
|
end
|
28
28
|
describe 'split' do
|
@@ -30,13 +30,13 @@ describe Phony::NationalSplitters::Fixed do
|
|
30
30
|
@splitter = Phony::NationalSplitters::Fixed.new nil
|
31
31
|
end
|
32
32
|
it 'splits correctly' do
|
33
|
-
@splitter.split('443643532').should == [
|
33
|
+
@splitter.split('443643532').should == [nil, '443643532']
|
34
34
|
end
|
35
35
|
it 'splits correctly even when the number is too long' do
|
36
|
-
@splitter.split('44364353211').should == [
|
36
|
+
@splitter.split('44364353211').should == [nil, '44364353211']
|
37
37
|
end
|
38
38
|
it 'splits correctly even when the number is too short' do
|
39
|
-
@splitter.split('443').should == [
|
39
|
+
@splitter.split('443').should == [nil, '443']
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -15,7 +15,7 @@ describe Phony::NationalSplitters::Regex do
|
|
15
15
|
context 'with on_fail 2' do
|
16
16
|
let(:splitter) { described_class.instance_for(/^(123)\d+$/, 2) }
|
17
17
|
it 'uses the on_fail_take' do
|
18
|
-
splitter.split('23456789').should == [
|
18
|
+
splitter.split('23456789').should == [nil, '23', '456789']
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -8,16 +8,16 @@ describe Phony::NationalSplitters::Variable do
|
|
8
8
|
@splitter = Phony::NationalSplitters::Variable.new 4, ['1', '316', '67', '68', '669', '711']
|
9
9
|
end
|
10
10
|
it "handles Vienna" do
|
11
|
-
@splitter.split('198110').should == [
|
11
|
+
@splitter.split('198110').should == [nil, '1', '98110']
|
12
12
|
end
|
13
13
|
it "handles some mobile services" do
|
14
|
-
@splitter.split('66914093902').should == [
|
14
|
+
@splitter.split('66914093902').should == [nil, '669', '14093902']
|
15
15
|
end
|
16
16
|
it "handles Graz" do
|
17
|
-
@splitter.split('3161234567891').should == [
|
17
|
+
@splitter.split('3161234567891').should == [nil, '316', '1234567891']
|
18
18
|
end
|
19
19
|
it "handles Rohrau" do
|
20
|
-
@splitter.split('2164123456789').should == [
|
20
|
+
@splitter.split('2164123456789').should == [nil, '2164', '123456789']
|
21
21
|
end
|
22
22
|
end
|
23
23
|
context 'special handling for using the variable size splitter for Swiss service numbers' do
|
@@ -25,7 +25,7 @@ describe Phony::NationalSplitters::Variable do
|
|
25
25
|
@splitter = Phony::NationalSplitters::Variable.new 2, ['800']
|
26
26
|
end
|
27
27
|
it "should handle swiss service numbers" do
|
28
|
-
@splitter.split('800223344').should == [
|
28
|
+
@splitter.split('800223344').should == [nil, '800', '223344']
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/spec/lib/phony_spec.rb
CHANGED
@@ -6,8 +6,10 @@ describe Phony do
|
|
6
6
|
|
7
7
|
describe 'regression' do
|
8
8
|
it '#151' do
|
9
|
-
|
10
|
-
|
9
|
+
# Normalizes, but this is a non-real case.
|
10
|
+
#
|
11
|
+
described_class.normalize('1-111-111-1111').should == '1111111111'
|
12
|
+
described_class.normalize('111-111-1111', cc: '1').should == '1111111111'
|
11
13
|
end
|
12
14
|
it 'best effort #152' do
|
13
15
|
described_class.split('39694805123').should == ['39', '694805123', []]
|
@@ -71,9 +73,6 @@ describe Phony do
|
|
71
73
|
it 'should normalize a number with colons' do
|
72
74
|
Phony.normalize('1.906.387.1698').should eql '19063871698'
|
73
75
|
end
|
74
|
-
it 'should normalize a number with optional ndc' do
|
75
|
-
Phony.normalize('+41 (044) 364 35 33').should eql '41443643533'
|
76
|
-
end
|
77
76
|
it 'should normalize a number with erroneous zero inside' do
|
78
77
|
Phony.normalize('+410443643533').should eql '41443643533'
|
79
78
|
end
|
@@ -81,15 +80,15 @@ describe Phony do
|
|
81
80
|
Phony.normalize('+390909709511').should eql '390909709511'
|
82
81
|
end
|
83
82
|
|
84
|
-
context 'special trunk prefixes' do
|
83
|
+
context 'special trunk prefixes are not handled' do
|
85
84
|
it 'normalizes Hungary' do
|
86
|
-
Phony.normalize('36 0630245506').should eql '
|
85
|
+
Phony.normalize('36 0630245506').should eql '360630245506'
|
87
86
|
end
|
88
87
|
it 'normalizes Russia' do
|
89
|
-
Phony.normalize('7 8 342 1234567').should eql '
|
88
|
+
Phony.normalize('7 8 342 1234567').should eql '783421234567'
|
90
89
|
end
|
91
90
|
it 'normalizes Lithuania' do
|
92
|
-
Phony.normalize('370 8 5 1234567').should eql '
|
91
|
+
Phony.normalize('370 8 5 1234567').should eql '370851234567'
|
93
92
|
end
|
94
93
|
it 'normalizes Belarus' do
|
95
94
|
Phony.normalize('375 152450911').should eql '375152450911'
|
@@ -124,18 +123,21 @@ describe Phony do
|
|
124
123
|
end
|
125
124
|
end
|
126
125
|
describe 'default' do
|
127
|
-
it 'should format
|
126
|
+
it 'should format Swiss numbers' do
|
128
127
|
Phony.format('41443643532').should eql '+41 44 364 35 32'
|
129
128
|
end
|
129
|
+
it 'should format Swiss national numbers' do
|
130
|
+
Phony.format('41443643532', :format => :national).should eql '044 364 35 32'
|
131
|
+
end
|
130
132
|
# TODO
|
131
133
|
#
|
132
|
-
it 'should format
|
134
|
+
it 'should format Swiss service numbers' do
|
133
135
|
Phony.format('41800112233').should eql '+41 800 112 233'
|
134
136
|
end
|
135
|
-
it 'should format
|
137
|
+
it 'should format Austrian numbers' do
|
136
138
|
Phony.format('43198110').should eql '+43 1 98110'
|
137
139
|
end
|
138
|
-
it 'should format
|
140
|
+
it 'should format American numbers' do
|
139
141
|
Phony.format('18705551122').should eql '+1 870 555 1122'
|
140
142
|
end
|
141
143
|
it 'should format New Zealand 021 6-digit mobile numbers' do
|
@@ -153,6 +155,18 @@ describe Phony do
|
|
153
155
|
it 'should format Indian numbers' do
|
154
156
|
Phony.format('914433993939').should eql '+91 44 339 93 939'
|
155
157
|
end
|
158
|
+
it 'should format Russian numbers' do
|
159
|
+
Phony.format(Phony.normalize('+370 800 12345'), :format => :international).should eql '+370 800 12 345'
|
160
|
+
end
|
161
|
+
it 'should format Russian numbers' do
|
162
|
+
Phony.format(Phony.normalize('+7 812 123 4567'), :format => :international).should eql '+7 812 123 4567'
|
163
|
+
end
|
164
|
+
it 'should format Russian numbers' do
|
165
|
+
Phony.format(Phony.normalize('+370 800 12345'), :format => :national).should eql '8800 12 345'
|
166
|
+
end
|
167
|
+
it 'should format Russian numbers' do
|
168
|
+
Phony.format(Phony.normalize('+7 812 123 4567'), :format => :national).should eql '8812 123 4567'
|
169
|
+
end
|
156
170
|
end
|
157
171
|
describe 'international' do
|
158
172
|
it 'should format north american numbers' do
|
@@ -243,8 +257,8 @@ describe Phony do
|
|
243
257
|
it 'should format austrian numbers' do
|
244
258
|
Phony.format('43198110', :format => :national).should eql '01 98110'
|
245
259
|
end
|
246
|
-
it 'should format US numbers
|
247
|
-
Phony.format('14159224711', :format => :national).should eql '
|
260
|
+
it 'should format US numbers with a leading trunk 1' do
|
261
|
+
Phony.format('14159224711', :format => :national).should eql '1415 922 4711'
|
248
262
|
end
|
249
263
|
end
|
250
264
|
describe 'local' do
|
@@ -260,7 +274,7 @@ describe Phony do
|
|
260
274
|
context 'minimal cases' do
|
261
275
|
context 'normalizing' do
|
262
276
|
it "handles completely crazy 'numbers'" do
|
263
|
-
Phony.normalize('Hello, I am Cora, the 41th parrot, and
|
277
|
+
Phony.normalize('Hello, I am Cora, the 41th parrot, and 44 is my 364 times 35 funky number. 32.').should eql '41443643532'
|
264
278
|
end
|
265
279
|
end
|
266
280
|
context 'splitting' do
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: 'Fast international phone number (E164 standard) normalizing, splitting
|
14
14
|
and formatting. Lots of formatting options: International (+.., 00..), national
|
15
15
|
(0..), and local.'
|
16
16
|
email: florian.hanke+phony@gmail.com
|
@@ -19,6 +19,9 @@ extensions: []
|
|
19
19
|
extra_rdoc_files:
|
20
20
|
- README.textile
|
21
21
|
files:
|
22
|
+
- README.textile
|
23
|
+
- lib/phony.rb
|
24
|
+
- lib/phony/countries.rb
|
22
25
|
- lib/phony/countries/austria.rb
|
23
26
|
- lib/phony/countries/bangladesh.rb
|
24
27
|
- lib/phony/countries/belarus.rb
|
@@ -57,7 +60,6 @@ files:
|
|
57
60
|
- lib/phony/countries/uruguay.rb
|
58
61
|
- lib/phony/countries/vietnam.rb
|
59
62
|
- lib/phony/countries/zimbabwe.rb
|
60
|
-
- lib/phony/countries.rb
|
61
63
|
- lib/phony/country.rb
|
62
64
|
- lib/phony/country_codes.rb
|
63
65
|
- lib/phony/dsl.rb
|
@@ -72,8 +74,6 @@ files:
|
|
72
74
|
- lib/phony/national_splitters/variable.rb
|
73
75
|
- lib/phony/trunk_code.rb
|
74
76
|
- lib/phony/vanity.rb
|
75
|
-
- lib/phony.rb
|
76
|
-
- README.textile
|
77
77
|
- spec/functional/error_spec.rb
|
78
78
|
- spec/functional/normalize_spec.rb
|
79
79
|
- spec/functional/plausibility_spec.rb
|
@@ -100,17 +100,17 @@ require_paths:
|
|
100
100
|
- lib
|
101
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.2.2
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Fast international phone number (E164 standard) normalizing, splitting and
|