phonelib 0.10.1 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/extended_data.dat +0 -0
- data/data/phone_data.dat +0 -0
- data/lib/phonelib/data_importer.rb +2 -2
- data/lib/phonelib/phone_analyzer.rb +8 -3
- 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: 9fe27c3c85d76103dc9fe5fe1a3877f31fd06cf6b3327b25d4f93aea3238ca63
|
4
|
+
data.tar.gz: 15b2fb31d0e9997d0ef6fef3502a15499d8bd151a05f8ffd6ef08c23729db121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 585a0298a4ec578788d3ee34d4c8c567290b9734f051a7bb73e85515b33b54c37792757d91a1c07fead6c9473bc6c5b9913c3313dc45fee03ea5e27e8152adda
|
7
|
+
data.tar.gz: 715cf0441e86fa0d3f8522023ace36fb3fe367e1c84c373d88130d87a8e51d8c8ed40bc17830d875d9c0f3b79d42ca81f3032106dce3964fc88ac3397c369d97
|
data/data/extended_data.dat
CHANGED
Binary file
|
data/data/phone_data.dat
CHANGED
Binary file
|
@@ -8,7 +8,7 @@ module Phonelib
|
|
8
8
|
require 'nokogiri'
|
9
9
|
|
10
10
|
# official libphonenumber repo for cloning
|
11
|
-
REPO = 'https://github.com/
|
11
|
+
REPO = 'https://github.com/google/libphonenumber.git'
|
12
12
|
|
13
13
|
# importing function
|
14
14
|
def self.import
|
@@ -203,7 +203,7 @@ module Phonelib
|
|
203
203
|
require 'open-uri'
|
204
204
|
require 'csv'
|
205
205
|
io = URI.open('http://download.geonames.org/export/dump/countryInfo.txt')
|
206
|
-
csv = CSV.new(io, {col_sep: "\t"})
|
206
|
+
csv = CSV.new(io, **{col_sep: "\t"})
|
207
207
|
csv.each do |row|
|
208
208
|
next if row[0].nil? || row[0].start_with?('#') || row[0].empty? || row[0].size != 2
|
209
209
|
|
@@ -19,7 +19,6 @@ module Phonelib
|
|
19
19
|
# country (2 letters) like 'US', 'us' or :us for United States
|
20
20
|
def analyze(phone, passed_country)
|
21
21
|
countries = country_or_default_country passed_country
|
22
|
-
|
23
22
|
return analyze_single_country(phone, countries.first, passed_country) if countries.size == 1
|
24
23
|
|
25
24
|
results = {}
|
@@ -133,8 +132,10 @@ module Phonelib
|
|
133
132
|
countries_data.each_with_object({}) do |data, result|
|
134
133
|
key = data[:id]
|
135
134
|
parsed = parse_single_country(phone, data)
|
135
|
+
parsed = parse_single_country(with_replaced_national_prefix(phone, data), data) unless parsed && parsed[key] && parsed[key][:valid].size > 0
|
136
136
|
if (!Phonelib.strict_double_prefix_check || key == country) && double_prefix_allowed?(data, phone, parsed && parsed[key])
|
137
|
-
|
137
|
+
parsed2 = parse_single_country(changed_dp_phone(key, phone), data)
|
138
|
+
parsed = parsed2 if parsed2 && parsed2[key] && parsed2[key][:valid].size > 0
|
138
139
|
end
|
139
140
|
result.merge!(parsed) unless parsed.nil?
|
140
141
|
end.compact
|
@@ -174,7 +175,11 @@ module Phonelib
|
|
174
175
|
# * +not_valid+ - specifies that number is not valid by general desc pattern
|
175
176
|
def national_and_data(data, country_match, not_valid = false)
|
176
177
|
result = data.select { |k, _v| k != :types && k != :formats }
|
177
|
-
|
178
|
+
index = 0
|
179
|
+
if Phonelib.additional_regexes.is_a?(Hash) && Phonelib.additional_regexes[data[:id]]
|
180
|
+
index = Phonelib.additional_regexes[data[:id]].values.flatten.join('|').scan(/\(/).size
|
181
|
+
end
|
182
|
+
phone = country_match.to_a[-1 - index]
|
178
183
|
result[:national] = phone
|
179
184
|
result[:format] = number_format(phone, data[Core::FORMATS])
|
180
185
|
result.merge! all_number_types(phone, data[Core::TYPES], not_valid)
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadim Senderovich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-16 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.3
|
44
44
|
post_install_message:
|
45
45
|
rdoc_options:
|
46
46
|
- " --no-private - CHANGELOG.md --readme README.md"
|