phony 2.16.3 → 2.16.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phony.rb +1 -1
- data/lib/phony/countries.rb +6 -2
- data/lib/phony/countries/south_korea.rb +10 -8
- data/spec/functional/plausibility_spec.rb +12 -1
- data/spec/lib/phony/countries_spec.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d694ea5581b74590cc1986eca397aa059a4835e
|
4
|
+
data.tar.gz: 4cfc87a6bdceb938a024a285bf04a514162bc47d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340c1f1ff5187c9e722fa0c82d1caa01637ae92466e8d1dec8c302742074e8b0ff850a3bff9b16f9d0794819f50899c428054199998efd76acc1dd8bd7121d1d
|
7
|
+
data.tar.gz: c1d20505af244d4864512d0d03c2de405056da6d96fc92c7396f803d9a887b12e5750bf23829cd86b098521267036ef704051a06d1145f5e4b806c92f6b6ac9a
|
data/lib/phony.rb
CHANGED
@@ -89,7 +89,7 @@ module Phony
|
|
89
89
|
#
|
90
90
|
class SplittingError < ArgumentError
|
91
91
|
def initialize number
|
92
|
-
super %Q{Phony could not split the given number. Is #{number.
|
92
|
+
super %Q{Phony could not split the given number. Is #{(number.nil? || number == '') ? 'it' : number.inspect} a phone number?}
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
data/lib/phony/countries.rb
CHANGED
@@ -491,8 +491,9 @@ Phony.define do
|
|
491
491
|
/\A20\d+\z/ => [2,3,4], # Telecom Malagasy (Telma)
|
492
492
|
/\A23\d+\z/ => [2,3,4], # Digitel
|
493
493
|
/\A30\d+\z/ => [2,3,4], # mobile Madamobil (CDMA2000)
|
494
|
-
/\A31\d+\z/ => [2,3,4], # mobile
|
494
|
+
/\A31\d+\z/ => [2,3,4], # mobile Airtel Madagascar
|
495
495
|
/\A32\d+\z/ => [2,3,4], # mobile Orange Madagascar
|
496
|
+
/\A33\d+\z/ => [2,3,4], # mobile Airtel Madagascar
|
496
497
|
/\A34\d+\z/ => [2,3,4], # mobile Telecom Malagasy (Telma)
|
497
498
|
/\A5\d+\z/ => [3,3,3], # pager
|
498
499
|
/\A22\d+\z/ => [3,3,3], # satellite GULFSAT Téléphonie
|
@@ -1024,7 +1025,10 @@ Phony.define do
|
|
1024
1025
|
# Bangladesh (People's Republic of)
|
1025
1026
|
# country '880' # see special file
|
1026
1027
|
|
1027
|
-
|
1028
|
+
# Global Mobile Satellite System (i.e. Iridium, Globalstar, etc)
|
1029
|
+
# https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=QM
|
1030
|
+
country '881', fixed(1) >> split(3,5)
|
1031
|
+
|
1028
1032
|
country '882', todo # International Networks, shared code
|
1029
1033
|
country '883', todo # -
|
1030
1034
|
country '884', todo # -
|
@@ -1,22 +1,24 @@
|
|
1
1
|
# South Korean (Republic of Korea) phone numbers.
|
2
2
|
#
|
3
3
|
# http://en.wikipedia.org/wiki/Telephone_numbers_in_South_Korea
|
4
|
+
# https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=KR
|
4
5
|
#
|
5
6
|
|
6
7
|
# TODO 4-digit services, like "unreasonable infringement of livelihood report" number :)
|
7
8
|
#
|
8
9
|
|
9
10
|
special = %w{ 100 101 105 106 107 108 109 111 112 113 114 115 116 117 118 119 120 121 122 123 125 127 128 129 131 132 134 141 182 188 }
|
10
|
-
|
11
|
+
mobile = ('10'..'19').to_a
|
11
12
|
|
12
13
|
Phony.define do
|
13
14
|
country '82',
|
14
15
|
trunk('0') |
|
15
16
|
match(/^(#{special.join("|")})$/) >> split(3,3) | # Special actually don't need to be split – but better err.
|
16
|
-
one_of(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
one_of(*mobile) >> split(4,4) |
|
18
|
+
one_of('2') >> matched_split(
|
19
|
+
/\A\d{7}\z/ => [3,4],
|
20
|
+
/\A\d{8}\z/ => [4,4]) | # Seoul, also includes "services".
|
21
|
+
fixed(2) >> matched_split(
|
22
|
+
/\A\d{7}\z/ => [3,4],
|
23
|
+
/\A\d{8}\z/ => [4,4]) # Rest of cities
|
24
|
+
end
|
@@ -189,7 +189,8 @@ describe 'plausibility' do
|
|
189
189
|
'+389 7 234 5678']
|
190
190
|
it_is_correct_for 'Madagascar', :samples => ['+261 20 012 345 678',
|
191
191
|
'+261 20 124 3456',
|
192
|
-
'+261 512 345 678'
|
192
|
+
'+261 512 345 678',
|
193
|
+
'+261 33 345 6789']
|
193
194
|
it_is_correct_for 'Malawi', :samples => ['+265 1725 123',
|
194
195
|
'+265 213 456 789',
|
195
196
|
'+265 9123 456',
|
@@ -280,6 +281,16 @@ describe 'plausibility' do
|
|
280
281
|
'+252 160 12 34',
|
281
282
|
'+252 500 123 45',
|
282
283
|
'+252 67 1234 567']
|
284
|
+
|
285
|
+
it 'is correct for South Korea' do
|
286
|
+
Phony.plausible?('+82 2 1234 5678').should be_truthy
|
287
|
+
Phony.plausible?('+82 2 711 2222').should be_truthy
|
288
|
+
Phony.plausible?('+82 51 1234 5678').should be_truthy
|
289
|
+
Phony.plausible?('+82 51 123 5678').should be_truthy
|
290
|
+
Phony.plausible?('+82 10 2797 5588').should be_truthy
|
291
|
+
Phony.plausible?('+82 10 8797 1234').should be_truthy
|
292
|
+
end
|
293
|
+
|
283
294
|
it_is_correct_for 'South Sudan', :samples => ['+211 123 212 345',
|
284
295
|
'+211 973 212 345']
|
285
296
|
it_is_correct_for 'Suriname (Republic of)', :samples => ['+597 212 345', '+597 612 3456']
|
@@ -632,8 +632,10 @@ describe 'country descriptions' do
|
|
632
632
|
it_splits '2399920012', %w(239 9 920 012)
|
633
633
|
end
|
634
634
|
describe 'South Korea' do
|
635
|
-
it_splits '82212345678', ['82', '2', '1234', '5678'] # Seoul
|
636
|
-
it_splits '
|
635
|
+
it_splits '82212345678', ['82', '2', '1234', '5678'] # Seoul (8 digits)
|
636
|
+
it_splits '8227111222', ['82', '2', '711', '1222'] # Seoul (7 digits)
|
637
|
+
it_splits '825112345678', ['82', '51', '1234', '5678'] # Busan (8 digits)
|
638
|
+
it_splits '82511234567', ['82', '51', '123', '4567'] # Busan (7 digits)
|
637
639
|
it_splits '821027975588', ['82', '10', '2797', '5588'] # mobile
|
638
640
|
it_splits '821087971234', ['82', '10', '8797', '1234'] # mobile
|
639
641
|
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.16.
|
4
|
+
version: 2.16.4
|
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-05-31 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
|