phonelib 0.6.42 → 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: b77a627655db4c34f0879f0dec65e326abe62dbf60fa4a158ca2599922100551
4
- data.tar.gz: 9920a5b9f955217f7e5768501af64f5751544e6f22608178a3a91c0d7a1a2f69
3
+ metadata.gz: 94a9dc3f92bdda4df449b88b989c0b90f79b1fcdd6f4ffe1729aa4b9aefb2992
4
+ data.tar.gz: 01c8f2034b5451b696ba58be76db5cf4d61be25d467e46b57fd4cfee455e3325
5
5
  SHA512:
6
- metadata.gz: 19b9d77ba6a7e7b26f19c09fc1b3a5f692db1f2f4205ba5cdda4e82fa144df32fb1dd3c8419a7a5d7065935556b215be33805487a3848ba814da8416a0db924d
7
- data.tar.gz: c83ca573baf9347761aebc9a3183842d4e16ac4daae47f2a5090247487bc8f5f749c4c9bf009f0d7caa352118b1c64327573bc12be61a1ab4ac9346338803b12
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
data/Rakefile CHANGED
@@ -22,6 +22,13 @@ end
22
22
  Bundler::GemHelper.install_tasks
23
23
 
24
24
  require 'rspec/core/rake_task'
25
+ module TempFixForRakeLastComment
26
+ def last_comment
27
+ last_description
28
+ end
29
+ end
30
+ Rake::Application.send :include, TempFixForRakeLastComment
31
+
25
32
  RSpec::Core::RakeTask.new(:spec) do |t|
26
33
  if defined? Rails
27
34
  puts 'Rails found! Running tests with Rails'
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
 
@@ -44,7 +44,7 @@ module Phonelib
44
44
  prefix = formatted if formatted.is_a?(String)
45
45
  return nil if sanitized.empty?
46
46
  return "#{prefix}#{country_prefix_or_not}#{sanitized}" unless valid?
47
- return country_code + @national_number unless formatted
47
+ return "#{prefix}#{country_code}#{@national_number}" unless formatted
48
48
 
49
49
  fmt = @data[country][:format]
50
50
  national = @national_number
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # @private
3
- VERSION = '0.6.42'
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.42
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-02-11 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
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '11.0'
19
+ version: '14.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '11.0'
26
+ version: '14.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.10.4
33
+ version: 1.10.8
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.10.4
40
+ version: 1.10.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.8.6
117
+ version: 2.3.1
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 1.8.6
124
+ version: 2.3.1
125
125
  description: |2
126
126
  Google libphonenumber library was taken as a basis for
127
127
  this gem. Gem uses its data file for validations and number formatting.
@@ -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