phonelib 0.10.2 → 0.10.4

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: e14bd0d38f0006d075d1d7d57c3532826a6cd28797b6b646643cac493d8ec820
4
- data.tar.gz: 5d152596149d3c0a8953408917255fc91e1ae8f3ff44a6cf478544f5f75a6619
3
+ metadata.gz: fb1fdf7dccd5aea928ae10a90c388d762b030e8c4def7a65d877923eeb3a4ca8
4
+ data.tar.gz: b59f64fb4a31d30dd168673fd1b7449821e49fdb561f41aa81a2441b7cd56cc1
5
5
  SHA512:
6
- metadata.gz: 2893fd50a54de66f7be75ecd69eeae41899f25a59287bec615a8bd5f362822a014ff05ed79787f49961024758ee10fc9e7ea1d275e8df3a96ef68b12c33cad64
7
- data.tar.gz: 9a63ff6d268ef3f986586068ea89c4af549924873c7e230206f1e46a5f66780cb95b96b2627b22b0312580d2d2f52d4c03256d4d9422713f1b380258ac2f7dbb
6
+ metadata.gz: d66563c8732ed401d1eefc8e2a2bf4339b047e1e5c840f5811cf590901461c403172abbb2fbb820adfaf2fc12ace71f5579d6089f104f9c85b8bc420faf4f2a0
7
+ data.tar.gz: 0ed58b39980e34e6bf3696c0513f44c284576bafec199cd56baa242589e1b1adce29cadd3621061c33e9bfe1feec2851a839ec665a813d7010660bd5a51e733b
data/README.md CHANGED
@@ -13,7 +13,7 @@ But it still doesn't include all Google's library functionality.
13
13
 
14
14
  ## Incorrect parsing or validation
15
15
 
16
- In case your phone number is incorrectly parsed, you can check original libphonenumber for result [here](https://rawgit.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/demo-compiled.html) and in case of same parse result [open an issue for them](https://issuetracker.google.com/issues/new?component=192347&template=829703). This gem's data is based on it.
16
+ In case your phone number is incorrectly parsed, you can check original libphonenumber for result [here](https://htmlpreview.github.io/?https://github.com/google/libphonenumber/blob/master/javascript/i18n/phonenumbers/demo-compiled.html) and in case of same parse result [open an issue for them](http://issuetracker.google.com/issues/new?component=192347). This gem's data is based on it.
17
17
  If you can't wait for libphonenumber to resolve the issue, try to use ```Phonelib.add_additional_regex``` and ```Phonelib.additional_regexes``` methods.
18
18
 
19
19
  ## Information
Binary file
data/data/phone_data.dat CHANGED
Binary file
@@ -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 = {}
@@ -70,9 +69,15 @@ module Phonelib
70
69
  end
71
70
 
72
71
  # replacing national prefix to simplified format
73
- def with_replaced_national_prefix(phone, data)
74
- return phone unless data[Core::NATIONAL_PREFIX_TRANSFORM_RULE]
75
- phone = phone.gsub(/^#{data[Core::COUNTRY_CODE]}/, '') if phone.start_with?(data[Core::COUNTRY_CODE]) && !data[Core::DOUBLE_COUNTRY_PREFIX_FLAG]
72
+ def with_replaced_national_prefix(passed_phone, data)
73
+ return passed_phone unless data[Core::NATIONAL_PREFIX_TRANSFORM_RULE]
74
+ phone = if passed_phone.start_with?(data[Core::COUNTRY_CODE]) && !data[Core::DOUBLE_COUNTRY_PREFIX_FLAG]
75
+ passed_phone.gsub(/^#{data[Core::COUNTRY_CODE]}/, '')
76
+ else
77
+ passed_phone
78
+ end
79
+ return passed_phone unless phone.match? cr("^#{type_regex(data[Core::TYPES][Core::GENERAL], Core::POSSIBLE_PATTERN)}$")
80
+
76
81
  pattern = cr("^(?:#{data[Core::NATIONAL_PREFIX_FOR_PARSING]})")
77
82
  match = phone.match pattern
78
83
  if match && match.captures.compact.size > 0
@@ -133,8 +138,10 @@ module Phonelib
133
138
  countries_data.each_with_object({}) do |data, result|
134
139
  key = data[:id]
135
140
  parsed = parse_single_country(phone, data)
141
+ parsed = parse_single_country(with_replaced_national_prefix(phone, data), data) unless parsed && parsed[key] && parsed[key][:valid].size > 0
136
142
  if (!Phonelib.strict_double_prefix_check || key == country) && double_prefix_allowed?(data, phone, parsed && parsed[key])
137
- parsed = parse_single_country(changed_dp_phone(key, phone), data)
143
+ parsed2 = parse_single_country(changed_dp_phone(key, phone), data)
144
+ parsed = parsed2 if parsed2 && parsed2[key] && parsed2[key][:valid].size > 0
138
145
  end
139
146
  result.merge!(parsed) unless parsed.nil?
140
147
  end.compact
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Phonelib
4
4
  # @private
5
- VERSION = '0.10.2'
5
+ VERSION = '0.10.4'
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.2
4
+ version: 0.10.4
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-12-15 00:00:00.000000000 Z
11
+ date: 2025-02-10 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.2
43
+ changelog_uri: https://github.com/daddyz/phonelib/releases/tag/v0.10.4
44
44
  post_install_message:
45
45
  rdoc_options:
46
46
  - " --no-private - CHANGELOG.md --readme README.md"