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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c01038c9597e5b81b8f362642fd3de6b2ce53b9c37d5d59d59b6baedb704e3d5
4
- data.tar.gz: f283b8a780f16a1d77db1c1bef45277ed9fe49a55b7921577a41474da05dcfa0
3
+ metadata.gz: 9584b7b8f08c4262f932920e37a409a5d0dfc43f02b4d41f3193d6f0309e2388
4
+ data.tar.gz: 3aee8c3998cea0b191b1a3f060f819e6e24953a3a4626cc987608cdca30b6505
5
5
  SHA512:
6
- metadata.gz: f38d3b1c5aff889a704ff89e90058addf324ed86014cf7033c6c8f344c443bc2bdeca792e5dfcffbca730c3b8e9bb114884cec560df52c84c64698f29b7bb41e
7
- data.tar.gz: 2c948878c14b2cc08b06c034122f2b4d10afe13b7afc91a738a75e179153ac61a10cbc0c94a13e6c057c4c6a0d7336a42ddb1a77f978cb0b3292b6257c9d56f4
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
@@ -11,4 +11,5 @@
11
11
  require 'phone_number_validator'
12
12
 
13
13
  print "\r\n"
14
+ # execute validator
14
15
  puts(PhoneNumberValidator.validate_phone_number(ARGV[0]))
@@ -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">&para;</a> <a href="#top">&uarr;</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 18</span>
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">&para;</a> <a href="#top">&uarr;</a></span></h2>
110
110
 
111
111
  <p>Regular Expression tested using <a
112
- href="https://regexr.com/">regexr.com</a></p>
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 20</span>
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">&#39;+1 (949) 355-6244 ext. 198842&#39;</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">&para;</a> <a href="#top">&uarr;</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</p>
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 32</span>
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">&quot;&#39;%s&#39; is a valid phone number.&quot;</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">&para;</a> <a href="#top">&uarr;</a></span></h1>
91
91
 
92
- <p><strong>Inherits from:</strong></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 24</span>
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">&#39;94643823637337&#39;</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 15</span>
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">&#39;+1 (949) 355-6244 ext. 198842&#39;</span>)
data/doc/created.rid CHANGED
@@ -1,6 +1,6 @@
1
- Sun, 04 Nov 2018 17:24:53 -0800
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 17:16:18 -0800
4
- lib/phone_number_validator/validator.rb Sun, 04 Nov 2018 17:24:38 -0800
5
- test/test_phone_number_validator.rb Sun, 04 Nov 2018 17:24:26 -0800
6
- bin/phone_number_validator Sun, 04 Nov 2018 14:35:10 -0800
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
Binary file
@@ -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><strong>Inherits from:</strong>\n\n<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>\n</pre>\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(&#39;+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"]]}}
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(&#39;+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"]]}}
Binary file
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.8'
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,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phone_number_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - bag33188