phone_number_validator 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +26 -26
- data/Gemfile +6 -6
- data/LICENSE +21 -21
- data/README.rdoc +66 -66
- data/Rakefile +26 -26
- data/bin/pnv +18 -18
- data/doc/PhoneNumberValidator.html +161 -161
- data/doc/PhoneNumberValidator/Validator.html +228 -225
- data/doc/PhoneNumberValidatorTest.html +236 -234
- data/doc/README_rdoc.html +171 -171
- data/doc/created.rid +6 -6
- data/doc/css/fonts.css +6 -6
- data/doc/index.html +164 -165
- data/doc/js/darkfish.js +7 -7
- data/doc/js/navigation.js +4 -3
- 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 +0 -1
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +104 -134
- data/lib/phone_number_validator.rb +18 -18
- data/lib/phone_number_validator/validator.rb +33 -33
- data/phone_number_validator.gemspec +36 -34
- data/test/test_phone_number_validator.rb +31 -31
- metadata +43 -2
data/doc/README_rdoc.html
CHANGED
@@ -1,171 +1,171 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>README - Phone Number Validator</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "./";
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<script src="./js/
|
15
|
-
|
16
|
-
|
17
|
-
<link href="./css/
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
<
|
24
|
-
<
|
25
|
-
<
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<a href="./table_of_contents.html#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
<div id="search-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
</div>
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
<
|
58
|
-
|
59
|
-
|
60
|
-
<li><a href="#label-
|
61
|
-
<li><a href="#label-
|
62
|
-
<li><a href="#label-
|
63
|
-
<li><a href="#label-
|
64
|
-
<li><a href="#label-
|
65
|
-
<li><a href="#label-
|
66
|
-
<li><a href="#label-
|
67
|
-
<li><a href="#label-
|
68
|
-
<li><a href="#label-
|
69
|
-
<li><a href="#label-In+
|
70
|
-
<li><a href="#label-Output">Output</a>
|
71
|
-
<li><a href="#label-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
<
|
79
|
-
|
80
|
-
<
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
</div>
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
<
|
93
|
-
|
94
|
-
<
|
95
|
-
|
96
|
-
<
|
97
|
-
|
98
|
-
<p>
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
<
|
107
|
-
<span class="ruby-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
<
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
</main>
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
<footer id="validator-badges" role="contentinfo">
|
167
|
-
<p><a href="
|
168
|
-
<p>Generated by <a href="
|
169
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
170
|
-
</footer>
|
171
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>README - Phone Number Validator</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<script src="./js/jquery.js"></script>
|
14
|
+
<script src="./js/darkfish.js"></script>
|
15
|
+
|
16
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
<body id="top" role="document" class="file">
|
22
|
+
<nav role="navigation">
|
23
|
+
<div id="project-navigation">
|
24
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
25
|
+
<h2>
|
26
|
+
<a href="./index.html" rel="home">Home</a>
|
27
|
+
</h2>
|
28
|
+
|
29
|
+
<div id="table-of-contents-navigation">
|
30
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
31
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
32
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
37
|
+
<form action="#" method="get" accept-charset="utf-8">
|
38
|
+
<div id="search-field-wrapper">
|
39
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
40
|
+
aria-autocomplete="list" aria-controls="search-results"
|
41
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
42
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<ul id="search-results" aria-label="Search Results"
|
46
|
+
aria-busy="false" aria-expanded="false"
|
47
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
48
|
+
</form>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
|
53
|
+
|
54
|
+
<div class="nav-section">
|
55
|
+
<h3>Table of Contents</h3>
|
56
|
+
|
57
|
+
<ul class="link-list" role="directory">
|
58
|
+
<li><a href="#label-Phone+Number+Validator">Phone Number Validator</a>
|
59
|
+
<li><a href="#label-About">About</a>
|
60
|
+
<li><a href="#label-Regular+Expression">Regular Expression</a>
|
61
|
+
<li><a href="#label-Installing">Installing</a>
|
62
|
+
<li><a href="#label-Install+Required+Gems-2FDependencies">Install Required Gems/Dependencies</a>
|
63
|
+
<li><a href="#label-Updating+Required+Gems-2FDependencies">Updating Required Gems/Dependencies</a>
|
64
|
+
<li><a href="#label-Uninstalling">Uninstalling</a>
|
65
|
+
<li><a href="#label-Testing">Testing</a>
|
66
|
+
<li><a href="#label-Usage">Usage</a>
|
67
|
+
<li><a href="#label-In+command+line">In command line</a>
|
68
|
+
<li><a href="#label-Output">Output</a>
|
69
|
+
<li><a href="#label-In+Ruby+code">In Ruby code</a>
|
70
|
+
<li><a href="#label-Output">Output</a>
|
71
|
+
<li><a href="#label-Development">Development</a>
|
72
|
+
</ul>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
|
76
|
+
<div id="project-metadata">
|
77
|
+
<div id="fileindex-section" class="nav-section">
|
78
|
+
<h3>Pages</h3>
|
79
|
+
|
80
|
+
<ul class="link-list">
|
81
|
+
|
82
|
+
<li><a href="./README_rdoc.html">README</a>
|
83
|
+
|
84
|
+
</ul>
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
</nav>
|
89
|
+
|
90
|
+
<main role="main" aria-label="Page README.rdoc">
|
91
|
+
|
92
|
+
<h1 id="label-Phone+Number+Validator">Phone Number Validator<span><a href="#label-Phone+Number+Validator">¶</a> <a href="#top">↑</a></span></h1>
|
93
|
+
|
94
|
+
<h2 id="label-About">About<span><a href="#label-About">¶</a> <a href="#top">↑</a></span></h2>
|
95
|
+
|
96
|
+
<p>This app is a US phone number-validating RubyGem.</p>
|
97
|
+
|
98
|
+
<p>It uses a complex regular expression to validate any United States phone
|
99
|
+
number.</p>
|
100
|
+
|
101
|
+
<h3 id="label-Regular+Expression">Regular Expression<span><a href="#label-Regular+Expression">¶</a> <a href="#top">↑</a></span></h3>
|
102
|
+
|
103
|
+
<p>This gem uses the following regular expression:</p>
|
104
|
+
|
105
|
+
<pre class="ruby"><span class="ruby-comment"># US Phone Numbers</span>
|
106
|
+
<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>
|
107
|
+
<span class="ruby-comment"># Regex Flags: i (ignore case)</span>
|
108
|
+
</pre>
|
109
|
+
|
110
|
+
<h2 id="label-Installing">Installing<span><a href="#label-Installing">¶</a> <a href="#top">↑</a></span></h2>
|
111
|
+
|
112
|
+
<pre>$ gem install phone_number_validator</pre>
|
113
|
+
|
114
|
+
<h3 id="label-Install+Required+Gems-2FDependencies">Install Required Gems/Dependencies<span><a href="#label-Install+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
115
|
+
|
116
|
+
<pre>$ bundle install</pre>
|
117
|
+
|
118
|
+
<h3 id="label-Updating+Required+Gems-2FDependencies">Updating Required Gems/Dependencies<span><a href="#label-Updating+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
119
|
+
|
120
|
+
<pre>$ bundle update</pre>
|
121
|
+
|
122
|
+
<h2 id="label-Uninstalling">Uninstalling<span><a href="#label-Uninstalling">¶</a> <a href="#top">↑</a></span></h2>
|
123
|
+
|
124
|
+
<pre>$ gem uninstall phone_number_validator</pre>
|
125
|
+
|
126
|
+
<h2 id="label-Testing">Testing<span><a href="#label-Testing">¶</a> <a href="#top">↑</a></span></h2>
|
127
|
+
|
128
|
+
<pre>$ rake test</pre>
|
129
|
+
|
130
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
131
|
+
|
132
|
+
<h3 id="label-In+command+line">In command line<span><a href="#label-In+command+line">¶</a> <a href="#top">↑</a></span></h3>
|
133
|
+
|
134
|
+
<pre>$ pnv "+1 (987) 654-3210 ext. 198842"</pre>
|
135
|
+
|
136
|
+
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
137
|
+
|
138
|
+
<pre>=> true</pre>
|
139
|
+
|
140
|
+
<h3 id="label-In+Ruby+code">In Ruby code<span><a href="#label-In+Ruby+code">¶</a> <a href="#top">↑</a></span></h3>
|
141
|
+
|
142
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'phone_number_validator'</span>
|
143
|
+
|
144
|
+
<span class="ruby-identifier">check_phone_number</span> = <span class="ruby-constant">PhoneNumberValidator</span>.<span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-string">'+1 (987) 654-3210 ext. 198842'</span>)
|
145
|
+
|
146
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">check_phone_number</span>
|
147
|
+
</pre>
|
148
|
+
|
149
|
+
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
150
|
+
|
151
|
+
<pre>=> true</pre>
|
152
|
+
|
153
|
+
<p>Output can be <strong>true</strong> (<em>boolean, valid phone number</em>),
|
154
|
+
<strong>false</strong> (<em>boolean, invalid phone number</em>), or
|
155
|
+
<strong>nil</strong> (<em>symbol, no phone number entered</em>).</p>
|
156
|
+
|
157
|
+
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
158
|
+
|
159
|
+
<p>Run the following to make <code>bin/pnv</code> executable (Unix only):</p>
|
160
|
+
|
161
|
+
<pre>chmod ugo+x bin/pnv</pre>
|
162
|
+
</main>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
<footer id="validator-badges" role="contentinfo">
|
167
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
168
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.1.
|
169
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
170
|
+
</footer>
|
171
|
+
|
data/doc/created.rid
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
Wed, 07 Aug 2019 08:
|
2
|
-
README.rdoc Wed, 07 Aug 2019 08:
|
3
|
-
lib/phone_number_validator.rb
|
4
|
-
lib/phone_number_validator/validator.rb
|
5
|
-
test/test_phone_number_validator.rb
|
6
|
-
bin/pnv
|
1
|
+
Wed, 07 Aug 2019 08:34:48 -0700
|
2
|
+
README.rdoc Wed, 07 Aug 2019 08:29:12 -0700
|
3
|
+
lib/phone_number_validator.rb Tue, 27 Nov 2018 09:42:11 -0800
|
4
|
+
lib/phone_number_validator/validator.rb Thu, 11 Jul 2019 08:46:02 -0700
|
5
|
+
test/test_phone_number_validator.rb Thu, 11 Jul 2019 08:46:25 -0700
|
6
|
+
bin/pnv Wed, 07 Aug 2019 08:29:12 -0700
|
data/doc/css/fonts.css
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
font-weight: 400;
|
18
18
|
src: local("Source Code Pro"),
|
19
19
|
local("SourceCodePro-Regular"),
|
20
|
-
url("
|
20
|
+
url("fonts/SourceCodePro-Regular.ttf") format("truetype");
|
21
21
|
}
|
22
22
|
|
23
23
|
@font-face {
|
@@ -26,7 +26,7 @@
|
|
26
26
|
font-weight: 700;
|
27
27
|
src: local("Source Code Pro Bold"),
|
28
28
|
local("SourceCodePro-Bold"),
|
29
|
-
url("
|
29
|
+
url("fonts/SourceCodePro-Bold.ttf") format("truetype");
|
30
30
|
}
|
31
31
|
|
32
32
|
/*
|
@@ -46,7 +46,7 @@
|
|
46
46
|
font-weight: 300;
|
47
47
|
src: local("Lato Light"),
|
48
48
|
local("Lato-Light"),
|
49
|
-
url("
|
49
|
+
url("fonts/Lato-Light.ttf") format("truetype");
|
50
50
|
}
|
51
51
|
|
52
52
|
@font-face {
|
@@ -55,7 +55,7 @@
|
|
55
55
|
font-weight: 300;
|
56
56
|
src: local("Lato Light Italic"),
|
57
57
|
local("Lato-LightItalic"),
|
58
|
-
url("
|
58
|
+
url("fonts/Lato-LightItalic.ttf") format("truetype");
|
59
59
|
}
|
60
60
|
|
61
61
|
@font-face {
|
@@ -64,7 +64,7 @@
|
|
64
64
|
font-weight: 700;
|
65
65
|
src: local("Lato Regular"),
|
66
66
|
local("Lato-Regular"),
|
67
|
-
url("
|
67
|
+
url("fonts/Lato-Regular.ttf") format("truetype");
|
68
68
|
}
|
69
69
|
|
70
70
|
@font-face {
|
@@ -73,7 +73,7 @@
|
|
73
73
|
font-weight: 700;
|
74
74
|
src: local("Lato Italic"),
|
75
75
|
local("Lato-Italic"),
|
76
|
-
url("
|
76
|
+
url("fonts/Lato-RegularItalic.ttf") format("truetype");
|
77
77
|
}
|
78
78
|
|
79
79
|
/*
|
data/doc/index.html
CHANGED
@@ -1,165 +1,164 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>Phone Number Validator</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "./";
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<script src="./js/
|
15
|
-
|
16
|
-
|
17
|
-
<link href="./css/
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
<
|
24
|
-
<
|
25
|
-
<
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<a href="./table_of_contents.html#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
<div id="search-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
</div>
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<
|
57
|
-
|
58
|
-
<
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
<
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
<li><a href="./PhoneNumberValidator.html">PhoneNumberValidator</a>
|
73
|
-
|
74
|
-
<li><a href="./
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
</div>
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<
|
88
|
-
|
89
|
-
<
|
90
|
-
|
91
|
-
<p>
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
<
|
100
|
-
<span class="ruby-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
<
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
<
|
161
|
-
<p
|
162
|
-
<p>
|
163
|
-
|
164
|
-
|
165
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>Phone Number Validator</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<script src="./js/jquery.js"></script>
|
14
|
+
<script src="./js/darkfish.js"></script>
|
15
|
+
|
16
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
<body id="top" role="document" class="file">
|
22
|
+
<nav role="navigation">
|
23
|
+
<div id="project-navigation">
|
24
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
25
|
+
<h2>
|
26
|
+
<a href="./index.html" rel="home">Home</a>
|
27
|
+
</h2>
|
28
|
+
|
29
|
+
<div id="table-of-contents-navigation">
|
30
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
31
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
32
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
|
37
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
+
<form action="#" method="get" accept-charset="utf-8">
|
39
|
+
<div id="search-field-wrapper">
|
40
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
+
aria-autocomplete="list" aria-controls="search-results"
|
42
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<ul id="search-results" aria-label="Search Results"
|
47
|
+
aria-busy="false" aria-expanded="false"
|
48
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
+
</form>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<div id="project-metadata">
|
55
|
+
<div id="fileindex-section" class="nav-section">
|
56
|
+
<h3>Pages</h3>
|
57
|
+
|
58
|
+
<ul class="link-list">
|
59
|
+
|
60
|
+
<li><a href="./README_rdoc.html">README</a>
|
61
|
+
|
62
|
+
</ul>
|
63
|
+
</div>
|
64
|
+
|
65
|
+
<div id="classindex-section" class="nav-section">
|
66
|
+
<h3>Class and Module Index</h3>
|
67
|
+
|
68
|
+
<ul class="link-list">
|
69
|
+
|
70
|
+
<li><a href="./PhoneNumberValidator.html">PhoneNumberValidator</a>
|
71
|
+
|
72
|
+
<li><a href="./PhoneNumberValidator/Validator.html">PhoneNumberValidator::Validator</a>
|
73
|
+
|
74
|
+
<li><a href="./PhoneNumberValidatorTest.html">PhoneNumberValidatorTest</a>
|
75
|
+
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
<main role="main">
|
83
|
+
|
84
|
+
|
85
|
+
<h1 id="label-Phone+Number+Validator">Phone Number Validator<span><a href="#label-Phone+Number+Validator">¶</a> <a href="#top">↑</a></span></h1>
|
86
|
+
|
87
|
+
<h2 id="label-About">About<span><a href="#label-About">¶</a> <a href="#top">↑</a></span></h2>
|
88
|
+
|
89
|
+
<p>This app is a US phone number-validating RubyGem.</p>
|
90
|
+
|
91
|
+
<p>It uses a complex regular expression to validate any United States phone
|
92
|
+
number.</p>
|
93
|
+
|
94
|
+
<h3 id="label-Regular+Expression">Regular Expression<span><a href="#label-Regular+Expression">¶</a> <a href="#top">↑</a></span></h3>
|
95
|
+
|
96
|
+
<p>This gem uses the following regular expression:</p>
|
97
|
+
|
98
|
+
<pre class="ruby"><span class="ruby-comment"># US Phone Numbers</span>
|
99
|
+
<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>
|
100
|
+
<span class="ruby-comment"># Regex Flags: i (ignore case)</span>
|
101
|
+
</pre>
|
102
|
+
|
103
|
+
<h2 id="label-Installing">Installing<span><a href="#label-Installing">¶</a> <a href="#top">↑</a></span></h2>
|
104
|
+
|
105
|
+
<pre>$ gem install phone_number_validator</pre>
|
106
|
+
|
107
|
+
<h3 id="label-Install+Required+Gems-2FDependencies">Install Required Gems/Dependencies<span><a href="#label-Install+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
108
|
+
|
109
|
+
<pre>$ bundle install</pre>
|
110
|
+
|
111
|
+
<h3 id="label-Updating+Required+Gems-2FDependencies">Updating Required Gems/Dependencies<span><a href="#label-Updating+Required+Gems-2FDependencies">¶</a> <a href="#top">↑</a></span></h3>
|
112
|
+
|
113
|
+
<pre>$ bundle update</pre>
|
114
|
+
|
115
|
+
<h2 id="label-Uninstalling">Uninstalling<span><a href="#label-Uninstalling">¶</a> <a href="#top">↑</a></span></h2>
|
116
|
+
|
117
|
+
<pre>$ gem uninstall phone_number_validator</pre>
|
118
|
+
|
119
|
+
<h2 id="label-Testing">Testing<span><a href="#label-Testing">¶</a> <a href="#top">↑</a></span></h2>
|
120
|
+
|
121
|
+
<pre>$ rake test</pre>
|
122
|
+
|
123
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
124
|
+
|
125
|
+
<h3 id="label-In+command+line">In command line<span><a href="#label-In+command+line">¶</a> <a href="#top">↑</a></span></h3>
|
126
|
+
|
127
|
+
<pre>$ pnv "+1 (987) 654-3210 ext. 198842"</pre>
|
128
|
+
|
129
|
+
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
130
|
+
|
131
|
+
<pre>=> true</pre>
|
132
|
+
|
133
|
+
<h3 id="label-In+Ruby+code">In Ruby code<span><a href="#label-In+Ruby+code">¶</a> <a href="#top">↑</a></span></h3>
|
134
|
+
|
135
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'phone_number_validator'</span>
|
136
|
+
|
137
|
+
<span class="ruby-identifier">check_phone_number</span> = <span class="ruby-constant">PhoneNumberValidator</span>.<span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-string">'+1 (987) 654-3210 ext. 198842'</span>)
|
138
|
+
|
139
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">check_phone_number</span>
|
140
|
+
</pre>
|
141
|
+
|
142
|
+
<h4 id="label-Output">Output<span><a href="#label-Output">¶</a> <a href="#top">↑</a></span></h4>
|
143
|
+
|
144
|
+
<pre>=> true</pre>
|
145
|
+
|
146
|
+
<p>Output can be <strong>true</strong> (<em>boolean, valid phone number</em>),
|
147
|
+
<strong>false</strong> (<em>boolean, invalid phone number</em>), or
|
148
|
+
<strong>nil</strong> (<em>symbol, no phone number entered</em>).</p>
|
149
|
+
|
150
|
+
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
151
|
+
|
152
|
+
<p>Run the following to make <code>bin/pnv</code> executable (Unix only):</p>
|
153
|
+
|
154
|
+
<pre>chmod ugo+x bin/pnv</pre>
|
155
|
+
</main>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<footer id="validator-badges" role="contentinfo">
|
160
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
161
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.1.
|
162
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
163
|
+
</footer>
|
164
|
+
|