phone_number_validator 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +25 -25
- data/Gemfile +6 -6
- data/LICENSE +21 -21
- data/README.rdoc +59 -59
- data/Rakefile +27 -27
- data/bin/pnv +18 -18
- data/doc/PhoneNumberValidator/Validator.html +230 -230
- data/doc/PhoneNumberValidator.html +160 -160
- data/doc/PhoneNumberValidatorTest.html +235 -235
- data/doc/README_rdoc.html +165 -165
- data/doc/created.rid +6 -6
- data/doc/index.html +159 -159
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +104 -104
- data/lib/phone_number_validator/validator.rb +34 -34
- data/lib/phone_number_validator.rb +18 -18
- data/phone_number_validator.gemspec +32 -32
- data/test/test_phone_number_validator.rb +31 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70599c5c934bc91808cb60be6de380eb6e810d740dc7fe4ace167d93b894ba41
|
4
|
+
data.tar.gz: 6b84cd997febce51fe048f4b82c45cf9fd151ddb7ca016ddeb27b3a25a147035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e648796b180a72b040fecd45bbe1e3475d4909994280fd81abb56aaa82c932af0a6296201eacc9cabd4a7defa3863ea1b8a45d9f5b6d23b317ee22bd013b00cf
|
7
|
+
data.tar.gz: 21d78579ff77840468f0dbff10e29a8f58950440fee1c1366cf3eb4d40d22c8487cf47b04c83db911237a2741fa38471bb21da524c6bf8c2672dae7d47ec1d29
|
data/.gitignore
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
# System File(s)/Folder(s)
|
2
|
-
.DS_Store
|
3
|
-
Thumbs.db
|
4
|
-
_MACOSX
|
5
|
-
|
6
|
-
# Editor File(s)/Folder(s)
|
7
|
-
*.code-workspace
|
8
|
-
*.sublime-project
|
9
|
-
*.sublime-workspace
|
10
|
-
.vscode
|
11
|
-
|
12
|
-
# Generated Files
|
13
|
-
*.gem
|
14
|
-
*.lock
|
15
|
-
|
16
|
-
# Executables
|
17
|
-
*.bat
|
18
|
-
*.sh
|
19
|
-
|
20
|
-
# if gitignore is not working, try this:
|
21
|
-
#
|
22
|
-
# git rm -r --cached .
|
23
|
-
# git add .
|
24
|
-
# git commit -m "fixed untracked files"
|
25
|
-
# git push
|
1
|
+
# System File(s)/Folder(s)
|
2
|
+
.DS_Store
|
3
|
+
Thumbs.db
|
4
|
+
_MACOSX
|
5
|
+
|
6
|
+
# Editor File(s)/Folder(s)
|
7
|
+
*.code-workspace
|
8
|
+
*.sublime-project
|
9
|
+
*.sublime-workspace
|
10
|
+
.vscode
|
11
|
+
|
12
|
+
# Generated Files
|
13
|
+
*.gem
|
14
|
+
*.lock
|
15
|
+
|
16
|
+
# Executables
|
17
|
+
*.bat
|
18
|
+
*.sh
|
19
|
+
|
20
|
+
# if gitignore is not working, try this:
|
21
|
+
#
|
22
|
+
# git rm -r --cached .
|
23
|
+
# git add .
|
24
|
+
# git commit -m "fixed untracked files"
|
25
|
+
# git push
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
platform :ruby do
|
3
|
-
gemspec
|
4
|
-
gem 'rdoc', '~> 6.0', '>= 6.0.4'
|
5
|
-
gem 'rake', '~> 11.2', '>= 11.2.2'
|
6
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
platform :ruby do
|
3
|
+
gemspec
|
4
|
+
gem 'rdoc', '~> 6.0', '>= 6.0.4'
|
5
|
+
gem 'rake', '~> 11.2', '>= 11.2.2'
|
6
|
+
end
|
data/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2018 bag33188
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 bag33188
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
= Phone Number Validator
|
2
|
-
|
3
|
-
== About
|
4
|
-
|
5
|
-
This app is a US phone number-validating RubyGem.
|
6
|
-
|
7
|
-
It uses a complex regular expression to validate any United States phone number.
|
8
|
-
|
9
|
-
=== Regular Expression
|
10
|
-
|
11
|
-
This gem uses the following regular expression:
|
12
|
-
|
13
|
-
# US Phone Numbers
|
14
|
-
/^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i
|
15
|
-
# Regex Flags: i (ignore case)
|
16
|
-
|
17
|
-
== Installing
|
18
|
-
|
19
|
-
$ gem install phone_number_validator
|
20
|
-
|
21
|
-
=== Install Required Gems/Dependencies
|
22
|
-
|
23
|
-
$ bundle install
|
24
|
-
|
25
|
-
=== Updateing Required Gems/Dependencies
|
26
|
-
|
27
|
-
$ bundle update
|
28
|
-
|
29
|
-
== Uninstalling
|
30
|
-
|
31
|
-
$ gem uninstall phone_number_validator
|
32
|
-
|
33
|
-
== Testing
|
34
|
-
|
35
|
-
$ rake test
|
36
|
-
|
37
|
-
== Usage
|
38
|
-
|
39
|
-
=== In command line
|
40
|
-
|
41
|
-
$ pnv "+1 (949) 355-6244 ext. 198842"
|
42
|
-
|
43
|
-
==== Output
|
44
|
-
|
45
|
-
=> true
|
46
|
-
|
47
|
-
=== In Ruby code
|
48
|
-
|
49
|
-
require 'phone_number_validator'
|
50
|
-
|
51
|
-
check_phone_number = PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')
|
52
|
-
|
53
|
-
print check_phone_number
|
54
|
-
|
55
|
-
==== Output
|
56
|
-
|
57
|
-
=> true
|
58
|
-
|
59
|
-
Output can be <b>true</b> (<em>boolean, valid phone number</em>), <b>false</b> (<em>boolean, invalid phone number</em>), or <b>nil</b> (<em>symbol, no phone number entered</em>).
|
1
|
+
= Phone Number Validator
|
2
|
+
|
3
|
+
== About
|
4
|
+
|
5
|
+
This app is a US phone number-validating RubyGem.
|
6
|
+
|
7
|
+
It uses a complex regular expression to validate any United States phone number.
|
8
|
+
|
9
|
+
=== Regular Expression
|
10
|
+
|
11
|
+
This gem uses the following regular expression:
|
12
|
+
|
13
|
+
# US Phone Numbers
|
14
|
+
/^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i
|
15
|
+
# Regex Flags: i (ignore case)
|
16
|
+
|
17
|
+
== Installing
|
18
|
+
|
19
|
+
$ gem install phone_number_validator
|
20
|
+
|
21
|
+
=== Install Required Gems/Dependencies
|
22
|
+
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
=== Updateing Required Gems/Dependencies
|
26
|
+
|
27
|
+
$ bundle update
|
28
|
+
|
29
|
+
== Uninstalling
|
30
|
+
|
31
|
+
$ gem uninstall phone_number_validator
|
32
|
+
|
33
|
+
== Testing
|
34
|
+
|
35
|
+
$ rake test
|
36
|
+
|
37
|
+
== Usage
|
38
|
+
|
39
|
+
=== In command line
|
40
|
+
|
41
|
+
$ pnv "+1 (949) 355-6244 ext. 198842"
|
42
|
+
|
43
|
+
==== Output
|
44
|
+
|
45
|
+
=> true
|
46
|
+
|
47
|
+
=== In Ruby code
|
48
|
+
|
49
|
+
require 'phone_number_validator'
|
50
|
+
|
51
|
+
check_phone_number = PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')
|
52
|
+
|
53
|
+
print check_phone_number
|
54
|
+
|
55
|
+
==== Output
|
56
|
+
|
57
|
+
=> true
|
58
|
+
|
59
|
+
Output can be <b>true</b> (<em>boolean, valid phone number</em>), <b>false</b> (<em>boolean, invalid phone number</em>), or <b>nil</b> (<em>symbol, no phone number entered</em>).
|
data/Rakefile
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
require 'rake/testtask'
|
2
|
-
|
3
|
-
Rake::TestTask.new do |test|
|
4
|
-
test.libs << 'test'
|
5
|
-
end
|
6
|
-
|
7
|
-
desc 'Run tests'
|
8
|
-
task :default => :test
|
9
|
-
|
10
|
-
require 'rdoc/task'
|
11
|
-
|
12
|
-
RDoc::Task.new do |rdoc|
|
13
|
-
rdoc.main = 'README.rdoc'
|
14
|
-
rdoc.title = 'Phone Number Validator'
|
15
|
-
rdoc.rdoc_dir = 'doc'
|
16
|
-
rdoc.rdoc_files.include('README.rdoc', 'lib/*.rb', 'lib/**/*.rb', 'test/*.rb', 'bin/*')
|
17
|
-
end
|
18
|
-
|
19
|
-
# for Windows
|
20
|
-
task :deldocw do
|
21
|
-
`RMDIR /S /Q "doc"`
|
22
|
-
end
|
23
|
-
|
24
|
-
# for Unix
|
25
|
-
task :deldocx do
|
26
|
-
`rm -rf doc`
|
27
|
-
end
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
Rake::TestTask.new do |test|
|
4
|
+
test.libs << 'test'
|
5
|
+
end
|
6
|
+
|
7
|
+
desc 'Run tests'
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
require 'rdoc/task'
|
11
|
+
|
12
|
+
RDoc::Task.new do |rdoc|
|
13
|
+
rdoc.main = 'README.rdoc'
|
14
|
+
rdoc.title = 'Phone Number Validator'
|
15
|
+
rdoc.rdoc_dir = 'doc'
|
16
|
+
rdoc.rdoc_files.include('README.rdoc', 'lib/*.rb', 'lib/**/*.rb', 'test/*.rb', 'bin/*')
|
17
|
+
end
|
18
|
+
|
19
|
+
# for Windows
|
20
|
+
task :deldocw do
|
21
|
+
`RMDIR /S /Q "doc"`
|
22
|
+
end
|
23
|
+
|
24
|
+
# for Unix
|
25
|
+
task :deldocx do
|
26
|
+
`rm -rf doc`
|
27
|
+
end
|
data/bin/pnv
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
=begin
|
4
|
-
|======================|
|
5
|
-
| PhoneNumberValidator |
|
6
|
-
|----------------------|
|
7
|
-
| Made by: bag33188 |
|
8
|
-
|======================|
|
9
|
-
=end
|
10
|
-
|
11
|
-
require 'phone_number_validator'
|
12
|
-
|
13
|
-
if (ARGV[0] == nil)
|
14
|
-
print
|
15
|
-
else
|
16
|
-
# execute validator
|
17
|
-
puts PhoneNumberValidator.validate(ARGV[0])
|
18
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|======================|
|
5
|
+
| PhoneNumberValidator |
|
6
|
+
|----------------------|
|
7
|
+
| Made by: bag33188 |
|
8
|
+
|======================|
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'phone_number_validator'
|
12
|
+
|
13
|
+
if (ARGV[0] == nil)
|
14
|
+
print "No phone number entered.\r\n"
|
15
|
+
else
|
16
|
+
# execute validator
|
17
|
+
puts PhoneNumberValidator.validate(ARGV[0])
|
18
|
+
end
|