phonie 3.2.2 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +15 -0
- data/Readme.rdoc +9 -0
- data/lib/phonie/data/phone_countries.yml +39 -0
- data/lib/phonie/formatter.rb +2 -1
- data/lib/phonie/phone.rb +7 -0
- data/lib/phonie/version.rb +1 -1
- data/test/countries/gp_test.rb +13 -0
- data/test/countries/jm_test.rb +12 -0
- data/test/countries/jo_test.rb +13 -0
- data/test/countries/ml_test.rb +13 -0
- data/test/countries/pa_test.rb +12 -0
- data/test/countries/sc_test.rb +13 -0
- data/test/countries/tz_test.rb +13 -0
- data/test/countries/ve_test.rb +13 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed1a7332cfe5e4371c273e9872030726f30f6484
|
4
|
+
data.tar.gz: ca1d252e1648897e9fb27224e58b59612b451343
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0c296ec4b38c9e28d92e876ab90073854290668eb4f1fa39b4e5d1c080a69f855e4c660c48102a6f37a8846d30d8199027e12055fbd53113d5256bfd9bda3bf
|
7
|
+
data.tar.gz: d5c5697192bdddf7c4e188c2f830ed641710b7040c17562553688f480fbddc40159229fe86dcf5e47e4b9fd58e8684eada2044a0bf978271a486fe3bf73333e9
|
data/Changelog.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
3.3.1
|
2
|
+
=====
|
3
|
+
|
4
|
+
* Adds support for multiple countries (Thanks @dramalho):
|
5
|
+
* Jordan
|
6
|
+
* Seychelles
|
7
|
+
* Panama
|
8
|
+
* Venezuela
|
9
|
+
* Guadeloupe
|
10
|
+
* Mali
|
11
|
+
* Tanzania
|
12
|
+
* Jamaica
|
13
|
+
|
14
|
+
* Adds new formatter option for extensions with prefix: %X (Thanks @feldpost)
|
15
|
+
|
1
16
|
3.2.2
|
2
17
|
=====
|
3
18
|
|
data/Readme.rdoc
CHANGED
@@ -59,6 +59,7 @@ When given a string, it interpolates the string with the following fields:
|
|
59
59
|
* %f - first @@n1_length characters of number (configured through Phonie.n1_length), default is 3 (512)
|
60
60
|
* %l - last characters of number (5486)
|
61
61
|
* %x - the extension number
|
62
|
+
* %X - the extension number with prefix
|
62
63
|
|
63
64
|
pn = Phonie::Phone.parse('+385915125486')
|
64
65
|
pn.to_s # => "+385915125486"
|
@@ -140,6 +141,7 @@ Currently tested on:
|
|
140
141
|
[GE] Georgia
|
141
142
|
[GF] French Guiana
|
142
143
|
[GH] Ghana
|
144
|
+
[GP] Guadeloupe
|
143
145
|
[GR] Greece
|
144
146
|
[GT] Guatemala
|
145
147
|
[GU] Guam
|
@@ -154,6 +156,8 @@ Currently tested on:
|
|
154
156
|
[IQ] Iraq
|
155
157
|
[IR] Iran
|
156
158
|
[IT] Italy
|
159
|
+
[JM] Jamaica
|
160
|
+
[JO] Jordan
|
157
161
|
[JP] Japan
|
158
162
|
[KE] Kenya
|
159
163
|
[KR] South Korea
|
@@ -164,6 +168,7 @@ Currently tested on:
|
|
164
168
|
[LV] Latvia
|
165
169
|
[MA] Morocco
|
166
170
|
[ME] Montenegro
|
171
|
+
[ML] Mali
|
167
172
|
[MT] Malta
|
168
173
|
[MX] Mexico
|
169
174
|
[MY] Malaysia
|
@@ -173,6 +178,7 @@ Currently tested on:
|
|
173
178
|
[NO] Norway
|
174
179
|
[NP] Nepal
|
175
180
|
[NZ] New Zealand
|
181
|
+
[PA] Panama
|
176
182
|
[PH] Philippines
|
177
183
|
[PK] Pakistan
|
178
184
|
[PT] Portugal
|
@@ -180,6 +186,7 @@ Currently tested on:
|
|
180
186
|
[RS] Serbia
|
181
187
|
[RU] Russian Federation
|
182
188
|
[SA] Saudi Arabia
|
189
|
+
[SC] Seychelles
|
183
190
|
[SE] Sweden
|
184
191
|
[SG] Singapore
|
185
192
|
[SI] Slovenia
|
@@ -189,10 +196,12 @@ Currently tested on:
|
|
189
196
|
[TO] Tonga
|
190
197
|
[TT] Trinidad and Tobago
|
191
198
|
[TW] Taiwan
|
199
|
+
[TZ] Tanzania
|
192
200
|
[UA] Ukraine
|
193
201
|
[UG] Uganda
|
194
202
|
[US] United States
|
195
203
|
[UY] Uruguay
|
204
|
+
[VE] Venezuela
|
196
205
|
[VN] Vietnam
|
197
206
|
[ZA] South Africa
|
198
207
|
[ZW] Zimbabwe
|
@@ -48,8 +48,23 @@
|
|
48
48
|
:national_dialing_prefix: None
|
49
49
|
:char_2_code: None
|
50
50
|
:iso_3166_code: GP
|
51
|
+
:area_code: '590|690'
|
52
|
+
:mobile_format: '690\d{6}'
|
53
|
+
:number_format: '\d{9}'
|
54
|
+
:local_number_format: '\d{6}'
|
51
55
|
:name: Guadeloupe
|
52
56
|
:international_dialing_prefix: '00'
|
57
|
+
-
|
58
|
+
:country_code: '1'
|
59
|
+
:national_dialing_prefix: '0'
|
60
|
+
:char_2_code: '0'
|
61
|
+
:iso_3166_code: JM
|
62
|
+
:name: Jamaica
|
63
|
+
:area_code: '876'
|
64
|
+
:mobile_format: '876(2|3|4|77|781|782|783|784|787|788|789|790|791|792|793|796|797|798|799|8|909|919|990|995|997|999)\d{4,6}'
|
65
|
+
:number_format: '\d{7,10}'
|
66
|
+
:local_number_format: '\d{4,7}'
|
67
|
+
:international_dialing_prefix: '011'
|
53
68
|
-
|
54
69
|
:country_code: '81'
|
55
70
|
:national_dialing_prefix: '0'
|
@@ -77,6 +92,10 @@
|
|
77
92
|
:national_dialing_prefix: '0'
|
78
93
|
:char_2_code: '0'
|
79
94
|
:iso_3166_code: ML
|
95
|
+
:area_code: '2\d{3}|442\d{1}|6\d{2}|7\d{2}'
|
96
|
+
:mobile_format: '(6|7)\d{7}'
|
97
|
+
:number_format: '\d{8}'
|
98
|
+
:local_number_format: '\d{4,5}'
|
80
99
|
:name: Mali
|
81
100
|
:international_dialing_prefix: '00'
|
82
101
|
-
|
@@ -121,6 +140,10 @@
|
|
121
140
|
:char_2_code: None
|
122
141
|
:iso_3166_code: PA
|
123
142
|
:name: Panama
|
143
|
+
:area_code: '2|4|6|7|9'
|
144
|
+
:mobile_format: '6\d{7}'
|
145
|
+
:number_format: '\d{7,8}'
|
146
|
+
:local_number_format: '\d{6,7}'
|
124
147
|
:international_dialing_prefix: '00'
|
125
148
|
-
|
126
149
|
:country_code: '591'
|
@@ -290,6 +313,10 @@
|
|
290
313
|
:national_dialing_prefix: '0'
|
291
314
|
:char_2_code: '0'
|
292
315
|
:iso_3166_code: TZ
|
316
|
+
:area_code: '2\d{1}|41|6\d{1}|7\d{1}'
|
317
|
+
:mobile_format: '(6|7)\d{8}'
|
318
|
+
:number_format: '\d{9}'
|
319
|
+
:local_number_format: '\d{7}'
|
293
320
|
:name: Tanzania, United Republic of
|
294
321
|
:international_dialing_prefix: '00'
|
295
322
|
-
|
@@ -344,6 +371,10 @@
|
|
344
371
|
:national_dialing_prefix: '0'
|
345
372
|
:char_2_code: '0'
|
346
373
|
:iso_3166_code: VE
|
374
|
+
:area_code: '(2|4)\d{2}'
|
375
|
+
:mobile_format: '4\d{9}'
|
376
|
+
:number_format: '\d{10}'
|
377
|
+
:local_number_format: '\d{7}'
|
347
378
|
:name: Venezuela, Bolivarian Republic of
|
348
379
|
:international_dialing_prefix: '00'
|
349
380
|
-
|
@@ -404,6 +435,10 @@
|
|
404
435
|
:national_dialing_prefix: '0'
|
405
436
|
:char_2_code: '0'
|
406
437
|
:iso_3166_code: JO
|
438
|
+
:area_code: '2|3|5|6|7\d{2}|8|9'
|
439
|
+
:mobile_format: '7\d{8}'
|
440
|
+
:number_format: '\d{8,9}'
|
441
|
+
:local_number_format: '\d{6,8}'
|
407
442
|
:name: Jordan
|
408
443
|
:international_dialing_prefix: '00'
|
409
444
|
-
|
@@ -1715,6 +1750,10 @@
|
|
1715
1750
|
:char_2_code: None
|
1716
1751
|
:iso_3166_code: SC
|
1717
1752
|
:name: Seychelles
|
1753
|
+
:area_code: '2|3|4|5|6|7'
|
1754
|
+
:mobile_format: '2\d{6,8}'
|
1755
|
+
:number_format: '\d{7,8}'
|
1756
|
+
:local_number_format: '\d{5,7}'
|
1718
1757
|
:international_dialing_prefix: '00'
|
1719
1758
|
-
|
1720
1759
|
:country_code: '20'
|
data/lib/phonie/formatter.rb
CHANGED
data/lib/phonie/phone.rb
CHANGED
@@ -38,6 +38,8 @@ module Phonie
|
|
38
38
|
def self.parse(string, options = {})
|
39
39
|
return if string.nil?
|
40
40
|
|
41
|
+
string = string.to_s
|
42
|
+
|
41
43
|
options[:country_code] ||= Phonie.configuration.default_country_code
|
42
44
|
options[:area_code] ||= Phonie.configuration.default_area_code
|
43
45
|
|
@@ -84,6 +86,11 @@ module Phonie
|
|
84
86
|
number[-n2_length, n2_length]
|
85
87
|
end
|
86
88
|
|
89
|
+
def extension_with_prefix
|
90
|
+
return unless extension
|
91
|
+
[' x', extension ].join
|
92
|
+
end
|
93
|
+
|
87
94
|
def format(fmt)
|
88
95
|
Formatter.new(format: fmt, phone_number: self).to_s
|
89
96
|
end
|
data/lib/phonie/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Guadeloupe
|
4
|
+
class GPTest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+590590878888', '590', '590', '878888', 'Guadeloupe', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+590690638764', '590', '690', '638764', 'Guadeloupe', true)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Norway
|
4
|
+
class JMTest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+18769696268', '1', '876', '9696268', 'Jamaica', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+18764884110', '1', '876', '4884110', 'Jamaica', true)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Jordan
|
4
|
+
class JOTest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+96265522796', '962', '6', '5522796', 'Jordan', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+962796899550', '962', '796', '899550', 'Jordan', true)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Mali
|
4
|
+
class MLTest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+22320203134', '223', '2020', '3134', 'Mali', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+22366089000', '223', '660', '89000', 'Mali', true)
|
11
|
+
parse_test('+22378458504', '223', '784', '58504', 'Mali', true)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Panama
|
4
|
+
class PATest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+50741869702', '507', '4', '1869702', 'Panama', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+50767677540', '507', '6', '7677540', 'Panama', true)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Seychelles
|
4
|
+
class SCTest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+2487985442', '248', '7', '985442', 'Seychelles', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+24825255813', '248', '2', '5255813', 'Seychelles', true)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Mali
|
4
|
+
class TZTest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+255262390044', '255', '26', '2390044', 'Tanzania, United Republic of', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+255673596267', '255', '67', '3596267', 'Tanzania, United Republic of', true)
|
11
|
+
parse_test('+255777375744', '255', '77', '7375744', 'Tanzania, United Republic of', true)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
## Venezuela
|
4
|
+
class VETest < Phonie::TestCase
|
5
|
+
def test_local
|
6
|
+
parse_test('+582742662406', '58', '274', '2662406', 'Venezuela, Bolivarian Republic of', false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mobile
|
10
|
+
parse_test('+584141809033', '58', '414', '1809033', 'Venezuela, Bolivarian Republic of', true)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phonie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomislav Car
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-
|
15
|
+
date: 2016-05-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activemodel
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- test/countries/ge_test.rb
|
147
147
|
- test/countries/gf_test.rb
|
148
148
|
- test/countries/gh_test.rb
|
149
|
+
- test/countries/gp_test.rb
|
149
150
|
- test/countries/gr_test.rb
|
150
151
|
- test/countries/gt_test.rb
|
151
152
|
- test/countries/gu_test.rb
|
@@ -162,6 +163,8 @@ files:
|
|
162
163
|
- test/countries/ir_test.rb
|
163
164
|
- test/countries/is_test.rb
|
164
165
|
- test/countries/it_test.rb
|
166
|
+
- test/countries/jm_test.rb
|
167
|
+
- test/countries/jo_test.rb
|
165
168
|
- test/countries/jp_test.rb
|
166
169
|
- test/countries/ke_test.rb
|
167
170
|
- test/countries/kh_text.rb
|
@@ -174,6 +177,7 @@ files:
|
|
174
177
|
- test/countries/lv_test.rb
|
175
178
|
- test/countries/ma_test.rb
|
176
179
|
- test/countries/me_test.rb
|
180
|
+
- test/countries/ml_test.rb
|
177
181
|
- test/countries/mt_test.rb
|
178
182
|
- test/countries/mu_test.rb
|
179
183
|
- test/countries/mx_test.rb
|
@@ -184,6 +188,7 @@ files:
|
|
184
188
|
- test/countries/no_test.rb
|
185
189
|
- test/countries/np_test.rb
|
186
190
|
- test/countries/nz_test.rb
|
191
|
+
- test/countries/pa_test.rb
|
187
192
|
- test/countries/ph_test.rb
|
188
193
|
- test/countries/pk_test.rb
|
189
194
|
- test/countries/pl_test.rb
|
@@ -194,6 +199,7 @@ files:
|
|
194
199
|
- test/countries/rs_test.rb
|
195
200
|
- test/countries/ru_test.rb
|
196
201
|
- test/countries/sa_test.rb
|
202
|
+
- test/countries/sc_test.rb
|
197
203
|
- test/countries/se_test.rb
|
198
204
|
- test/countries/sg_test.rb
|
199
205
|
- test/countries/si_test.rb
|
@@ -206,10 +212,12 @@ files:
|
|
206
212
|
- test/countries/tr_test.rb
|
207
213
|
- test/countries/tt_test.rb
|
208
214
|
- test/countries/tw_test.rb
|
215
|
+
- test/countries/tz_test.rb
|
209
216
|
- test/countries/ua_test.rb
|
210
217
|
- test/countries/ug_test.rb
|
211
218
|
- test/countries/us_test.rb
|
212
219
|
- test/countries/uy_test.rb
|
220
|
+
- test/countries/ve_test.rb
|
213
221
|
- test/countries/vn_test.rb
|
214
222
|
- test/countries/za_test.rb
|
215
223
|
- test/countries/zw_test.rb
|
@@ -288,6 +296,7 @@ test_files:
|
|
288
296
|
- test/countries/ge_test.rb
|
289
297
|
- test/countries/gf_test.rb
|
290
298
|
- test/countries/gh_test.rb
|
299
|
+
- test/countries/gp_test.rb
|
291
300
|
- test/countries/gr_test.rb
|
292
301
|
- test/countries/gt_test.rb
|
293
302
|
- test/countries/gu_test.rb
|
@@ -304,6 +313,8 @@ test_files:
|
|
304
313
|
- test/countries/ir_test.rb
|
305
314
|
- test/countries/is_test.rb
|
306
315
|
- test/countries/it_test.rb
|
316
|
+
- test/countries/jm_test.rb
|
317
|
+
- test/countries/jo_test.rb
|
307
318
|
- test/countries/jp_test.rb
|
308
319
|
- test/countries/ke_test.rb
|
309
320
|
- test/countries/kh_text.rb
|
@@ -316,6 +327,7 @@ test_files:
|
|
316
327
|
- test/countries/lv_test.rb
|
317
328
|
- test/countries/ma_test.rb
|
318
329
|
- test/countries/me_test.rb
|
330
|
+
- test/countries/ml_test.rb
|
319
331
|
- test/countries/mt_test.rb
|
320
332
|
- test/countries/mu_test.rb
|
321
333
|
- test/countries/mx_test.rb
|
@@ -326,6 +338,7 @@ test_files:
|
|
326
338
|
- test/countries/no_test.rb
|
327
339
|
- test/countries/np_test.rb
|
328
340
|
- test/countries/nz_test.rb
|
341
|
+
- test/countries/pa_test.rb
|
329
342
|
- test/countries/ph_test.rb
|
330
343
|
- test/countries/pk_test.rb
|
331
344
|
- test/countries/pl_test.rb
|
@@ -336,6 +349,7 @@ test_files:
|
|
336
349
|
- test/countries/rs_test.rb
|
337
350
|
- test/countries/ru_test.rb
|
338
351
|
- test/countries/sa_test.rb
|
352
|
+
- test/countries/sc_test.rb
|
339
353
|
- test/countries/se_test.rb
|
340
354
|
- test/countries/sg_test.rb
|
341
355
|
- test/countries/si_test.rb
|
@@ -348,10 +362,12 @@ test_files:
|
|
348
362
|
- test/countries/tr_test.rb
|
349
363
|
- test/countries/tt_test.rb
|
350
364
|
- test/countries/tw_test.rb
|
365
|
+
- test/countries/tz_test.rb
|
351
366
|
- test/countries/ua_test.rb
|
352
367
|
- test/countries/ug_test.rb
|
353
368
|
- test/countries/us_test.rb
|
354
369
|
- test/countries/uy_test.rb
|
370
|
+
- test/countries/ve_test.rb
|
355
371
|
- test/countries/vn_test.rb
|
356
372
|
- test/countries/za_test.rb
|
357
373
|
- test/countries/zw_test.rb
|