phonelib 0.6.32 → 0.6.33

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: b11cbc72e5e26801a5d20ca72809f466560fe557
4
- data.tar.gz: 99888d8b8767f57c7ccc2034a714e2e6a0500633
3
+ metadata.gz: 8f45b39c150aa147321af5827f2668ad29016c02
4
+ data.tar.gz: a6aa4a45b4932415dfa79fd4d23cc5eff5c321b6
5
5
  SHA512:
6
- metadata.gz: 170c12fc42e597aa724905503a5cbb4bf3692dd78d6c367f05e7edc2c8b2b80439b46f2ef7e10751d1c2ec3dc37b0c57c905f584dfa423af66e2bd17d265c1b5
7
- data.tar.gz: a0ff6272b78ddc16c36118d6e11d55dbd8fdb87555b27855460914e61315d938edf012e78aeceec62aee8bc9350e406e0c5948aa3ddfbcf34b8f94a485e60d50
6
+ metadata.gz: 7f76bee8d45d7182ecba2d14e340233e497e6e79dfe89088e6a1c0800f4bea906198ea5026c1e24624c7d6c19b0680ae6d571134b027225a654ca87e28e5b4e8
7
+ data.tar.gz: fe977152591ec066f921f25f2b34f6d6e2c848a20e03fdfbb094a413428a1b6e58257b0bcc250f55a57cdb10feb3e1c41cba06f88b11323f4b09042dd874370d
data/README.md CHANGED
@@ -61,6 +61,12 @@ To disable sanitizing of passed phone number (keeping digits only)
61
61
  Phonelib.strict_check = true
62
62
  ```
63
63
 
64
+ To disable sanitizing of double prefix on passed phone number
65
+
66
+ ```ruby
67
+ Phonelib.strict_double_prefix_check = true
68
+ ```
69
+
64
70
  To set different extension separator on formatting, this setting doesn't affect parsing. Default setting is ';'
65
71
 
66
72
  ``` ruby
data/lib/phonelib/core.rb CHANGED
@@ -107,6 +107,22 @@ module Phonelib
107
107
  @@strict_check = strict
108
108
  end
109
109
 
110
+ # @private strict double prefix check for validator, doesn't sanitize number
111
+ @@strict_double_prefix_check = false
112
+
113
+ # getter for strict double prefix check flag
114
+ # @return [Boolean] Flag defines whether to do strict double prefix parsing check
115
+ def strict_double_prefix_check
116
+ @@strict_double_prefix_check
117
+ end
118
+
119
+ # setter for strict double prefix check flag
120
+ # @param strict [Boolean] make a strict double prefix parsing or not
121
+ # @return [Boolean] Flag defines whether to do strict double prefix parsing check
122
+ def strict_double_prefix_check=(strict)
123
+ @@strict_double_prefix_check = strict
124
+ end
125
+
110
126
  @@override_phone_data = nil
111
127
  # setter for data file to use
112
128
  def override_phone_data=(file_path)
@@ -24,7 +24,7 @@ module Phonelib
24
24
  # all is good, return result
25
25
  when passed_country.nil?
26
26
  # trying for all countries if no country was passed
27
- detect_and_parse phone
27
+ detect_and_parse(phone, country)
28
28
  when country_can_dp?(country)
29
29
  # if country allows double prefix trying modified phone
30
30
  parse_country(changed_dp_phone(country, phone), country)
@@ -102,11 +102,11 @@ module Phonelib
102
102
  # ==== Attributes
103
103
  #
104
104
  # * +phone+ - phone number for parsing
105
- def detect_and_parse(phone)
105
+ def detect_and_parse(phone, country)
106
106
  result = {}
107
107
  Phonelib.phone_data.each do |key, data|
108
108
  parsed = parse_single_country(phone, data)
109
- if double_prefix_allowed?(data, phone, parsed && parsed[key])
109
+ if (!Phonelib.strict_double_prefix_check || key == country) && double_prefix_allowed?(data, phone, parsed && parsed[key])
110
110
  parsed = parse_single_country(changed_dp_phone(key, phone), data)
111
111
  end
112
112
  result.merge!(parsed) unless parsed.nil?
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # @private
3
- VERSION = '0.6.32'
3
+ VERSION = '0.6.33'
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.6.32
4
+ version: 0.6.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Senderovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-14 00:00:00.000000000 Z
11
+ date: 2019-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake