phonelib 0.10.24 → 0.10.25
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 +4 -4
- data/data/extended_data.dat +0 -0
- data/data/phone_data.dat +0 -0
- data/lib/phonelib/data_importer_helper.rb +9 -1
- data/lib/phonelib/phone_analyzer.rb +3 -1
- data/lib/phonelib/phone_analyzer_helper.rb +13 -4
- data/lib/phonelib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84e2a8f47cd1fb8108efa26ab0ba6120bd6e28a420794acf7ee099135618ab1e
|
|
4
|
+
data.tar.gz: a15e47d9b2a941639e4dc83226143c01b314506482d7fdee63ed95afa0ba78f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 81a599c8844452b9d0124a8b75315905f85e79a31eedc3e14af66a830885fa0ebbe27aa9ebd65da57c7e710744d9147a1bf6304699049e0cd6452a8d698083bd
|
|
7
|
+
data.tar.gz: baf0e046b6eea13ae466c97b6a065f2fe9bf6fc496992424ebe78fd51d177acf72cefe8b53bdcae07d0fc2b6a6e42323966558fe593a4f57f22780d7aecf3fd5
|
data/data/extended_data.dat
CHANGED
|
Binary file
|
data/data/phone_data.dat
CHANGED
|
Binary file
|
|
@@ -22,7 +22,7 @@ module Phonelib
|
|
|
22
22
|
# method saves extended data file
|
|
23
23
|
def save_extended_data_file
|
|
24
24
|
extended = {
|
|
25
|
-
Phonelib::Core::EXT_PREFIXES => @prefixes,
|
|
25
|
+
Phonelib::Core::EXT_PREFIXES => intern_hashes(@prefixes),
|
|
26
26
|
Phonelib::Core::EXT_GEO_NAMES => @geo_names,
|
|
27
27
|
Phonelib::Core::EXT_COUNTRY_NAMES => @countries,
|
|
28
28
|
Phonelib::Core::EXT_TIMEZONES => @timezones,
|
|
@@ -34,6 +34,14 @@ module Phonelib
|
|
|
34
34
|
puts 'DATA SAVED'
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def intern_hashes(hash, table = {})
|
|
38
|
+
canonical = {}
|
|
39
|
+
hash.each do |k, v|
|
|
40
|
+
canonical[k] = v.is_a?(Hash) ? intern_hashes(v, table) : v
|
|
41
|
+
end
|
|
42
|
+
table[canonical] ||= canonical
|
|
43
|
+
end
|
|
44
|
+
|
|
37
45
|
# method updates prefixes hash recursively
|
|
38
46
|
def fill_prefixes(key, value, prefix, prefixes)
|
|
39
47
|
prefixes = {} if prefixes.nil?
|
|
@@ -139,7 +139,9 @@ module Phonelib
|
|
|
139
139
|
key = data[:id]
|
|
140
140
|
parsed = parse_single_country(phone, data)
|
|
141
141
|
unless parsed && parsed[key] && parsed[key][:valid].size > 0
|
|
142
|
-
|
|
142
|
+
replaced = with_replaced_national_prefix(phone, data)
|
|
143
|
+
# re-parsing an unchanged phone cannot change the result
|
|
144
|
+
replaced_parsed = parse_single_country(replaced, data) unless replaced == phone
|
|
143
145
|
parsed = replaced_parsed unless replaced_parsed.nil?
|
|
144
146
|
end
|
|
145
147
|
if (!Phonelib.strict_double_prefix_check || key == country) && double_prefix_allowed?(data, phone, parsed && parsed[key])
|
|
@@ -17,7 +17,7 @@ module Phonelib
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def original_starts_with_plus_or_double_zero?
|
|
20
|
-
significant_original_s[0] == Core::PLUS_SIGN || significant_original_s[0..1] == '00'
|
|
20
|
+
significant_original_s[0] == Core::PLUS_SIGN || significant_original_s[0..1] == '00' && significant_original_s[2..-1] =~ cr('[1-9]+')
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
# converts symbols in phone to numbers
|
|
@@ -48,7 +48,7 @@ module Phonelib
|
|
|
48
48
|
|
|
49
49
|
# returns country prefix for provided country or nil
|
|
50
50
|
def country_prefix(country)
|
|
51
|
-
country = country
|
|
51
|
+
country = normalize_passed_country(country)
|
|
52
52
|
Phonelib.phone_data[country] && \
|
|
53
53
|
Phonelib.phone_data[country][Core::COUNTRY_CODE]
|
|
54
54
|
end
|
|
@@ -117,9 +117,9 @@ module Phonelib
|
|
|
117
117
|
country ||= (original_starts_with_plus_or_double_zero? ? nil : Phonelib.default_country)
|
|
118
118
|
|
|
119
119
|
if country.is_a?(Array)
|
|
120
|
-
country.compact.map { |e| e
|
|
120
|
+
country.compact.map { |e| normalize_passed_country(e) }
|
|
121
121
|
else
|
|
122
|
-
[country && country
|
|
122
|
+
[country && normalize_passed_country(country)]
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
@@ -232,5 +232,14 @@ module Phonelib
|
|
|
232
232
|
match = number.match(cr("^(?:#{regex})$"))
|
|
233
233
|
match && match.to_s.length == number.length
|
|
234
234
|
end
|
|
235
|
+
|
|
236
|
+
# normalization for passed country unless we are not talking about International XXX
|
|
237
|
+
def normalize_passed_country(country)
|
|
238
|
+
return country if country.nil?
|
|
239
|
+
country = country.to_s
|
|
240
|
+
return country if country.start_with?('International')
|
|
241
|
+
country.upcase
|
|
242
|
+
end
|
|
243
|
+
|
|
235
244
|
end
|
|
236
245
|
end
|
data/lib/phonelib/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.10.25
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vadim Senderovich
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-18 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.
|
|
43
|
+
changelog_uri: https://github.com/daddyz/phonelib/releases/tag/v0.10.25
|
|
44
44
|
post_install_message:
|
|
45
45
|
rdoc_options:
|
|
46
46
|
- " --no-private - CHANGELOG.md --readme README.md"
|