phone_number_validator 0.2.8 → 0.2.9
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/Rakefile +1 -1
- data/bin/phone_number_validator +1 -0
- data/doc/PhoneNumberValidator.html +4 -1
- data/doc/PhoneNumberValidator/Validator.html +5 -8
- data/doc/PhoneNumberValidatorTest.html +4 -3
- data/doc/created.rid +5 -5
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/lib/phone_number_validator.rb +1 -3
- data/lib/phone_number_validator/validator.rb +0 -6
- data/phone_number_validator.gemspec +1 -1
- data/test/test_phone_number_validator.rb +1 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9584b7b8f08c4262f932920e37a409a5d0dfc43f02b4d41f3193d6f0309e2388
|
4
|
+
data.tar.gz: 3aee8c3998cea0b191b1a3f060f819e6e24953a3a4626cc987608cdca30b6505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c828ccc0e82a4bdf0ba74c282760dc4d92885dc7233a6b0b7f4f0e12a0166e250ac8a194b15cb3ebb83fbddfafd00ea5429e498fd61895115ab9d61badad41b3
|
7
|
+
data.tar.gz: ce2707bcdbc97f8ca2d0a4038cab1e9e1ddcb3128363ecabbb94997edf5456d76e4270a1f22fba57b135d1e307ccc994aa120b2a93163ffb934e46fae70e4540
|
data/Rakefile
CHANGED
@@ -12,8 +12,8 @@ require 'rdoc/task'
|
|
12
12
|
RDoc::Task.new do |rdoc|
|
13
13
|
rdoc.main = "README.rdoc"
|
14
14
|
rdoc.title = 'Phone Number Validator'
|
15
|
-
rdoc.rdoc_files.include('README.rdoc', 'lib/*.rb', 'lib/**/*.rb', 'test/*.rb', 'bin/*')
|
16
15
|
rdoc.rdoc_dir = 'doc'
|
16
|
+
rdoc.rdoc_files.include('README.rdoc', 'lib/*.rb', 'lib/**/*.rb', 'test/*.rb', 'bin/*')
|
17
17
|
end
|
18
18
|
|
19
19
|
# for Windows
|
data/bin/phone_number_validator
CHANGED
@@ -87,6 +87,9 @@
|
|
87
87
|
|
88
88
|
<h1 id="class-PhoneNumberValidator-label-Phone+Number+Validator+Parent+Class">Phone Number Validator Parent Class<span><a href="#class-PhoneNumberValidator-label-Phone+Number+Validator+Parent+Class">¶</a> <a href="#top">↑</a></span></h1>
|
89
89
|
|
90
|
+
<p>This class is the master/parent class to all of the validation
|
91
|
+
functionality</p>
|
92
|
+
|
90
93
|
</section>
|
91
94
|
|
92
95
|
|
@@ -141,7 +144,7 @@
|
|
141
144
|
|
142
145
|
|
143
146
|
<div class="method-source-code" id="validate_phone_number-source">
|
144
|
-
<pre><span class="ruby-comment"># File lib/phone_number_validator.rb, line
|
147
|
+
<pre><span class="ruby-comment"># File lib/phone_number_validator.rb, line 16</span>
|
145
148
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-identifier">phone_number</span>)
|
146
149
|
<span class="ruby-identifier">validator</span> = <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">phone_number</span>)
|
147
150
|
<span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_phone_number</span>
|
@@ -109,9 +109,8 @@
|
|
109
109
|
<dd><h2 id="label-Validates+US+Phone+Numbers">Validates US Phone Numbers<span><a href="#label-Validates+US+Phone+Numbers">¶</a> <a href="#top">↑</a></span></h2>
|
110
110
|
|
111
111
|
<p>Regular Expression tested using <a
|
112
|
-
href="https://regexr.com/">regexr.com</a
|
113
|
-
|
114
|
-
<p><strong>Raw Regular Expression:</strong></p>
|
112
|
+
href="https://regexr.com/">regexr.com</a> <strong>Raw Regular
|
113
|
+
Expression:</strong></p>
|
115
114
|
|
116
115
|
<pre class="ruby"><span class="ruby-node">/^(?:(?:[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</span>
|
117
116
|
</pre>
|
@@ -159,7 +158,7 @@ href="https://regexr.com/">regexr.com</a></p>
|
|
159
158
|
|
160
159
|
|
161
160
|
<div class="method-source-code" id="new-source">
|
162
|
-
<pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line
|
161
|
+
<pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 16</span>
|
163
162
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">phone_number</span> = <span class="ruby-string">'+1 (949) 355-6244 ext. 198842'</span>)
|
164
163
|
<span class="ruby-ivar">@phone_number</span> = <span class="ruby-identifier">phone_number</span>
|
165
164
|
<span class="ruby-keyword">end</span></pre>
|
@@ -197,9 +196,7 @@ href="https://regexr.com/">regexr.com</a></p>
|
|
197
196
|
<h2 id="method-i-validate_phone_number-label-Validation+Method">Validation Method<span><a href="#method-i-validate_phone_number-label-Validation+Method">¶</a> <a href="#top">↑</a></span></h2>
|
198
197
|
|
199
198
|
<p>Checks to see if the phone number the user entered is valid by testing
|
200
|
-
regex the pattern with the phone number
|
201
|
-
|
202
|
-
<p><strong>Return Type:</strong></p>
|
199
|
+
regex the pattern with the phone number <strong>Return Type:</strong></p>
|
203
200
|
|
204
201
|
<pre class="ruby"><span class="ruby-identifier">boolean</span>
|
205
202
|
</pre>
|
@@ -208,7 +205,7 @@ regex the pattern with the phone number</p>
|
|
208
205
|
|
209
206
|
|
210
207
|
<div class="method-source-code" id="validate_phone_number-source">
|
211
|
-
<pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line
|
208
|
+
<pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 26</span>
|
212
209
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">validate_phone_number</span>
|
213
210
|
<span class="ruby-keyword">if</span> (<span class="ruby-ivar">@phone_number</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">PHONE_NUMBER_REGEX</span>))
|
214
211
|
<span class="ruby-identifier">puts</span> <span class="ruby-string">"'%s' is a valid phone number."</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@phone_number</span>
|
@@ -89,7 +89,8 @@
|
|
89
89
|
|
90
90
|
<h1 id="class-PhoneNumberValidatorTest-label-Phone+Number+Validator+Test+Class">Phone Number Validator Test Class<span><a href="#class-PhoneNumberValidatorTest-label-Phone+Number+Validator+Test+Class">¶</a> <a href="#top">↑</a></span></h1>
|
91
91
|
|
92
|
-
<p
|
92
|
+
<p>This class respresents the testing-unit for this gem app <strong>Inherits
|
93
|
+
from:</strong></p>
|
93
94
|
|
94
95
|
<pre class="ruby"><span class="ruby-constant">Test</span><span class="ruby-operator">::</span><span class="ruby-constant">Unit</span><span class="ruby-operator">::</span><span class="ruby-constant">TestCase</span>
|
95
96
|
</pre>
|
@@ -137,7 +138,7 @@
|
|
137
138
|
|
138
139
|
|
139
140
|
<div class="method-source-code" id="test_invalid_phone_number-source">
|
140
|
-
<pre><span class="ruby-comment"># File test/test_phone_number_validator.rb, line
|
141
|
+
<pre><span class="ruby-comment"># File test/test_phone_number_validator.rb, line 22</span>
|
141
142
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_invalid_phone_number</span>
|
142
143
|
<span class="ruby-identifier">assert_equal</span> <span class="ruby-keyword">false</span>,
|
143
144
|
<span class="ruby-constant">PhoneNumberValidator</span>.<span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-string">'94643823637337'</span>)
|
@@ -174,7 +175,7 @@
|
|
174
175
|
|
175
176
|
|
176
177
|
<div class="method-source-code" id="test_valid_phone_number-source">
|
177
|
-
<pre><span class="ruby-comment"># File test/test_phone_number_validator.rb, line
|
178
|
+
<pre><span class="ruby-comment"># File test/test_phone_number_validator.rb, line 14</span>
|
178
179
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_valid_phone_number</span>
|
179
180
|
<span class="ruby-identifier">assert_equal</span> <span class="ruby-keyword">true</span>,
|
180
181
|
<span class="ruby-constant">PhoneNumberValidator</span>.<span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-string">'+1 (949) 355-6244 ext. 198842'</span>)
|
data/doc/created.rid
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
Sun, 04 Nov 2018 17:
|
1
|
+
Sun, 04 Nov 2018 18:17:01 -0800
|
2
2
|
README.rdoc Sun, 04 Nov 2018 17:11:34 -0800
|
3
|
-
lib/phone_number_validator.rb Sun, 04 Nov 2018
|
4
|
-
lib/phone_number_validator/validator.rb Sun, 04 Nov 2018
|
5
|
-
test/test_phone_number_validator.rb Sun, 04 Nov 2018
|
6
|
-
bin/phone_number_validator Sun, 04 Nov 2018
|
3
|
+
lib/phone_number_validator.rb Sun, 04 Nov 2018 18:16:04 -0800
|
4
|
+
lib/phone_number_validator/validator.rb Sun, 04 Nov 2018 18:14:54 -0800
|
5
|
+
test/test_phone_number_validator.rb Sun, 04 Nov 2018 18:14:30 -0800
|
6
|
+
bin/phone_number_validator Sun, 04 Nov 2018 18:16:53 -0800
|
data/doc/js/navigation.js.gz
CHANGED
Binary file
|
data/doc/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["phonenumbervalidator","validator","phonenumbervalidatortest","new()","test_invalid_phone_number()","test_valid_phone_number()","validate_phone_number()","validate_phone_number()","readme"],"longSearchIndex":["phonenumbervalidator","phonenumbervalidator::validator","phonenumbervalidatortest","phonenumbervalidator::validator::new()","phonenumbervalidatortest#test_invalid_phone_number()","phonenumbervalidatortest#test_valid_phone_number()","phonenumbervalidator::validate_phone_number()","phonenumbervalidator::validator#validate_phone_number()",""],"info":[["PhoneNumberValidator","","PhoneNumberValidator.html","","<p>Phone Number Validator Parent Class\n"],["PhoneNumberValidator::Validator","","PhoneNumberValidator/Validator.html","",""],["PhoneNumberValidatorTest","","PhoneNumberValidatorTest.html","","<p>Phone Number Validator Test Class\n<p
|
1
|
+
var search_data = {"index":{"searchIndex":["phonenumbervalidator","validator","phonenumbervalidatortest","new()","test_invalid_phone_number()","test_valid_phone_number()","validate_phone_number()","validate_phone_number()","readme"],"longSearchIndex":["phonenumbervalidator","phonenumbervalidator::validator","phonenumbervalidatortest","phonenumbervalidator::validator::new()","phonenumbervalidatortest#test_invalid_phone_number()","phonenumbervalidatortest#test_valid_phone_number()","phonenumbervalidator::validate_phone_number()","phonenumbervalidator::validator#validate_phone_number()",""],"info":[["PhoneNumberValidator","","PhoneNumberValidator.html","","<p>Phone Number Validator Parent Class\n<p>This class is the master/parent class to all of the validation\nfunctionality …\n"],["PhoneNumberValidator::Validator","","PhoneNumberValidator/Validator.html","",""],["PhoneNumberValidatorTest","","PhoneNumberValidatorTest.html","","<p>Phone Number Validator Test Class\n<p>This class respresents the testing-unit for this gem app <strong>Inherits\nfrom:</strong> …\n"],["new","PhoneNumberValidator::Validator","PhoneNumberValidator/Validator.html#method-c-new","(phone_number = '+1 (949) 355-6244 ext. 198842')","<p>Initialize Phone Number\n<p><strong>Method type:</strong>\n\n<pre class=\"ruby\"><span class=\"ruby-identifier\">constructor</span>\n</pre>\n"],["test_invalid_phone_number","PhoneNumberValidatorTest","PhoneNumberValidatorTest.html#method-i-test_invalid_phone_number","()","<p>Negative Test\n<p>Inputs an invalid phone number and expects the output to be\n<strong>false</strong>\n"],["test_valid_phone_number","PhoneNumberValidatorTest","PhoneNumberValidatorTest.html#method-i-test_valid_phone_number","()","<p>Positive Test\n<p>Inputs a valid phone number and expects the output to be\n<strong>true</strong>\n"],["validate_phone_number","PhoneNumberValidator","PhoneNumberValidator.html#method-c-validate_phone_number","(phone_number)","<p>Validate any United States phone number!\n<p><strong>Example:</strong>\n\n<pre>PhoneNumberValidator.validate_phone_number('+1 (949) ...</pre>\n"],["validate_phone_number","PhoneNumberValidator::Validator","PhoneNumberValidator/Validator.html#method-i-validate_phone_number","()","<p>Validation Method\n<p>Checks to see if the phone number the user entered is valid by testing\nregex the pattern …\n"],["README","","README_rdoc.html","","<p>Phone Number Validator\n<p>About\n<p>This app is a US phone number-validating RubyGem.\n"]]}}
|
data/doc/js/search_index.js.gz
CHANGED
Binary file
|
data/doc/js/searcher.js.gz
CHANGED
Binary file
|
@@ -1,18 +1,16 @@
|
|
1
1
|
##
|
2
2
|
# = Phone Number \Validator Parent Class
|
3
|
+
# This class is the master/parent class to all of the validation functionality
|
3
4
|
class PhoneNumberValidator
|
4
5
|
class << self
|
5
6
|
|
6
7
|
##
|
7
8
|
# == Validate any United States phone number!
|
8
|
-
#
|
9
9
|
# <b>Example:</b>
|
10
10
|
# PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')
|
11
|
-
#
|
12
11
|
# <b>Output:</b>
|
13
12
|
# => '+1 (949) 355-6244 ext. 198842' is a valid phone number.'
|
14
13
|
# => true
|
15
|
-
#
|
16
14
|
# <b>Arguments:</b>
|
17
15
|
# phone_number: (String)
|
18
16
|
def validate_phone_number(phone_number)
|
@@ -2,19 +2,15 @@ class PhoneNumberValidator::Validator
|
|
2
2
|
|
3
3
|
##
|
4
4
|
# == Validates US Phone Numbers
|
5
|
-
#
|
6
5
|
# Regular Expression tested using {regexr.com}[https://regexr.com/]
|
7
|
-
#
|
8
6
|
# <b>Raw Regular Expression:</b>
|
9
7
|
# /^(?:(?:[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
|
10
|
-
#
|
11
8
|
# <b>RegEx Flags:</b>
|
12
9
|
# Regexp::IGNORECASE (i)
|
13
10
|
PHONE_NUMBER_REGEX = Regexp.new('^(?:(?:[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+))?)$', Regexp::IGNORECASE)
|
14
11
|
|
15
12
|
##
|
16
13
|
# == Initialize Phone Number
|
17
|
-
#
|
18
14
|
# <b>Method type:</b>
|
19
15
|
# constructor
|
20
16
|
def initialize(phone_number = '+1 (949) 355-6244 ext. 198842')
|
@@ -23,10 +19,8 @@ class PhoneNumberValidator::Validator
|
|
23
19
|
|
24
20
|
##
|
25
21
|
# == Validation Method
|
26
|
-
#
|
27
22
|
# Checks to see if the phone number the user entered is valid
|
28
23
|
# by testing regex the pattern with the phone number
|
29
|
-
#
|
30
24
|
# <b>Return Type:</b>
|
31
25
|
# boolean
|
32
26
|
def validate_phone_number
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'phone_number_validator'
|
3
|
-
spec.version = '0.2.
|
3
|
+
spec.version = '0.2.9'
|
4
4
|
spec.date = Time.now.strftime("%Y-%m-%d")
|
5
5
|
spec.summary = 'Validate any US phone number!'
|
6
6
|
spec.description = 'This gem is a United States phone number validator. This gem uses a complex regular expression that can validate any United States phone number.'
|
@@ -3,14 +3,13 @@ require 'phone_number_validator'
|
|
3
3
|
|
4
4
|
##
|
5
5
|
# = Phone Number \Validator Test Class
|
6
|
-
#
|
6
|
+
# This class respresents the testing-unit for this gem app
|
7
7
|
# <b>Inherits from:</b>
|
8
8
|
# Test::Unit::TestCase
|
9
9
|
class PhoneNumberValidatorTest < Test::Unit::TestCase
|
10
10
|
|
11
11
|
##
|
12
12
|
# == Positive Test
|
13
|
-
#
|
14
13
|
# Inputs a valid phone number and expects the output to be <b>true</b>
|
15
14
|
def test_valid_phone_number
|
16
15
|
assert_equal true,
|
@@ -19,7 +18,6 @@ class PhoneNumberValidatorTest < Test::Unit::TestCase
|
|
19
18
|
|
20
19
|
##
|
21
20
|
# == Negative Test
|
22
|
-
#
|
23
21
|
# Inputs an invalid phone number and expects the output to be <b>false</b>
|
24
22
|
def test_invalid_phone_number
|
25
23
|
assert_equal false,
|