phonelib 0.8.8 → 0.9.1

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: 2e41d410f5bb57cfd89b05cc5a13022de6a370ab82d43effd6f0f3147f07d3e9
4
- data.tar.gz: '06885db5a6b08483c3de1165e2e25284ebb98b7920a9f6b74794255410f179aa'
3
+ metadata.gz: 2cc35b2b49e08abb5a2da2075e9ff6a33398b9e07a97fdc1e377ccb273eb3114
4
+ data.tar.gz: fee9d2ac1700bbe33c056f0d658e8a260408acf320e76e62b4f993efe31fe940
5
5
  SHA512:
6
- metadata.gz: 1d9b39f64830551dac9dee66544b44fc2ffd07e6649033291d1f4adfee755366c68b0e7d54ad7c307716c7d0fb594997747b1b5a09df9b0dab44fa7f41b698f0
7
- data.tar.gz: bc8830dafb972e5b31ad0defbbc0db7a92400bb954d7ea7b311818e467c96a92117c0b59655b475e4dd7f9c82f481dbd659a081c617d79b00b611cf030d95445
6
+ metadata.gz: 0f24a98ff377ab4eda20f1c8c0a3c68a608b103ff90009933ef5094aa68bf019a4fb17b65ea734f17364682666802cddf06906f3850299538b908f9781696f01
7
+ data.tar.gz: 7e80f05ab5f94310250700eaea3f8bac83842dba84fca847cb7d6e93cf7da38eb27001af69550417d74f41dc888dbd4781fb5d73ae7ca8bb30912d411f21ee53
Binary file
data/data/phone_data.dat CHANGED
Binary file
@@ -70,10 +70,11 @@ module Phonelib
70
70
  # replacing national prefix to simplified format
71
71
  def with_replaced_national_prefix(phone, data)
72
72
  return phone unless data[Core::NATIONAL_PREFIX_TRANSFORM_RULE]
73
+ phone = phone.gsub(/^#{data[Core::COUNTRY_CODE]}/, '') if phone.start_with?(data[Core::COUNTRY_CODE])
73
74
  pattern = cr("^(?:#{data[Core::NATIONAL_PREFIX_FOR_PARSING]})")
74
75
  match = phone.match pattern
75
76
  if match && match.captures.compact.size > 0
76
- phone.gsub(pattern, data[Core::NATIONAL_PREFIX_TRANSFORM_RULE])
77
+ data[Core::COUNTRY_CODE] + phone.gsub(pattern, data[Core::NATIONAL_PREFIX_TRANSFORM_RULE])
77
78
  else
78
79
  phone
79
80
  end
@@ -8,6 +8,7 @@ module Phonelib
8
8
  result
9
9
  else
10
10
  matched_countries = country_or_default_country(nil) & result.keys
11
+ matched_countries = result.keys.take(1) if matched_countries.size == 0
11
12
  result = result.keep_if {|k, _v| matched_countries.include?(k) } if matched_countries
12
13
  Hash[result.take(1)]
13
14
  end
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # @private
3
- VERSION = '0.8.8'
3
+ VERSION = '0.9.1'
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.8
4
+ version: 0.9.1
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-03-16 00:00:00.000000000 Z
11
+ date: 2024-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  requirements: []
200
- rubygems_version: 3.1.4
200
+ rubygems_version: 3.1.6
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Gem validates phone numbers with Google libphonenumber database