phonelib 0.6.46 → 0.6.47

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: 1f5702cfd1fd7ef6eecf8c589701a8be3879ffc29147df0915f05c40199ee43d
4
- data.tar.gz: 694c0a043d7d2681652dd4a9e0ea3a668ccd35e300813acc8cfac2d6980caa3a
3
+ metadata.gz: 94a9dc3f92bdda4df449b88b989c0b90f79b1fcdd6f4ffe1729aa4b9aefb2992
4
+ data.tar.gz: 01c8f2034b5451b696ba58be76db5cf4d61be25d467e46b57fd4cfee455e3325
5
5
  SHA512:
6
- metadata.gz: 37ea9d924c98e51c2879a395a7e56050ee63060ace543a60c69a6df7d4b92054af945532ec0b559bcbc298eca4597eb471d845a853caaae1538928e25b929b83
7
- data.tar.gz: 69df60d5eeecc7747cca844b12adcac43d03396d676749d49ee5b381c8fc4f7b2b44543ad5605cf2772302820c087e37482a4dc43c826a925f4135772649d5ec
6
+ metadata.gz: 6fa5f840b24ffbb506292a9577fb9832bc374dd22bc9096bef6f0685e9a86ba94ebf2230685790b5b4f046b64f19d7b90725ae15b2a36fa76fe5a511048fa563
7
+ data.tar.gz: 95841918b7173a4b8f93ad4939acc121a07cbb1c99a29064333666f50cad5548e02d4a4ad4f5afdaf34c0612cc3f563ba279cd9373157fbcaae8aed0224993d4
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 change sanitized symbols on parsed number, so non-specified symbols won't be wiped and will fail the parsing
65
+
66
+ ``` ruby
67
+ Phonelib.sanitize_regex = '[\.\-\(\) \;\+]'
68
+ ```
69
+
64
70
  To disable sanitizing of double prefix on passed phone number
65
71
 
66
72
  ```ruby
Binary file
Binary file
@@ -107,6 +107,22 @@ module Phonelib
107
107
  @@strict_check = strict
108
108
  end
109
109
 
110
+ # @private sanitizing regex, matching symbols will get removed from parsed number, must be string
111
+ @@sanitize_regex = '[^0-9]+'
112
+
113
+ # getter for sanitize regex
114
+ # @return [String] regex of symbols to wipe from parsed number
115
+ def sanitize_regex
116
+ @@sanitize_regex
117
+ end
118
+
119
+ # setter for sanitize regex
120
+ # @param regex [String] symbols to wipe from parsed number
121
+ # @return [String] regex of symbols to wipe from parsed number
122
+ def sanitize_regex=(regex)
123
+ @@sanitize_regex = regex.is_a?(String) ? regex : regex.to_s
124
+ end
125
+
110
126
  # @private strict double prefix check for validator, doesn't sanitize number
111
127
  @@strict_double_prefix_check = false
112
128
 
@@ -145,10 +145,10 @@ module Phonelib
145
145
 
146
146
  require 'open-uri'
147
147
  require 'csv'
148
- io = open('http://download.geonames.org/export/dump/countryInfo.txt')
148
+ io = open('http://api.geonames.org/countryInfoCSV?username=demo&style=full')
149
149
  csv = CSV.new(io, {col_sep: "\t"})
150
150
  csv.each do |row|
151
- next if row[0].start_with?('#') || row[0].empty?
151
+ next if row[0].nil? || row[0].start_with?('#') || row[0].empty?
152
152
 
153
153
  @countries[row[0]] = row[4]
154
154
  end
@@ -51,7 +51,7 @@ module Phonelib
51
51
  def sanitized
52
52
  @sanitized ||=
53
53
  vanity_converted(@original).gsub(
54
- Phonelib.strict_check ? cr('^\+') : cr('[^0-9]+'),
54
+ Phonelib.strict_check ? cr('^\+') : cr(Phonelib.sanitize_regex),
55
55
  '')
56
56
  end
57
57
 
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # @private
3
- VERSION = '0.6.46'
3
+ VERSION = '0.6.47'
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.46
4
+ version: 0.6.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Senderovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
11
+ date: 2020-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  requirements: []
171
- rubygems_version: 3.0.6
171
+ rubygems_version: 3.0.9
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Gem validates phone numbers with Google libphonenumber database