env_parser 1.0.0 → 1.1.0

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
  SHA1:
3
- metadata.gz: 71db2fdf0d882840050bc0718e4695f3eeedfef4
4
- data.tar.gz: e25fb8e4e50bc32c16f7479a26ca125818f35dc4
3
+ metadata.gz: a9267e9a3c9e84f53fe028aa4eaecefd43559b67
4
+ data.tar.gz: efb184bc36af4c482ee88d721d5dc281b0e20ad3
5
5
  SHA512:
6
- metadata.gz: c27c985ef686b9c658648e833ee0cb1c65c191f38968ea3ad7114d2d4ed71ae737b4dd2cc951b168b7947ac61bbca4352585a503669934a075cbbf60ece9f0f7
7
- data.tar.gz: f450e32ad5fdcbd32da05eb8ac49c984df30515262d63511e59d5a5093fc8fd418106f71b9e7740c43aed24a51abc4f8464ab675acad7e493be3de5b033e0934
6
+ metadata.gz: 1158be532e36463128f3c97d78186d7b2d4601315e53cb9b2d2ce21fb779f617ec44cb34a375af9c95b31ee426a8ac3a8d8491cf44442b3fab42883d3e67662e
7
+ data.tar.gz: b59a03c76c0988f5545e88338de325e8d1eded9b9a87a691e28768b6c94e3ef9da5bbc906787eb045dbb9fde01535086a65ae3f0988a0af405eaa3e64fbfe802
data/.circleci/config.yml CHANGED
@@ -48,11 +48,12 @@ jobs:
48
48
  mkdir /tmp/test-results
49
49
  TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
50
50
 
51
- bundle exec rspec --format progress \
52
- --format RspecJunitFormatter \
53
- --out /tmp/test-results/rspec.xml \
54
- --format progress \
55
- "${TEST_FILES}"
51
+ bundle exec rspec --format progress \
52
+ --format RspecJunitFormatter \
53
+ --out /tmp/test-results/rspec.xml \
54
+ --format progress \
55
+ -- \
56
+ $TEST_FILES
56
57
 
57
58
  # collect reports
58
59
  - store_test_results:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- env_parser (1.0.0)
4
+ env_parser (1.1.0)
5
5
  activesupport (>= 5.0.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -209,8 +209,7 @@ b = EnvParser.parse :B, as: :my_special_type_of_number
209
209
 
210
210
  Additional features/options coming in the future:
211
211
 
212
- - Round out the "as" type selection with things like `:url`, `:email`, etc.
213
- - ... ?
212
+ - Continue to round out the "as" type selection as ideas come to mind, suggestions are made, and pull requests are submitted.
214
213
 
215
214
 
216
215
  ## Contribution / Development
data/docs/EnvParser.html CHANGED
@@ -130,7 +130,7 @@ different data types.</p>
130
130
  <dt id="VERSION-constant" class="">VERSION =
131
131
 
132
132
  </dt>
133
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.0.0</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
133
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.1.0</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
134
134
 
135
135
  </dl>
136
136
 
@@ -1075,7 +1075,7 @@ each value needing validation must give its own “validated_by” Proc.</p>
1075
1075
  </div>
1076
1076
 
1077
1077
  <div id="footer">
1078
- Generated on Mon Dec 25 19:13:02 2017 by
1078
+ Generated on Mon Dec 25 23:01:10 2017 by
1079
1079
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1080
1080
  0.9.11 (ruby-2.4.2).
1081
1081
  </div>
@@ -129,7 +129,7 @@
129
129
  </div>
130
130
 
131
131
  <div id="footer">
132
- Generated on Mon Dec 25 19:13:03 2017 by
132
+ Generated on Mon Dec 25 23:01:10 2017 by
133
133
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
134
134
  0.9.11 (ruby-2.4.2).
135
135
  </div>
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div id="footer">
136
- Generated on Mon Dec 25 19:13:03 2017 by
136
+ Generated on Mon Dec 25 23:01:10 2017 by
137
137
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
138
  0.9.11 (ruby-2.4.2).
139
139
  </div>
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div id="footer">
136
- Generated on Mon Dec 25 19:13:03 2017 by
136
+ Generated on Mon Dec 25 23:01:10 2017 by
137
137
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
138
  0.9.11 (ruby-2.4.2).
139
139
  </div>
@@ -135,7 +135,7 @@ by failing the “validated_by” Proc or yield-block check.</p>
135
135
  </div>
136
136
 
137
137
  <div id="footer">
138
- Generated on Mon Dec 25 19:13:03 2017 by
138
+ Generated on Mon Dec 25 23:01:10 2017 by
139
139
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
140
140
  0.9.11 (ruby-2.4.2).
141
141
  </div>
@@ -134,7 +134,7 @@ requested type.</p>
134
134
  </div>
135
135
 
136
136
  <div id="footer">
137
- Generated on Mon Dec 25 19:13:03 2017 by
137
+ Generated on Mon Dec 25 23:01:10 2017 by
138
138
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
139
139
  0.9.11 (ruby-2.4.2).
140
140
  </div>
@@ -78,7 +78,9 @@
78
78
 
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
- <dd>lib/env_parser/types/base_types.rb</dd>
81
+ <dd>lib/env_parser/types/internet.rb<span class="defines">,<br />
82
+ lib/env_parser/types/base_types.rb</span>
83
+ </dd>
82
84
  </dl>
83
85
 
84
86
  </div>
@@ -99,7 +101,7 @@ for documentation&#39;s sake.</p>
99
101
  <p class="children">
100
102
 
101
103
 
102
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="EnvParserTypes/BaseTypes.html" title="EnvParserTypes::BaseTypes (module)">BaseTypes</a></span>
104
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="EnvParserTypes/BaseTypes.html" title="EnvParserTypes::BaseTypes (module)">BaseTypes</a></span>, <span class='object_link'><a href="EnvParserTypes/InternetTypes.html" title="EnvParserTypes::InternetTypes (module)">InternetTypes</a></span>
103
105
 
104
106
 
105
107
 
@@ -117,7 +119,7 @@ for documentation&#39;s sake.</p>
117
119
  </div>
118
120
 
119
121
  <div id="footer">
120
- Generated on Mon Dec 25 19:13:02 2017 by
122
+ Generated on Mon Dec 25 23:01:09 2017 by
121
123
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
124
  0.9.11 (ruby-2.4.2).
123
125
  </div>
@@ -92,40 +92,58 @@
92
92
  <tr>
93
93
  <th><code>:as</code> value</th>
94
94
  <th>type returned</th>
95
+ <th>default</th>
96
+ <th>notes</th>
95
97
  </tr>
96
98
  </tbody>
97
99
  <tbody>
98
100
  <tr>
99
101
  <td>:string</td>
100
102
  <td>String</td>
103
+ <td><code>''</code></td>
104
+ <td></td>
101
105
  </tr>
102
106
  <tr>
103
107
  <td>:symbol</td>
104
108
  <td>Symbol</td>
109
+ <td><code>:''</code></td>
110
+ <td></td>
105
111
  </tr>
106
112
  <tr>
107
113
  <td>:boolean</td>
108
114
  <td>TrueValue / FalseValue</td>
115
+ <td><code>false</code></td>
116
+ <td></td>
109
117
  </tr>
110
118
  <tr>
111
119
  <td>:int / :integer</td>
112
120
  <td>Integer</td>
121
+ <td><code>0</code></td>
122
+ <td></td>
113
123
  </tr>
114
124
  <tr>
115
125
  <td>:float / :decimal / :number</td>
116
126
  <td>Float</td>
127
+ <td><code>0.0</code></td>
128
+ <td></td>
117
129
  </tr>
118
130
  <tr>
119
131
  <td>:json</td>
120
132
  <td>&lt; depends on JSON given &gt;</td>
133
+ <td><code>nil</code></td>
134
+ <td></td>
121
135
  </tr>
122
136
  <tr>
123
137
  <td>:array</td>
124
138
  <td>Array</td>
139
+ <td><code>[]</code></td>
140
+ <td></td>
125
141
  </tr>
126
142
  <tr>
127
143
  <td>:hash</td>
128
144
  <td>Hash</td>
145
+ <td><code>{}</code></td>
146
+ <td></td>
129
147
  </tr>
130
148
  </tbody>
131
149
  </table>
@@ -150,7 +168,7 @@
150
168
  </div>
151
169
 
152
170
  <div id="footer">
153
- Generated on Mon Dec 25 19:13:02 2017 by
171
+ Generated on Mon Dec 25 23:01:09 2017 by
154
172
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
155
173
  0.9.11 (ruby-2.4.2).
156
174
  </div>
@@ -0,0 +1,159 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: EnvParserTypes::InternetTypes
8
+
9
+ &mdash; Documentation by YARD 0.9.11
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "EnvParserTypes::InternetTypes";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (I)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../EnvParserTypes.html" title="EnvParserTypes (module)">EnvParserTypes</a></span></span>
41
+ &raquo;
42
+ <span class="title">InternetTypes</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: EnvParserTypes::InternetTypes
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/env_parser/types/internet.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Overview</h2><div class="docstring">
87
+ <div class="discussion">
88
+
89
+ <p>Defines types for internet-related values, adding the following:</p>
90
+ <table>
91
+ <tbody>
92
+ <tr>
93
+ <th><code>:as</code> value</th>
94
+ <th>type returned</th>
95
+ <th>default</th>
96
+ <th>notes</th>
97
+ </tr>
98
+ </tbody>
99
+ <tbody>
100
+ <tr>
101
+ <td>:ipv4_address</td>
102
+ <td>String</td>
103
+ <td><code>nil</code></td>
104
+ <td>
105
+ An IPv4 address in 4-octet dot-decimal notation,
106
+ <br />
107
+ with no CIDR or subnet suffix (e.g. <code>'192.168.0.1'</code>).
108
+ </td>
109
+ </tr>
110
+ <tr>
111
+ <td>:ipv6_address</td>
112
+ <td>String</td>
113
+ <td><code>nil</code></td>
114
+ <td>An IPv6 address, in RFC5952 format.</td>
115
+ </tr>
116
+ <tr>
117
+ <td>:network_port / :port</td>
118
+ <td>Integer</td>
119
+ <td><code>nil</code></td>
120
+ <td></td>
121
+ </tr>
122
+ <tr>
123
+ <td>:email_address</td>
124
+ <td>String</td>
125
+ <td><code>nil</code></td>
126
+ <td>
127
+ A "simple" email address, containing only a username and a domain.
128
+ <br />
129
+ Note this does not guarantee RFC5322-conformity.
130
+ </td>
131
+ </tr>
132
+ </tbody>
133
+ </table>
134
+
135
+ </div>
136
+ </div>
137
+ <div class="tags">
138
+
139
+
140
+ </div>
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ </div>
150
+
151
+ <div id="footer">
152
+ Generated on Mon Dec 25 23:01:09 2017 by
153
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
154
+ 0.9.11 (ruby-2.4.2).
155
+ </div>
156
+
157
+ </div>
158
+ </body>
159
+ </html>
data/docs/_index.html CHANGED
@@ -118,6 +118,21 @@
118
118
  </ul>
119
119
 
120
120
 
121
+ <ul id="alpha_I" class="alpha">
122
+ <li class="letter">I</li>
123
+ <ul>
124
+
125
+ <li>
126
+ <span class='object_link'><a href="EnvParserTypes/InternetTypes.html" title="EnvParserTypes::InternetTypes (module)">InternetTypes</a></span>
127
+
128
+ <small>(EnvParserTypes)</small>
129
+
130
+ </li>
131
+
132
+ </ul>
133
+ </ul>
134
+
135
+
121
136
  <ul id="alpha_T" class="alpha">
122
137
  <li class="letter">T</li>
123
138
  <ul>
@@ -178,7 +193,7 @@
178
193
  </div>
179
194
 
180
195
  <div id="footer">
181
- Generated on Mon Dec 25 19:13:01 2017 by
196
+ Generated on Mon Dec 25 23:01:09 2017 by
182
197
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
183
198
  0.9.11 (ruby-2.4.2).
184
199
  </div>
data/docs/class_list.html CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
  <ul id="full_list" class="class">
45
45
  <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
46
- <li id='object_EnvParser' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="EnvParser.html" title="EnvParser (class)">EnvParser</a></span> &lt; Object<small class='search_info'>Top Level Namespace</small></div><ul><li id='object_EnvParser::Error' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/Error.html" title="EnvParser::Error (class)">Error</a></span> &lt; StandardError<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::TypeAlreadyDefinedError' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/TypeAlreadyDefinedError.html" title="EnvParser::TypeAlreadyDefinedError (class)">TypeAlreadyDefinedError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::UnknownTypeError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/UnknownTypeError.html" title="EnvParser::UnknownTypeError (class)">UnknownTypeError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::ValueNotAllowedError' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/ValueNotAllowedError.html" title="EnvParser::ValueNotAllowedError (class)">ValueNotAllowedError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::ValueNotConvertibleError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/ValueNotConvertibleError.html" title="EnvParser::ValueNotConvertibleError (class)">ValueNotConvertibleError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li></ul></li><li id='object_EnvParserTypes' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="EnvParserTypes.html" title="EnvParserTypes (module)">EnvParserTypes</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_EnvParserTypes::BaseTypes' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParserTypes/BaseTypes.html" title="EnvParserTypes::BaseTypes (module)">BaseTypes</a></span><small class='search_info'>EnvParserTypes</small></div></li></ul></li>
46
+ <li id='object_EnvParser' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="EnvParser.html" title="EnvParser (class)">EnvParser</a></span> &lt; Object<small class='search_info'>Top Level Namespace</small></div><ul><li id='object_EnvParser::Error' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/Error.html" title="EnvParser::Error (class)">Error</a></span> &lt; StandardError<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::TypeAlreadyDefinedError' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/TypeAlreadyDefinedError.html" title="EnvParser::TypeAlreadyDefinedError (class)">TypeAlreadyDefinedError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::UnknownTypeError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/UnknownTypeError.html" title="EnvParser::UnknownTypeError (class)">UnknownTypeError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::ValueNotAllowedError' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/ValueNotAllowedError.html" title="EnvParser::ValueNotAllowedError (class)">ValueNotAllowedError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li><li id='object_EnvParser::ValueNotConvertibleError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParser/ValueNotConvertibleError.html" title="EnvParser::ValueNotConvertibleError (class)">ValueNotConvertibleError</a></span> &lt; Error<small class='search_info'>EnvParser</small></div></li></ul></li><li id='object_EnvParserTypes' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="EnvParserTypes.html" title="EnvParserTypes (module)">EnvParserTypes</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_EnvParserTypes::BaseTypes' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParserTypes/BaseTypes.html" title="EnvParserTypes::BaseTypes (module)">BaseTypes</a></span><small class='search_info'>EnvParserTypes</small></div></li><li id='object_EnvParserTypes::InternetTypes' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="EnvParserTypes/InternetTypes.html" title="EnvParserTypes::InternetTypes (module)">InternetTypes</a></span><small class='search_info'>EnvParserTypes</small></div></li></ul></li>
47
47
 
48
48
  </ul>
49
49
  </div>
@@ -270,10 +270,8 @@ the repo docs for the full EnvParser documentation.</a></p>
270
270
 
271
271
  <p>Additional features/options coming in the future:</p>
272
272
  <ul><li>
273
- <p>Round out the “as” type selection with things like <code>:url</code>,
274
- <code>:email</code>, etc.</p>
275
- </li><li>
276
- <p>… ?</p>
273
+ <p>Continue to round out the “as” type selection as ideas come to mind,
274
+ suggestions are made, and pull requests are submitted.</p>
277
275
  </li></ul>
278
276
 
279
277
  <h2 id="label-Contribution+-2F+Development">Contribution / Development</h2>
@@ -298,7 +296,7 @@ href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
298
296
  </div></div>
299
297
 
300
298
  <div id="footer">
301
- Generated on Mon Dec 25 19:13:02 2017 by
299
+ Generated on Mon Dec 25 23:01:09 2017 by
302
300
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
303
301
  0.9.11 (ruby-2.4.2).
304
302
  </div>
data/docs/index.html CHANGED
@@ -270,10 +270,8 @@ the repo docs for the full EnvParser documentation.</a></p>
270
270
 
271
271
  <p>Additional features/options coming in the future:</p>
272
272
  <ul><li>
273
- <p>Round out the “as” type selection with things like <code>:url</code>,
274
- <code>:email</code>, etc.</p>
275
- </li><li>
276
- <p>… ?</p>
273
+ <p>Continue to round out the “as” type selection as ideas come to mind,
274
+ suggestions are made, and pull requests are submitted.</p>
277
275
  </li></ul>
278
276
 
279
277
  <h2 id="label-Contribution+-2F+Development">Contribution / Development</h2>
@@ -298,7 +296,7 @@ href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
298
296
  </div></div>
299
297
 
300
298
  <div id="footer">
301
- Generated on Mon Dec 25 19:13:02 2017 by
299
+ Generated on Mon Dec 25 23:01:09 2017 by
302
300
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
303
301
  0.9.11 (ruby-2.4.2).
304
302
  </div>
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Mon Dec 25 19:13:02 2017 by
183
+ Generated on Mon Dec 25 23:01:09 2017 by
184
184
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
185
  0.9.11 (ruby-2.4.2).
186
186
  </div>
@@ -11,40 +11,58 @@ module EnvParserTypes
11
11
  ## <tr>
12
12
  ## <th><code>:as</code> value</th>
13
13
  ## <th>type returned</th>
14
+ ## <th>default</th>
15
+ ## <th>notes</th>
14
16
  ## </tr>
15
17
  ## </tbody>
16
18
  ## <tbody>
17
19
  ## <tr>
18
20
  ## <td>:string</td>
19
21
  ## <td>String</td>
22
+ ## <td><code>''</code></td>
23
+ ## <td></td>
20
24
  ## </tr>
21
25
  ## <tr>
22
26
  ## <td>:symbol</td>
23
27
  ## <td>Symbol</td>
28
+ ## <td><code>:''</code></td>
29
+ ## <td></td>
24
30
  ## </tr>
25
31
  ## <tr>
26
32
  ## <td>:boolean</td>
27
33
  ## <td>TrueValue / FalseValue</td>
34
+ ## <td><code>false</code></td>
35
+ ## <td></td>
28
36
  ## </tr>
29
37
  ## <tr>
30
38
  ## <td>:int / :integer</td>
31
39
  ## <td>Integer</td>
40
+ ## <td><code>0</code></td>
41
+ ## <td></td>
32
42
  ## </tr>
33
43
  ## <tr>
34
44
  ## <td>:float / :decimal / :number</td>
35
45
  ## <td>Float</td>
46
+ ## <td><code>0.0</code></td>
47
+ ## <td></td>
36
48
  ## </tr>
37
49
  ## <tr>
38
50
  ## <td>:json</td>
39
51
  ## <td>&lt; depends on JSON given &gt;</td>
52
+ ## <td><code>nil</code></td>
53
+ ## <td></td>
40
54
  ## </tr>
41
55
  ## <tr>
42
56
  ## <td>:array</td>
43
57
  ## <td>Array</td>
58
+ ## <td><code>[]</code></td>
59
+ ## <td></td>
44
60
  ## </tr>
45
61
  ## <tr>
46
62
  ## <td>:hash</td>
47
63
  ## <td>Hash</td>
64
+ ## <td><code>{}</code></td>
65
+ ## <td></td>
48
66
  ## </tr>
49
67
  ## </tbody>
50
68
  ## </table>
@@ -0,0 +1,99 @@
1
+ require 'env_parser'
2
+
3
+ ## The parent module for all EnvParser type definition modules.
4
+ ## Exists only for documentation's sake.
5
+ ##
6
+ module EnvParserTypes
7
+ ## Defines types for internet-related values, adding the following:
8
+ ##
9
+ ## <table>
10
+ ## <tbody>
11
+ ## <tr>
12
+ ## <th><code>:as</code> value</th>
13
+ ## <th>type returned</th>
14
+ ## <th>default</th>
15
+ ## <th>notes</th>
16
+ ## </tr>
17
+ ## </tbody>
18
+ ## <tbody>
19
+ ## <tr>
20
+ ## <td>:ipv4_address</td>
21
+ ## <td>String</td>
22
+ ## <td><code>nil</code></td>
23
+ ## <td>
24
+ ## An IPv4 address in 4-octet dot-decimal notation,
25
+ ## <br />
26
+ ## with no CIDR or subnet suffix (e.g. <code>'192.168.0.1'</code>).
27
+ ## </td>
28
+ ## </tr>
29
+ ## <tr>
30
+ ## <td>:ipv6_address</td>
31
+ ## <td>String</td>
32
+ ## <td><code>nil</code></td>
33
+ ## <td>An IPv6 address, in RFC5952 format.</td>
34
+ ## </tr>
35
+ ## <tr>
36
+ ## <td>:network_port / :port</td>
37
+ ## <td>Integer</td>
38
+ ## <td><code>nil</code></td>
39
+ ## <td></td>
40
+ ## </tr>
41
+ ## <tr>
42
+ ## <td>:email_address</td>
43
+ ## <td>String</td>
44
+ ## <td><code>nil</code></td>
45
+ ## <td>
46
+ ## A "simple" email address, containing only a username and a domain.
47
+ ## <br />
48
+ ## Note this does not guarantee RFC5322-conformity.
49
+ ## </td>
50
+ ## </tr>
51
+ ## </tbody>
52
+ ## </table>
53
+ ##
54
+ module InternetTypes
55
+ EnvParser.define_type(:ipv4_address, if_unset: nil) do |value|
56
+ begin
57
+ require 'socket'
58
+ address = Addrinfo.getaddrinfo(value, nil, Socket::AF_INET, nil, Socket::IPPROTO_TCP).first
59
+ raise StandardError unless address.ipv4?
60
+ rescue StandardError
61
+ raise EnvParser::ValueNotConvertibleError, 'non-ip value'
62
+ end
63
+
64
+ address.ip_address
65
+ end
66
+
67
+ EnvParser.define_type(:ipv6_address, if_unset: nil) do |value|
68
+ begin
69
+ require 'socket'
70
+ address = Addrinfo.getaddrinfo(value, nil, Socket::AF_INET6, nil, Socket::IPPROTO_TCP).first
71
+ raise StandardError unless address.ipv6?
72
+ rescue StandardError
73
+ raise EnvParser::ValueNotConvertibleError, 'non-ip value'
74
+ end
75
+
76
+ address.ip_address
77
+ end
78
+
79
+ EnvParser.define_type(:network_port, aliases: :port, if_unset: nil) do |value|
80
+ begin
81
+ Integer(value)
82
+ rescue
83
+ raise(EnvParser::ValueNotConvertibleError, 'non-numeric value')
84
+ end
85
+
86
+ value = value.to_i
87
+ raise(EnvParser::ValueNotAllowedError, 'value out of range') unless (0..65535).cover?(value)
88
+
89
+ value
90
+ end
91
+
92
+ EnvParser.define_type(:email_address, if_unset: nil) do |value|
93
+ simple_email = %r[^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$]i
94
+ raise(EnvParser::ValueNotConvertibleError, 'not an email') unless value.match?(simple_email)
95
+
96
+ value
97
+ end
98
+ end
99
+ end
@@ -1,3 +1,3 @@
1
1
  class EnvParser
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: env_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nestor Custodio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2017-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,6 +111,7 @@ files:
111
111
  - docs/EnvParser/ValueNotConvertibleError.html
112
112
  - docs/EnvParserTypes.html
113
113
  - docs/EnvParserTypes/BaseTypes.html
114
+ - docs/EnvParserTypes/InternetTypes.html
114
115
  - docs/_index.html
115
116
  - docs/class_list.html
116
117
  - docs/css/common.css
@@ -130,6 +131,7 @@ files:
130
131
  - lib/env_parser/errors.rb
131
132
  - lib/env_parser/types.rb
132
133
  - lib/env_parser/types/base_types.rb
134
+ - lib/env_parser/types/internet.rb
133
135
  - lib/env_parser/version.rb
134
136
  homepage: https://github.com/nestor-custodio/env_parser
135
137
  licenses: