phonelib 0.8.0 → 0.8.2

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
  SHA256:
3
- metadata.gz: bdcde83b646a76dd337ecbb6e7ca8976a23729936d34a0b2734ac6dc76d758e0
4
- data.tar.gz: 5f0ef67a10c99e563f52885860e41aefa08c67df4d3593fc9fe515c1479ebc6b
3
+ metadata.gz: ba0b6be5c2a7713ded6c8bbc68a5d12d022b75cbc495bbdcd13cace46ee8467a
4
+ data.tar.gz: 6ad47b7928886d2c3222e072a2b2e73566baffe8462fa6a8ee353b9ff7630bca
5
5
  SHA512:
6
- metadata.gz: f27ccd04e753eb2349af42ea19710fec3c4d97975e477a380651f51c6d2c47202b5e029f93807659df33aac6cf3817ffda7fc6eeeceb81e02132b6d1d6294f1f
7
- data.tar.gz: 3c2049c708d6e938cbbc3459a3bec1ad20a409b797cd4a399586705231e0321a897a9ebe19fd1cfd7e13be9cae22515b08390a323262cb0015a591186632e845
6
+ metadata.gz: 9a9dd8cc0c6b18a192575c169ff213e2bcf762d1a93f4ecc07aad89729a3173e03fe31e86e35ed4e583446410933367ef7ae9a6f365b47a55e75dd1c53b0b521
7
+ data.tar.gz: a468f6781963b983e54e367a0ddb99525ae2f5c1da8ca9b04829c248bf2ffe85705c9f96088eb09a39250cbb616d507288c84e54a27dee11cf42c4bd533dcb7f
Binary file
data/data/phone_data.dat CHANGED
Binary file
data/lib/phonelib/core.rb CHANGED
@@ -40,14 +40,14 @@ module Phonelib
40
40
  @@default_country = nil
41
41
 
42
42
  # getter method for default_country variable
43
- # @return [String|nil] Default country set for parsing or nil
43
+ # @return [String,Symbol,Array<String,Symbol>,nil] Default country ISO2 code or codes used for parsing
44
44
  def default_country
45
45
  @@default_country
46
46
  end
47
47
 
48
48
  # setter method for default_country variable
49
- # @param country [String|Symbol] default country ISO2 code used for parsing
50
- # @return [String|nil] Default country set for parsing or nil
49
+ # @param country [String,Symbol,Array<String,Symbol>] Default country ISO2 code or codes used for parsing
50
+ # @return [String,Symbol,Array<String,Symbol>] Default country ISO2 code or codes used for parsing
51
51
  def default_country=(country)
52
52
  @@default_country = country
53
53
  end
@@ -45,6 +45,7 @@ module Phonelib
45
45
  'TA' => 'SH',
46
46
  'TC' => 'US',
47
47
  'TT' => 'US',
48
+ 'UM' => 'US',
48
49
  'VA' => 'IT',
49
50
  'VC' => 'US',
50
51
  'VG' => 'US',
@@ -160,6 +161,7 @@ module Phonelib
160
161
  # some countries missing formats, and are linking them to another countries
161
162
  def process_format_links
162
163
  FORMAT_SHARING.each do |destination, source|
164
+ next unless @data[destination]
163
165
  @data[destination][:formats] ||= []
164
166
  @data[destination][:formats] = @data[destination][:formats] + @data[source][:formats]
165
167
  end
@@ -7,6 +7,8 @@ module Phonelib
7
7
  if result.size == 1
8
8
  result
9
9
  else
10
+ matched_countries = country_or_default_country(nil) & result.keys
11
+ result = result.keep_if {|k, _v| matched_countries.include?(k) } if matched_countries
10
12
  Hash[result.take(1)]
11
13
  end
12
14
  end
@@ -56,7 +58,7 @@ module Phonelib
56
58
  def country_can_dp?(country)
57
59
  Phonelib.phone_data[country] &&
58
60
  Phonelib.phone_data[country][Core::DOUBLE_COUNTRY_PREFIX_FLAG] &&
59
- !original_starts_with_plus?
61
+ !original_starts_with_plus? && original_s.start_with?(Phonelib.phone_data[country][Core::COUNTRY_CODE])
60
62
  end
61
63
 
62
64
  # changes phone to with/without double country prefix
@@ -66,6 +68,7 @@ module Phonelib
66
68
 
67
69
  country_code = Phonelib.phone_data[country][Core::COUNTRY_CODE]
68
70
  if phone.start_with? country_code * 2
71
+ # remove double prefix in case it is there
69
72
  phone.gsub(cr("^#{country_code}"), '')
70
73
  else
71
74
  "#{country_code}#{phone}"
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # @private
3
- VERSION = '0.8.0'
3
+ VERSION = '0.8.2'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonelib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Senderovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-04 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake