telephone_number 1.4.4 → 1.4.5

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
  SHA1:
3
- metadata.gz: a3308470b6943c2bea539b891ed52e915f35d6d6
4
- data.tar.gz: 0d82e611462d314ebdcbfe35e1731998136e13f7
3
+ metadata.gz: e1f48528c24b8209a7249897915221fe199dfb44
4
+ data.tar.gz: 14d0f77b933e58e22543faf85d1d9f45026e86af
5
5
  SHA512:
6
- metadata.gz: 5088aee089d456b4561a7361d37a49a47a5260dd5fe618c2f9dbb2b0d16581d63334b3bdfe7394a3a8885d7015867ad8f8da0521705f7af959d5c8bf9dd4a091
7
- data.tar.gz: 0cdf9725d4b4868e18d84ec40b168ab95cbf6d19164de2210ab952e65fd58069be5a4cfee428ee62a37011bb5e4ab4662e3140638101ce56e51a0e71a069010c
6
+ metadata.gz: '049b869cea68f8c7d1a81d15c7fa6598e8c8b0e423c5ee269e1a975e259489d09c87a9da63629f231f52fe2718b7cb111e551cda456c8fd60346b80337cdc3d8'
7
+ data.tar.gz: c034eba54a5a8596a725e8a38b41ff995ea15451a1c5df3fd44b1bceb68867fac20a11ab424983ab435289ddb93613f680813c669c97051a6480ed18b3650a06
@@ -11,7 +11,7 @@ module TelephoneNumber
11
11
  AU: %w(0467703037),
12
12
  BE: %w(32498485960 32477702206 32474095692),
13
13
  BO: %w(59178500348 59178006138 59178006139),
14
- BR: %w(011992339376 1123456789 11961234567),
14
+ BR: %w(011992339376 1123456789 11961234567 55991472683),
15
15
  BY: %w(80152450911 294911911 152450911),
16
16
  CA: %w(16135550119 16135550171 16135550112 16135550194
17
17
  16135550122 16135550131 15146708700 14169158200),
@@ -9,7 +9,7 @@ module TelephoneNumber
9
9
  end
10
10
 
11
11
  def valid_types
12
- @valid_types ||= validate
12
+ @valid_types ||= generate_valid_types(normalized_number)
13
13
  end
14
14
 
15
15
  def valid?(keys = [])
@@ -23,15 +23,20 @@ module TelephoneNumber
23
23
  # basically anything else that uses google data
24
24
  def build_normalized_number
25
25
  match_result = parse_prefix.match(country.full_general_pattern)
26
- match_result ? match_result[:national_num] : original_number
26
+
27
+ if match_result && generate_valid_types(match_result[:national_num]).any?
28
+ match_result[:national_num]
29
+ else
30
+ original_number
31
+ end
27
32
  end
28
33
 
29
- # returns an array of valid types for the normalized number
34
+ # returns an array of valid types for the given number
30
35
  # if array is empty, we can assume that the number is invalid
31
- def validate
36
+ def generate_valid_types(number)
32
37
  return [] unless country
33
38
  country.validations.select do |validation|
34
- normalized_number.match?(Regexp.new("^(#{validation.pattern})$"))
39
+ number.match?(Regexp.new("^(#{validation.pattern})$"))
35
40
  end.map(&:name)
36
41
  end
37
42
 
@@ -1,3 +1,3 @@
1
1
  module TelephoneNumber
2
- VERSION = "1.4.4"
2
+ VERSION = "1.4.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telephone_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - MOBI Wireless Management
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-09 00:00:00.000000000 Z
11
+ date: 2019-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler