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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7c21a8c6e8081e6ef55bb582caa1b4c395bc134
4
- data.tar.gz: 2d15cf9be4f0912ac1e03b81cd12750aabdf5cc2
3
+ metadata.gz: 5d694ea5581b74590cc1986eca397aa059a4835e
4
+ data.tar.gz: 4cfc87a6bdceb938a024a285bf04a514162bc47d
5
5
  SHA512:
6
- metadata.gz: 8d4384ce970c0650b68b6c8afb8b936784ac52c0fd862462c690bc22487e633c2ac8033288cb27a1521e1272e5a456d3e32130f0fb1f5160404806874f059888
7
- data.tar.gz: 7f634655df245f4c5de104a80a4f32aeec95338cb4129aadf0297193fc8576923798ac4acdf8fcd01992e59598525d9cd366c55611151345fb8bda1308033b7e
6
+ metadata.gz: 340c1f1ff5187c9e722fa0c82d1caa01637ae92466e8d1dec8c302742074e8b0ff850a3bff9b16f9d0794819f50899c428054199998efd76acc1dd8bd7121d1d
7
+ data.tar.gz: c1d20505af244d4864512d0d03c2de405056da6d96fc92c7396f803d9a887b12e5750bf23829cd86b098521267036ef704051a06d1145f5e4b806c92f6b6ac9a
@@ -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.blank? ? 'it' : number.inspect} a phone 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
 
@@ -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 Sacel
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
- country '881', todo # International Mobile, shared code
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
- # mobile = ('10'..'19').to_a # Note: Mobile not used as it is (for now) handled by the fixed catchall.
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('2') >> split(4,4) | # Seoul, also includes "services".
17
- fixed(2) >> split(4,4) # Catchall.
18
-
19
- # See above.
20
- #
21
- # one_of(*mobile) >> split(4,4) |
22
- end
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 '825112345678', ['82', '51', '1234', '5678'] # Busan
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.3
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-01-08 00:00:00.000000000 Z
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