phonelib 0.10.6 → 0.10.7

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: 4ed5052f30c6009ab20dab0f859f202c9484817f7ec7229d7ea79b8f799f0e03
4
- data.tar.gz: 539365259ec72b497bb8c3eb2ada310c4c0e8aee7d505baed86d4e6dc8a300ee
3
+ metadata.gz: c3392c3861bbde37edc22277490262ba9575e3fece9af25cc905e7e9818c3dfe
4
+ data.tar.gz: 341900031e760af19a6ab4f0e00dc7fd1f5d9df54fd3e8489428cefd4f070f42
5
5
  SHA512:
6
- metadata.gz: c8c3eac344c989724c6c27d69a9bc550dd6d6afbed47309448dc2491b68bee2fd1630604f65a27d9a236d76b65271c810e91a5a9f392b99952a34fb2741f5013
7
- data.tar.gz: b578d6ebf03f933e7338db43fc1e3555494f1664c8b4ddf6f74751e659ce745d87e373310354511d9f41af0a9373432f6a9cfeb8bb69efb43b3c3f8fce1f11d9
6
+ metadata.gz: aca95b93fc79099532429253cc5a395e1570b9fa18cf59c52e1c531830cc0664b95c3ed9380d54fb831e517bd78bb4dfcb6a35a7d766a4fd2322d33c1641136d
7
+ data.tar.gz: 5e2f46e9ba85cdd56f66b48b9edd731229be5f676ba6087a531ec2cf14ed8b8cbc477c17a201b1bae42b4873751a4cd6335f2a118cbb881a3a2bf98095ee3bd0
Binary file
data/data/phone_data.dat CHANGED
Binary file
@@ -162,13 +162,13 @@ module Phonelib
162
162
  # * +phone+ - phone number for parsing
163
163
  # * +data+ - country data to be based on for creating e164 representation
164
164
  def convert_to_e164(phone, data)
165
- match = phone.match full_regex_for_data(data, Core::VALID_PATTERN, !original_starts_with_plus?)
165
+ match = phone.match full_regex_for_data(data, Core::VALID_PATTERN, !original_starts_with_plus_or_double_zero?)
166
166
  case
167
167
  when match
168
168
  "#{data[Core::COUNTRY_CODE]}#{match.to_a.last}"
169
169
  when phone.match(cr("^#{data[Core::INTERNATIONAL_PREFIX]}"))
170
170
  phone.sub(cr("^#{data[Core::INTERNATIONAL_PREFIX]}"), Core::PLUS_SIGN)
171
- when original_starts_with_plus? && phone.start_with?(data[Core::COUNTRY_CODE])
171
+ when original_starts_with_plus_or_double_zero? && phone.start_with?(data[Core::COUNTRY_CODE])
172
172
  phone
173
173
  else
174
174
  "#{data[Core::COUNTRY_CODE]}#{phone}"
@@ -16,8 +16,8 @@ module Phonelib
16
16
  end
17
17
  end
18
18
 
19
- def original_starts_with_plus?
20
- original_s[0] == Core::PLUS_SIGN
19
+ def original_starts_with_plus_or_double_zero?
20
+ original_s[0] == Core::PLUS_SIGN || original_s[0..1] == '00'
21
21
  end
22
22
 
23
23
  # converts symbols in phone to numbers
@@ -61,7 +61,8 @@ module Phonelib
61
61
  def country_can_dp?(country)
62
62
  Phonelib.phone_data[country] &&
63
63
  Phonelib.phone_data[country][Core::DOUBLE_COUNTRY_PREFIX_FLAG] &&
64
- !original_starts_with_plus? && original_s.start_with?(Phonelib.phone_data[country][Core::COUNTRY_CODE])
64
+ !original_starts_with_plus_or_double_zero? &&
65
+ original_s.start_with?(Phonelib.phone_data[country][Core::COUNTRY_CODE])
65
66
  end
66
67
 
67
68
  # changes phone to with/without double country prefix
@@ -89,7 +90,7 @@ module Phonelib
89
90
  data[Core::DOUBLE_COUNTRY_PREFIX_FLAG] &&
90
91
  phone =~ cr("^#{data[Core::COUNTRY_CODE]}") &&
91
92
  parsed && (parsed[:valid].nil? || parsed[:valid].empty?) &&
92
- !original_starts_with_plus?
93
+ !original_starts_with_plus_or_double_zero?
93
94
  end
94
95
 
95
96
  # Returns original number passed if it's a string or empty string otherwise
@@ -103,7 +104,8 @@ module Phonelib
103
104
  #
104
105
  # * +country+ - country passed for parsing
105
106
  def country_or_default_country(country)
106
- country ||= (original_starts_with_plus? ? nil : Phonelib.default_country)
107
+ country ||= (original_starts_with_plus_or_double_zero? ? nil : Phonelib.default_country)
108
+
107
109
  if country.is_a?(Array)
108
110
  country.compact.map { |e| e.to_s.upcase }
109
111
  else
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Phonelib
4
4
  # @private
5
- VERSION = '0.10.6'
5
+ VERSION = '0.10.7'
6
6
  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.10.6
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Senderovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-12 00:00:00.000000000 Z
11
+ date: 2025-04-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Google libphonenumber library was taken as a basis for
@@ -40,7 +40,7 @@ homepage: https://github.com/daddyz/phonelib
40
40
  licenses:
41
41
  - MIT
42
42
  metadata:
43
- changelog_uri: https://github.com/daddyz/phonelib/releases/tag/v0.10.6
43
+ changelog_uri: https://github.com/daddyz/phonelib/releases/tag/v0.10.7
44
44
  post_install_message:
45
45
  rdoc_options:
46
46
  - " --no-private - CHANGELOG.md --readme README.md"