phony 2.16.5 → 2.16.6
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 +5 -5
- data/lib/phony/countries.rb +19 -8
- data/lib/phony/countries/malaysia.rb +5 -2
- data/spec/functional/plausibility_spec.rb +132 -0
- data/spec/lib/phony/countries_spec.rb +22 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a692a55cbcbd9468fce9e49b6ea2e866695de5b32683b8e70fdeed9148bc26fa
|
4
|
+
data.tar.gz: 339527a9c152e964205ddc42f4c701ede918aa36d3c4fb861335800c78ad9e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72558d720a71eeab6dd18b4b0c85c02e640688d0337a82a288434fec29c3f38df3b706ceef959f76b618b1c62f77bc8c792160c9f454115f419903ca8c9a15a6
|
7
|
+
data.tar.gz: bf64d35ba470fd802f5c63aec263703312ed5a3cf5266bc736c396d9c337ff3986619f90f733a94405e2fe935633fcfc0d57d24ccde9ab26ca06daaded00467f
|
data/lib/phony/countries.rb
CHANGED
@@ -685,13 +685,24 @@ Phony.define do
|
|
685
685
|
# Note: https://en.wikipedia.org/wiki/Telephone_numbers_in_Bulgaria
|
686
686
|
country '359',
|
687
687
|
trunk('0') |
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
688
|
+
match(/^(2)\d{6}$/) >> split(3,3) | # Landline Sofia (optional last digit)
|
689
|
+
match(/^(2)\d{7}$/) >> split(3,4) | # Landline Sofia (optional last digit)
|
690
|
+
match(/^(30|31|33|36|37|39|41|43\d|45|47|51|53|55|57|59)\d{5}$/) >> split(5) |
|
691
|
+
match(/^(30|31|32|33|34|35|36|37|38|39|41|42|44|45|46|47|51|52|53|54|55|56|57|58|59)\d{6}$/) >> split(2,4) |
|
692
|
+
|
693
|
+
match(/^(60|61|63|65|66|69)\d{5}$/) >> split(5) |
|
694
|
+
match(/^(60|61|62|63|64|65|66|68|69)\d{6}$/) >> split(6) |
|
695
|
+
|
696
|
+
match(/^(700|701|703|704|705|706|707|708|709)\d{5}$/) >> split(5) |
|
697
|
+
match(/^(701|702|703|704|705|706|707|708|709)\d{4}$/) >> split(4) |
|
698
|
+
|
699
|
+
match(/^(71|72|74|75|77)\d{5}$/) >> split(5) |
|
700
|
+
match(/^(71|72|73|74|75|76|77|78|79)\d{6}$/) >> split(6) |
|
701
|
+
|
702
|
+
match(/^(80\d|81|91|93|95|97)\d{5}$/) >> split(5) |
|
703
|
+
match(/^(81|82|84|86)\d{6}$/) >> split(6) |
|
704
|
+
match(/^(87|88|89)\d{7}$/) >> split(4,3) |
|
705
|
+
match(/^(90|91|92|93|94|95|96|97|98\d|99\d)\d{6}$/) >> split(6)
|
695
706
|
|
696
707
|
# Lithuania
|
697
708
|
#
|
@@ -1155,7 +1166,7 @@ Phony.define do
|
|
1155
1166
|
one_of(%w(500 700 900)) >> split(3,3) | # premium rate
|
1156
1167
|
one_of('800') >> matched_split(
|
1157
1168
|
/\A\d{2}\z/ => [2],
|
1158
|
-
/\A\d+\z/ => [2,3,4])
|
1169
|
+
/\A\d+\z/ => [2,3,4])| # freephone
|
1159
1170
|
one_of(%w(50 52 54 55 56 58)) >> split(3,4) | # mobile
|
1160
1171
|
one_of(%w(2 3 4 6 7 9)) >> split(3,4) |
|
1161
1172
|
fixed(1) >> split(3,4)
|
@@ -4,7 +4,6 @@
|
|
4
4
|
#
|
5
5
|
ndcs = [
|
6
6
|
'2', # Singapore
|
7
|
-
'3', # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
|
8
7
|
'4', # Kedah, Penang & Perlis
|
9
8
|
'5', # Perak & Cameron Highlands (Pahang)
|
10
9
|
'6', # Melaka, Negeri Sembilan & Muar (Johor)
|
@@ -14,6 +13,9 @@ ndcs = [
|
|
14
13
|
mobile = %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 }
|
15
14
|
# service = %w{ 100 101 102 103 104 108 991 994 995 999 } # Emergeny and Service numbers, only 3 digits long
|
16
15
|
freephone = %w{ 300 700 800 }
|
16
|
+
ndcs_eight = [
|
17
|
+
'3' # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
|
18
|
+
]
|
17
19
|
|
18
20
|
Phony.define do
|
19
21
|
country '60',
|
@@ -21,6 +23,7 @@ Phony.define do
|
|
21
23
|
one_of(freephone) >> split(2,4) | # Freephone, Tollfree, Forwarding
|
22
24
|
# one_of(service) >> none | # Service
|
23
25
|
one_of(mobile) >> split(3,4..5) | # Mobile
|
24
|
-
one_of(ndcs) >> split(
|
26
|
+
one_of(ndcs) >> split(7) | # 1-digit NDCs
|
27
|
+
one_of(ndcs_eight) >> split(8) | # 1-digit NDCs
|
25
28
|
fixed(2) >> split(8) # 2-digit NDCs (Also, fallback)
|
26
29
|
end
|
@@ -50,6 +50,134 @@ describe 'plausibility' do
|
|
50
50
|
it_is_correct_for 'Bosnia and Herzegovina', :samples => ['+387 66 666 666',
|
51
51
|
'+387 37 123 456',
|
52
52
|
'+387 33 222 111']
|
53
|
+
it 'is correct for Bulgaria' do
|
54
|
+
Phony.plausible?('+359 2 1234567').should be_truthy
|
55
|
+
Phony.plausible?('+359 30 12345').should be_truthy
|
56
|
+
Phony.plausible?('+359 30 123456').should be_truthy
|
57
|
+
Phony.plausible?('+359 31 12345').should be_truthy
|
58
|
+
Phony.plausible?('+359 31 123456').should be_truthy
|
59
|
+
Phony.plausible?('+359 32 123456').should be_truthy
|
60
|
+
Phony.plausible?('+359 33 12345').should be_truthy
|
61
|
+
Phony.plausible?('+359 33 123456').should be_truthy
|
62
|
+
Phony.plausible?('+359 34 123456').should be_truthy
|
63
|
+
Phony.plausible?('+359 35 123456').should be_truthy
|
64
|
+
Phony.plausible?('+359 36 12345').should be_truthy
|
65
|
+
Phony.plausible?('+359 36 123456').should be_truthy
|
66
|
+
Phony.plausible?('+359 37 12345').should be_truthy
|
67
|
+
Phony.plausible?('+359 37 123456').should be_truthy
|
68
|
+
Phony.plausible?('+359 38 123456').should be_truthy
|
69
|
+
Phony.plausible?('+359 39 12345').should be_truthy
|
70
|
+
Phony.plausible?('+359 39 123456').should be_truthy
|
71
|
+
Phony.plausible?('+359 41 12345').should be_truthy
|
72
|
+
Phony.plausible?('+359 41 123456').should be_truthy
|
73
|
+
Phony.plausible?('+359 42 123456').should be_truthy
|
74
|
+
Phony.plausible?('+359 430 12345').should be_truthy
|
75
|
+
Phony.plausible?('+359 431 12345').should be_truthy
|
76
|
+
Phony.plausible?('+359 432 12345').should be_truthy
|
77
|
+
Phony.plausible?('+359 433 12345').should be_truthy
|
78
|
+
Phony.plausible?('+359 434 12345').should be_truthy
|
79
|
+
Phony.plausible?('+359 435 12345').should be_truthy
|
80
|
+
Phony.plausible?('+359 436 12345').should be_truthy
|
81
|
+
Phony.plausible?('+359 437 12345').should be_truthy
|
82
|
+
Phony.plausible?('+359 438 12345').should be_truthy
|
83
|
+
Phony.plausible?('+359 439 12345').should be_truthy
|
84
|
+
Phony.plausible?('+359 44 123456').should be_truthy
|
85
|
+
Phony.plausible?('+359 45 12345').should be_truthy
|
86
|
+
Phony.plausible?('+359 45 123456').should be_truthy
|
87
|
+
Phony.plausible?('+359 46 123456').should be_truthy
|
88
|
+
Phony.plausible?('+359 47 12345').should be_truthy
|
89
|
+
Phony.plausible?('+359 47 123456').should be_truthy
|
90
|
+
Phony.plausible?('+359 47 12345').should be_truthy
|
91
|
+
Phony.plausible?('+359 47 123456').should be_truthy
|
92
|
+
Phony.plausible?('+359 51 12345').should be_truthy
|
93
|
+
Phony.plausible?('+359 51 123456').should be_truthy
|
94
|
+
Phony.plausible?('+359 52 123456').should be_truthy
|
95
|
+
Phony.plausible?('+359 53 12345').should be_truthy
|
96
|
+
Phony.plausible?('+359 53 123456').should be_truthy
|
97
|
+
Phony.plausible?('+359 54 123456').should be_truthy
|
98
|
+
Phony.plausible?('+359 55 12345').should be_truthy
|
99
|
+
Phony.plausible?('+359 55 123456').should be_truthy
|
100
|
+
Phony.plausible?('+359 56 123456').should be_truthy
|
101
|
+
Phony.plausible?('+359 57 12345').should be_truthy
|
102
|
+
Phony.plausible?('+359 57 123456').should be_truthy
|
103
|
+
Phony.plausible?('+359 58 123456').should be_truthy
|
104
|
+
Phony.plausible?('+359 59 12345').should be_truthy
|
105
|
+
Phony.plausible?('+359 59 123456').should be_truthy
|
106
|
+
Phony.plausible?('+359 60 12345').should be_truthy
|
107
|
+
Phony.plausible?('+359 60 123456').should be_truthy
|
108
|
+
Phony.plausible?('+359 61 12345').should be_truthy
|
109
|
+
Phony.plausible?('+359 61 123456').should be_truthy
|
110
|
+
Phony.plausible?('+359 62 123456').should be_truthy
|
111
|
+
Phony.plausible?('+359 63 12345').should be_truthy
|
112
|
+
Phony.plausible?('+359 63 123456').should be_truthy
|
113
|
+
Phony.plausible?('+359 64 123456').should be_truthy
|
114
|
+
Phony.plausible?('+359 65 12345').should be_truthy
|
115
|
+
Phony.plausible?('+359 65 123456').should be_truthy
|
116
|
+
Phony.plausible?('+359 66 12345').should be_truthy
|
117
|
+
Phony.plausible?('+359 66 123456').should be_truthy
|
118
|
+
Phony.plausible?('+359 68 123456').should be_truthy
|
119
|
+
Phony.plausible?('+359 69 12345').should be_truthy
|
120
|
+
Phony.plausible?('+359 69 123456').should be_truthy
|
121
|
+
Phony.plausible?('+359 700 12345').should be_truthy
|
122
|
+
Phony.plausible?('+359 701 1234').should be_truthy
|
123
|
+
Phony.plausible?('+359 701 12345').should be_truthy
|
124
|
+
Phony.plausible?('+359 71 12345').should be_truthy
|
125
|
+
Phony.plausible?('+359 71 123456').should be_truthy
|
126
|
+
Phony.plausible?('+359 72 12345').should be_truthy
|
127
|
+
Phony.plausible?('+359 72 123456').should be_truthy
|
128
|
+
Phony.plausible?('+359 73 123456').should be_truthy
|
129
|
+
Phony.plausible?('+359 74 12345').should be_truthy
|
130
|
+
Phony.plausible?('+359 74 123456').should be_truthy
|
131
|
+
Phony.plausible?('+359 75 12345').should be_truthy
|
132
|
+
Phony.plausible?('+359 75 123456').should be_truthy
|
133
|
+
Phony.plausible?('+359 76 123456').should be_truthy
|
134
|
+
Phony.plausible?('+359 77 12345').should be_truthy
|
135
|
+
Phony.plausible?('+359 77 123456').should be_truthy
|
136
|
+
Phony.plausible?('+359 78 123456').should be_truthy
|
137
|
+
Phony.plausible?('+359 79 123456').should be_truthy
|
138
|
+
Phony.plausible?('+359 800 12345').should be_truthy
|
139
|
+
Phony.plausible?('+359 81 12345').should be_truthy
|
140
|
+
Phony.plausible?('+359 81 123456').should be_truthy
|
141
|
+
Phony.plausible?('+359 82 123456').should be_truthy
|
142
|
+
Phony.plausible?('+359 82 123456').should be_truthy
|
143
|
+
Phony.plausible?('+359 84 123456').should be_truthy
|
144
|
+
Phony.plausible?('+359 86 123456').should be_truthy
|
145
|
+
Phony.plausible?('+359 87 1234567').should be_truthy
|
146
|
+
Phony.plausible?('+359 88 1234567').should be_truthy
|
147
|
+
Phony.plausible?('+359 89 1234567').should be_truthy
|
148
|
+
Phony.plausible?('+359 90 123456').should be_truthy
|
149
|
+
Phony.plausible?('+359 91 12345').should be_truthy
|
150
|
+
Phony.plausible?('+359 91 123456').should be_truthy
|
151
|
+
Phony.plausible?('+359 92 123456').should be_truthy
|
152
|
+
Phony.plausible?('+359 93 12345').should be_truthy
|
153
|
+
Phony.plausible?('+359 93 123456').should be_truthy
|
154
|
+
Phony.plausible?('+359 94 123456').should be_truthy
|
155
|
+
Phony.plausible?('+359 95 12345').should be_truthy
|
156
|
+
Phony.plausible?('+359 95 123456').should be_truthy
|
157
|
+
Phony.plausible?('+359 96 123456').should be_truthy
|
158
|
+
Phony.plausible?('+359 97 12345').should be_truthy
|
159
|
+
Phony.plausible?('+359 97 123456').should be_truthy
|
160
|
+
Phony.plausible?('+359 980 123456').should be_truthy
|
161
|
+
Phony.plausible?('+359 981 123456').should be_truthy
|
162
|
+
Phony.plausible?('+359 982 123456').should be_truthy
|
163
|
+
Phony.plausible?('+359 983 123456').should be_truthy
|
164
|
+
Phony.plausible?('+359 984 123456').should be_truthy
|
165
|
+
Phony.plausible?('+359 985 123456').should be_truthy
|
166
|
+
Phony.plausible?('+359 986 123456').should be_truthy
|
167
|
+
Phony.plausible?('+359 987 123456').should be_truthy
|
168
|
+
Phony.plausible?('+359 988 123456').should be_truthy
|
169
|
+
Phony.plausible?('+359 989 123456').should be_truthy
|
170
|
+
Phony.plausible?('+359 990 123456').should be_truthy
|
171
|
+
Phony.plausible?('+359 991 123456').should be_truthy
|
172
|
+
Phony.plausible?('+359 992 123456').should be_truthy
|
173
|
+
Phony.plausible?('+359 993 123456').should be_truthy
|
174
|
+
Phony.plausible?('+359 994 123456').should be_truthy
|
175
|
+
Phony.plausible?('+359 995 123456').should be_truthy
|
176
|
+
Phony.plausible?('+359 996 123456').should be_truthy
|
177
|
+
Phony.plausible?('+359 997 123456').should be_truthy
|
178
|
+
Phony.plausible?('+359 998 123456').should be_truthy
|
179
|
+
Phony.plausible?('+359 999 123456').should be_truthy
|
180
|
+
end
|
53
181
|
it_is_correct_for 'Congo', :samples => '+242 1234 56789'
|
54
182
|
it_is_correct_for 'Cook Islands', :samples => '+682 71928'
|
55
183
|
it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
|
@@ -430,6 +558,10 @@ describe 'plausibility' do
|
|
430
558
|
Phony.plausible?('+359 30 123 123').should be_truthy # Landline
|
431
559
|
Phony.plausible?('+359 89 123 1234').should be_truthy # Mobile
|
432
560
|
end
|
561
|
+
|
562
|
+
it 'is correct for Malaysia' do
|
563
|
+
Phony.plausible?('+60 5 123 1234').should be_truthy # Non Selangor Landline
|
564
|
+
end
|
433
565
|
end
|
434
566
|
end
|
435
567
|
end
|
@@ -179,6 +179,26 @@ describe 'country descriptions' do
|
|
179
179
|
it_splits '55199', ['55', '199', ""]
|
180
180
|
end
|
181
181
|
end
|
182
|
+
describe "Bulgaria" do
|
183
|
+
it_splits '35929284000', ['359', '2', '928', '4000'] # Sofia
|
184
|
+
it_splits '359878357523', ['359', '87', '8357', '523']
|
185
|
+
it_splits '3593012345', ['359', '30', '12345']
|
186
|
+
it_splits '35930123456', ['359', '30', '12', '3456']
|
187
|
+
it_splits '35943312345', ['359', '433', '12345']
|
188
|
+
it_splits '3596012345', ['359', '60', '12345']
|
189
|
+
it_splits '35969123456', ['359', '69', '123456']
|
190
|
+
it_splits '35970512345', ['359', '705', '12345']
|
191
|
+
it_splits '3597051234', ['359', '705', '1234']
|
192
|
+
it_splits '3597112345', ['359', '71', '12345']
|
193
|
+
it_splits '35979123456', ['359', '79', '123456']
|
194
|
+
it_splits '35980112345', ['359', '801', '12345']
|
195
|
+
it_splits '3598112345', ['359', '81', '12345']
|
196
|
+
it_splits '35986123456', ['359', '86', '123456']
|
197
|
+
it_splits '359881234567', ['359', '88', '1234', '567']
|
198
|
+
it_splits '35990123456', ['359', '90', '123456']
|
199
|
+
it_splits '359988123456', ['359', '988', '123456']
|
200
|
+
it_splits '359998123456', ['359', '998', '123456']
|
201
|
+
end
|
182
202
|
describe 'Cambodia' do
|
183
203
|
it_splits '85512236142', ["855", "12", "236", "142"] # mobile (Mobitel)
|
184
204
|
it_splits '855977100872', ["855", "97", "710", "0872"] # mobile (Metfone)
|
@@ -1308,6 +1328,8 @@ describe 'country descriptions' do
|
|
1308
1328
|
describe 'United Arab Emirates' do
|
1309
1329
|
it_splits '97180012', %w(971 800 12)
|
1310
1330
|
it_splits '971800123456789', %w(971 800 12 345 6789)
|
1331
|
+
it_splits '97180012345678', %w(971 800 12 345 678)
|
1332
|
+
it_splits '9718001234567', %w(971 800 12 345 67)
|
1311
1333
|
it_splits '97121234567', %w(971 2 123 4567)
|
1312
1334
|
it_splits '971506412345', %w(971 50 641 2345)
|
1313
1335
|
it_splits '971600641234', %w(971 600 641 234)
|
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.16.
|
4
|
+
version: 2.16.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-13 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
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.6
|
115
|
+
rubygems_version: 2.7.6
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Fast international phone number (E164 standard) normalizing, splitting and
|