phony 2.21.0 → 2.21.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ff2cd9c33f893f770fd66ba1665ace7827d0d30bb21f1f0a46ace070f9e683b
4
- data.tar.gz: 34fed8e28246ab7db2b348e9bb6a46956e0eb366ef94bdfa9f0f3798b7c87cc5
3
+ metadata.gz: 7ed67d7f4f5596a67cb82fe62a78d312090e39fb325828049928642247d372c0
4
+ data.tar.gz: 1f4b6414d76ecf6d08f81033a1299f9f11d238e227c8f9549ed1ad07464c0683
5
5
  SHA512:
6
- metadata.gz: d0ce05e1ed6fac6fc0a23b57549b9ffd71bf45f2b258e606348e1f2572afdcaa00d6c2da5923a4568f3b02ad09b5390e23a571a0e8182df79927b4737245b081
7
- data.tar.gz: 2f0b899f0acba7142a4c68de1ddf00a66b2f8a7f2996bc22d981695dda9c0dcdb823c98c40d76e9cb0845f77657327b65a05aa7ee774cef1438f9d4ead6c500f
6
+ metadata.gz: db794a6b0c29320812ce0364be17d5072f97233f0c45cb0d627e3197102fcd4b5c0dfb3f1763774adc128d93b9d9137eff4d8ad85663f68b8e0ca2ceebe98622
7
+ data.tar.gz: 6915599eb1c93ed981ff37e5ea72e082efa8424316de1eabeb5e28562e6f092a1fc695f1fd9119abacc6941e0264cde5d2f55a24650f14afe47bff8e78df18f1
@@ -371,7 +371,16 @@ Phony.define do
371
371
 
372
372
  country '227', none >> split(4, 4) # Niger http://www.wtng.info/wtng-227-ne.html
373
373
  country '228', none >> split(4, 4) # Togolese Republic http://www.wtng.info/wtng-228-tg.html
374
- country '229', none >> split(4, 4) # Benin http://www.itu.int/oth/T0202000017/en
374
+
375
+ # Benin http://www.itu.int/oth/T0202000017/en
376
+ #
377
+ # There is no trunk code for this country and prefixes start with 0
378
+ country '229',
379
+ trunk('', normalize: false) |
380
+ none >> matched_split(
381
+ # Old empty and new 01 prefix.
382
+ /\A(01)?\d+\z/ => [2, 2, 2, 2, 2]
383
+ )
375
384
 
376
385
  # Mauritius
377
386
  # http://www.wtng.info/wtng-230-mu.html
@@ -1167,6 +1176,7 @@ Phony.define do
1167
1176
  /\A65816\d+\z/ => [4, 4, 4], # voicemail (mobile), Wataniya Telecom
1168
1177
  /\A1\d+\z/ => [3, 4], # geographic
1169
1178
  /\A2\d+\z/ => [4, 4], # geographic
1179
+ /\A41\d+\z/ => [4, 4], # mobile (Virgin Mobile)
1170
1180
  /\A[569]\d+\z/ => [4, 4], # mobile
1171
1181
  /\A8\d+\z/ => [3, 3] # geographic
1172
1182
  )
data/lib/phony/country.rb CHANGED
@@ -62,6 +62,7 @@ module Phony
62
62
  @codes.each do |national_splitter|
63
63
  new_trunk, ndc, *rest = national_splitter.split national_number
64
64
  trunk ||= new_trunk
65
+ national_number.replace(ndc) if new_trunk
65
66
  return [national_splitter.local_splitter, trunk, ndc, *rest] if rest && !rest.empty?
66
67
  end
67
68
 
@@ -29,8 +29,10 @@ module Phony
29
29
  # its parts.
30
30
  #
31
31
  def split(national_number)
32
- national_number.gsub! @trunk_code_replacement, EMPTY_STRING if @split
33
- [self, national_number]
32
+ return [self, national_number] unless @split
33
+
34
+ without_trunk = national_number.gsub @trunk_code_replacement, EMPTY_STRING
35
+ [self, without_trunk]
34
36
  end
35
37
 
36
38
  # Normalize normalizes the given national number.
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.21.0
4
+ version: 2.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-03 00:00:00.000000000 Z
11
+ date: 2025-02-01 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