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 +4 -4
- data/README.md +6 -0
- data/lib/phonelib/core.rb +16 -0
- data/lib/phonelib/phone_analyzer.rb +3 -3
- data/lib/phonelib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f45b39c150aa147321af5827f2668ad29016c02
|
4
|
+
data.tar.gz: a6aa4a45b4932415dfa79fd4d23cc5eff5c321b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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?
|
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.6.
|
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-
|
11
|
+
date: 2019-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|