env_parser 1.3.0 → 1.3.2

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.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +1 -1
  3. data/.rubocop.yml +25 -30
  4. data/.ruby-version +1 -1
  5. data/Gemfile.lock +51 -43
  6. data/README.md +1 -1
  7. data/docs/EnvParser/AutoregisterFileNotFound.html +9 -10
  8. data/docs/EnvParser/Error.html +8 -9
  9. data/docs/EnvParser/TypeAlreadyDefinedError.html +8 -9
  10. data/docs/EnvParser/Types/BaseTypes.html +12 -11
  11. data/docs/EnvParser/Types/ChronologyTypes.html +10 -9
  12. data/docs/EnvParser/Types/InternetTypes.html +10 -9
  13. data/docs/EnvParser/Types.html +9 -10
  14. data/docs/EnvParser/UnknownTypeError.html +8 -9
  15. data/docs/EnvParser/UnparseableAutoregisterSpec.html +9 -10
  16. data/docs/EnvParser/ValueNotAllowedError.html +10 -11
  17. data/docs/EnvParser/ValueNotConvertibleError.html +8 -10
  18. data/docs/EnvParser.html +123 -186
  19. data/docs/_index.html +8 -10
  20. data/docs/class_list.html +2 -2
  21. data/docs/css/style.css +3 -2
  22. data/docs/file.README.html +254 -284
  23. data/docs/file_list.html +2 -2
  24. data/docs/frames.html +2 -2
  25. data/docs/index.html +254 -284
  26. data/docs/js/app.js +14 -3
  27. data/docs/method_list.html +3 -11
  28. data/docs/top-level-namespace.html +7 -85
  29. data/env_parser.gemspec +14 -14
  30. data/lib/env_parser/errors.rb +18 -18
  31. data/lib/env_parser/types/base_types.rb +69 -69
  32. data/lib/env_parser/types/chronology_types.rb +54 -54
  33. data/lib/env_parser/types/internet_types.rb +51 -51
  34. data/lib/env_parser/types.rb +2 -2
  35. data/lib/env_parser/version.rb +1 -1
  36. data/lib/env_parser.rb +206 -217
  37. data/spec/env_parser/types/base_types_spec.rb +98 -0
  38. data/spec/env_parser/types/chronology_types_spec.rb +49 -0
  39. data/spec/env_parser/types/internet_types_spec.rb +45 -0
  40. data/spec/env_parser_spec.rb +192 -0
  41. data/spec/spec_helper.rb +14 -0
  42. metadata +54 -50
  43. data/.travis.yml +0 -5
data/docs/js/app.js CHANGED
@@ -171,6 +171,7 @@ function generateTOC() {
171
171
  var counter = 0;
172
172
  var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
173
173
  var i;
174
+ var curli;
174
175
  if ($('#filecontents h1').length > 1) tags.unshift('h1');
175
176
  for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
176
177
  var lastTag = parseInt(tags[0][1], 10);
@@ -190,15 +191,25 @@ function generateTOC() {
190
191
  }
191
192
  if (thisTag > lastTag) {
192
193
  for (i = 0; i < thisTag - lastTag; i++) {
193
- var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
194
+ if ( typeof(curli) == "undefined" ) {
195
+ curli = $('<li/>');
196
+ toc.append(curli);
197
+ }
198
+ toc = $('<ol/>');
199
+ curli.append(toc);
200
+ curli = undefined;
194
201
  }
195
202
  }
196
203
  if (thisTag < lastTag) {
197
- for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
204
+ for (i = 0; i < lastTag - thisTag; i++) {
205
+ toc = toc.parent();
206
+ toc = toc.parent();
207
+ }
198
208
  }
199
209
  var title = $(this).attr('toc-title');
200
210
  if (typeof(title) == "undefined") title = $(this).text();
201
- toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
211
+ curli =$('<li><a href="#' + this.id + '">' + title + '</a></li>');
212
+ toc.append(curli);
202
213
  lastTag = thisTag;
203
214
  });
204
215
  if (!show) return;
@@ -4,9 +4,9 @@
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
5
  <meta charset="utf-8" />
6
6
 
7
- <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
8
 
9
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
10
 
11
11
 
12
12
 
@@ -69,14 +69,6 @@
69
69
 
70
70
 
71
71
  <li class="even ">
72
- <div class="item">
73
- <span class='object_link'><a href="top-level-namespace.html#filename-instance_method" title="#filename (method)">#filename</a></span>
74
- <small>Top Level Namespace</small>
75
- </div>
76
- </li>
77
-
78
-
79
- <li class="odd ">
80
72
  <div class="item">
81
73
  <span class='object_link'><a href="EnvParser.html#parse-class_method" title="EnvParser.parse (method)">parse</a></span>
82
74
  <small>EnvParser</small>
@@ -84,7 +76,7 @@
84
76
  </li>
85
77
 
86
78
 
87
- <li class="even ">
79
+ <li class="odd ">
88
80
  <div class="item">
89
81
  <span class='object_link'><a href="EnvParser.html#register-class_method" title="EnvParser.register (method)">register</a></span>
90
82
  <small>EnvParser</small>
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.9.20
9
+ &mdash; Documentation by YARD 0.9.28
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "";
19
19
  relpath = '';
20
20
  </script>
@@ -95,92 +95,14 @@
95
95
 
96
96
 
97
97
 
98
-
99
- <h2>
100
- Instance Method Summary
101
- <small><a href="#" class="summary_toggle">collapse</a></small>
102
- </h2>
103
-
104
- <ul class="summary">
105
-
106
- <li class="public ">
107
- <span class="summary_signature">
108
-
109
- <a href="top-level-namespace.html#filename-instance_method" title="#filename (instance method)">#<strong>filename</strong> &#x21d2; Object </a>
110
-
111
-
112
-
113
- </span>
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
- <span class="summary_desc"><div class='inline'>
124
- <p>Load all files listed in “/lib/env_parser/types”.</p>
125
- </div></span>
126
-
127
- </li>
128
-
129
-
130
- </ul>
131
-
132
-
133
-
134
98
 
135
- <div id="instance_method_details" class="method_details_list">
136
- <h2>Instance Method Details</h2>
137
-
138
-
139
- <div class="method_details first">
140
- <h3 class="signature first" id="filename-instance_method">
141
-
142
- #<strong>filename</strong> &#x21d2; <tt>Object</tt>
143
-
144
-
145
-
146
-
147
-
148
- </h3><div class="docstring">
149
- <div class="discussion">
150
-
151
- <p>Load all files listed in “/lib/env_parser/types”.</p>
152
-
153
-
154
- </div>
155
- </div>
156
- <div class="tags">
157
-
158
-
159
- </div><table class="source_code">
160
- <tr>
161
- <td>
162
- <pre class="lines">
163
-
164
-
165
- 3</pre>
166
- </td>
167
- <td>
168
- <pre class="code"><span class="info file"># File 'lib/env_parser/types.rb', line 3</span>
169
-
170
- <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_glob'>glob</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid___dir__'>__dir__</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>types</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>*.rb</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_filename'>filename</span><span class='op'>|</span> <span class='id identifier rubyid_require_relative'>require_relative</span> <span class='id identifier rubyid_filename'>filename</span> <span class='rbrace'>}</span></pre>
171
- </td>
172
- </tr>
173
- </table>
174
- </div>
175
-
176
- </div>
177
99
 
178
100
  </div>
179
101
 
180
102
  <div id="footer">
181
- Generated on Sun Nov 3 21:30:37 2019 by
182
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
183
- 0.9.20 (ruby-2.4.2).
103
+ Generated on Sun Dec 25 19:19:23 2022 by
104
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
+ 0.9.28 (ruby-3.0.4).
184
106
  </div>
185
107
 
186
108
  </div>
data/env_parser.gemspec CHANGED
@@ -1,9 +1,10 @@
1
-
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'env_parser/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
6
+ spec.required_ruby_version = '~> 3.0'
7
+
7
8
  spec.name = 'env_parser'
8
9
  spec.version = EnvParser::VERSION
9
10
  spec.authors = ['Nestor Custodio']
@@ -13,21 +14,20 @@ Gem::Specification.new do |spec|
13
14
  spec.homepage = 'https://github.com/nestor-custodio/env_parser'
14
15
  spec.license = 'MIT'
15
16
 
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
- spec.bindir = 'exe'
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |filename| filename.start_with? 'test/' }
18
+ spec.executables = []
21
19
  spec.require_paths = ['lib']
22
20
 
23
- spec.add_development_dependency 'bundler', '~> 1.16'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
- spec.add_development_dependency 'rspec', '~> 3.0'
26
- spec.add_development_dependency 'rspec_junit_formatter'
27
- spec.add_development_dependency 'rubocop'
28
- spec.add_development_dependency 'yard'
21
+ spec.metadata['rubygems_mfa_required'] = 'true'
29
22
 
30
- spec.add_dependency 'activesupport', '>= 5.0.0'
23
+ spec.add_dependency 'activesupport', '>= 6.1.0'
31
24
  spec.add_dependency 'chronic'
32
25
  spec.add_dependency 'chronic_duration'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 2'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec', '~> 3'
30
+ spec.add_development_dependency 'rspec_junit_formatter'
31
+ spec.add_development_dependency 'rubocop'
32
+ spec.add_development_dependency 'yard'
33
33
  end
@@ -1,40 +1,40 @@
1
1
  class EnvParser
2
- ## Base error class for EnvParser.
3
- ##
2
+ # Base error class for EnvParser.
3
+ #
4
4
  class Error < ::StandardError
5
5
  end
6
6
 
7
- ## Error class used to indicate a type has already been defined.
8
- ##
7
+ # Error class used to indicate a type has already been defined.
8
+ #
9
9
  class TypeAlreadyDefinedError < Error
10
10
  end
11
11
 
12
- ## Error class used to indicate the requested "as" type has not been defined.
13
- ##
12
+ # Error class used to indicate the requested "as" type has not been defined.
13
+ #
14
14
  class UnknownTypeError < Error
15
15
  end
16
16
 
17
- ## Error class used to indicate value given is not convertible to the requested type.
18
- ##
17
+ # Error class used to indicate value given is not convertible to the requested type.
18
+ #
19
19
  class ValueNotConvertibleError < Error
20
20
  end
21
21
 
22
- ## Error class used to indicate parsed values that do not pass user-validation, either by not
23
- ## being part of the given "from_set" list, or by failing the "validated_by" Proc or yield-block
24
- ## check.
25
- ##
22
+ # Error class used to indicate parsed values that do not pass user-validation, either by not
23
+ # being part of the given "from_set" list, or by failing the "validated_by" Proc or yield-block
24
+ # check.
25
+ #
26
26
  class ValueNotAllowedError < Error
27
27
  end
28
28
 
29
- ## Error class used to indicate a missing auto-registration spec file (used by the "autoregister"
30
- ## feature).
31
- ##
29
+ # Error class used to indicate a missing auto-registration spec file (used by the "autoregister"
30
+ # feature).
31
+ #
32
32
  class AutoregisterFileNotFound < Error
33
33
  end
34
34
 
35
- ## Error class used to indicate an unparseable auto-registration spec (used by the "autoregister"
36
- ## feature).
37
- ##
35
+ # Error class used to indicate an unparseable auto-registration spec (used by the "autoregister"
36
+ # feature).
37
+ #
38
38
  class UnparseableAutoregisterSpec < Error
39
39
  end
40
40
  end
@@ -1,75 +1,75 @@
1
1
  require 'env_parser'
2
2
 
3
- ## The parent module for all EnvParser type definition modules.
4
- ## Exists only for documentation's sake.
5
- ##
3
+ # The parent module for all EnvParser type definition modules.
4
+ # Exists only for documentation's sake.
5
+ #
6
6
  module EnvParser::Types
7
- ## Defines types for primitive classes, 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>:string</td>
21
- ## <td>String</td>
22
- ## <td><code>''</code></td>
23
- ## <td></td>
24
- ## </tr>
25
- ## <tr>
26
- ## <td>:symbol</td>
27
- ## <td>Symbol</td>
28
- ## <td><code>:''</code></td>
29
- ## <td></td>
30
- ## </tr>
31
- ## <tr>
32
- ## <td>:boolean</td>
33
- ## <td>TrueValue / FalseValue</td>
34
- ## <td><code>false</code></td>
35
- ## <td></td>
36
- ## </tr>
37
- ## <tr>
38
- ## <td>:int / :integer</td>
39
- ## <td>Integer</td>
40
- ## <td><code>0</code></td>
41
- ## <td></td>
42
- ## </tr>
43
- ## <tr>
44
- ## <td>:float / :decimal / :number</td>
45
- ## <td>Float</td>
46
- ## <td><code>0.0</code></td>
47
- ## <td></td>
48
- ## </tr>
49
- ## <tr>
50
- ## <td>:json</td>
51
- ## <td>&lt; depends on JSON given &gt;</td>
52
- ## <td><code>nil</code></td>
53
- ## <td></td>
54
- ## </tr>
55
- ## <tr>
56
- ## <td>:array</td>
57
- ## <td>Array</td>
58
- ## <td><code>[]</code></td>
59
- ## <td></td>
60
- ## </tr>
61
- ## <tr>
62
- ## <td>:hash</td>
63
- ## <td>Hash</td>
64
- ## <td><code>{}</code></td>
65
- ## <td></td>
66
- ## </tr>
67
- ## </tbody>
68
- ## </table>
69
- ##
70
- ## Note JSON is parsed using *quirks-mode* (meaning 'true', '25', and 'null' are all considered
71
- ## valid, parseable JSON).
72
- ##
7
+ # Defines types for primitive classes, 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>:string</td>
21
+ # <td>String</td>
22
+ # <td><code>''</code></td>
23
+ # <td></td>
24
+ # </tr>
25
+ # <tr>
26
+ # <td>:symbol</td>
27
+ # <td>Symbol</td>
28
+ # <td><code>:''</code></td>
29
+ # <td></td>
30
+ # </tr>
31
+ # <tr>
32
+ # <td>:boolean</td>
33
+ # <td>TrueValue / FalseValue</td>
34
+ # <td><code>false</code></td>
35
+ # <td></td>
36
+ # </tr>
37
+ # <tr>
38
+ # <td>:int / :integer</td>
39
+ # <td>Integer</td>
40
+ # <td><code>0</code></td>
41
+ # <td></td>
42
+ # </tr>
43
+ # <tr>
44
+ # <td>:float / :decimal / :number</td>
45
+ # <td>Float</td>
46
+ # <td><code>0.0</code></td>
47
+ # <td></td>
48
+ # </tr>
49
+ # <tr>
50
+ # <td>:json</td>
51
+ # <td>&lt; depends on JSON given &gt;</td>
52
+ # <td><code>nil</code></td>
53
+ # <td></td>
54
+ # </tr>
55
+ # <tr>
56
+ # <td>:array</td>
57
+ # <td>Array</td>
58
+ # <td><code>[]</code></td>
59
+ # <td></td>
60
+ # </tr>
61
+ # <tr>
62
+ # <td>:hash</td>
63
+ # <td>Hash</td>
64
+ # <td><code>{}</code></td>
65
+ # <td></td>
66
+ # </tr>
67
+ # </tbody>
68
+ # </table>
69
+ #
70
+ # Note JSON is parsed using *quirks-mode* (meaning 'true', '25', and 'null' are all considered
71
+ # valid, parseable JSON).
72
+ #
73
73
  module BaseTypes
74
74
  EnvParser.define_type(:string, if_unset: '') do |value|
75
75
  value
@@ -1,56 +1,56 @@
1
1
  require 'env_parser'
2
2
 
3
- ## The parent module for all EnvParser type definition modules.
4
- ## Exists only for documentation's sake.
5
- ##
3
+ # The parent module for all EnvParser type definition modules.
4
+ # Exists only for documentation's sake.
5
+ #
6
6
  module EnvParser::Types
7
- ## Defines types for date/time-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>:date</td>
21
- ## <td>Date</td>
22
- ## <td><code>nil</code></td>
23
- ## <td>
24
- ## A natural language or ISO8601-parseable date.
25
- ## <br />
26
- ## Actual interpretation of the value is handled by the *chronic* gem.
27
- ## </td>
28
- ## </tr>
29
- ## <tr>
30
- ## <td>:time / :datetime</td>
31
- ## <td>Time</td>
32
- ## <td><code>nil</code></td>
33
- ## <td>
34
- ## A natural language or ISO8601-parseable date and time.
35
- ## <br />
36
- ## Actual interpretation of the value is handled by the *chronic* gem.
37
- ## </td>
38
- ## </tr>
39
- ## <tr>
40
- ## <td>:duration</td>
41
- ## <td>Numeric</td>
42
- ## <td><code>nil</code></td>
43
- ## <td>
44
- ## A natural language or ISO8601-parseable period.
45
- ## <br />
46
- ## Value returned is the number of seconds in the given period.
47
- ## <br />
48
- ## Actual interpretation of the value is handled by the *chronic_duration* gem.
49
- ## </td>
50
- ## </tr>
51
- ## </tbody>
52
- ## </table>
53
- ##
7
+ # Defines types for date/time-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>:date</td>
21
+ # <td>Date</td>
22
+ # <td><code>nil</code></td>
23
+ # <td>
24
+ # A natural language or ISO8601-parseable date.
25
+ # <br />
26
+ # Actual interpretation of the value is handled by the *chronic* gem.
27
+ # </td>
28
+ # </tr>
29
+ # <tr>
30
+ # <td>:time / :datetime</td>
31
+ # <td>Time</td>
32
+ # <td><code>nil</code></td>
33
+ # <td>
34
+ # A natural language or ISO8601-parseable date and time.
35
+ # <br />
36
+ # Actual interpretation of the value is handled by the *chronic* gem.
37
+ # </td>
38
+ # </tr>
39
+ # <tr>
40
+ # <td>:duration</td>
41
+ # <td>Numeric</td>
42
+ # <td><code>nil</code></td>
43
+ # <td>
44
+ # A natural language or ISO8601-parseable period.
45
+ # <br />
46
+ # Value returned is the number of seconds in the given period.
47
+ # <br />
48
+ # Actual interpretation of the value is handled by the *chronic_duration* gem.
49
+ # </td>
50
+ # </tr>
51
+ # </tbody>
52
+ # </table>
53
+ #
54
54
  module ChronologyTypes
55
55
  EnvParser.define_type(:date, if_unset: nil) do |value|
56
56
  require 'chronic'
@@ -85,10 +85,10 @@ module EnvParser::Types
85
85
  original_raise_setting = ChronicDuration.raise_exceptions
86
86
  ChronicDuration.raise_exceptions = true
87
87
 
88
- ## With `raise_exceptions` set, ChronicDuration will fail on the "P" and "T" in ISO8601
89
- ## periods, so we have to check for and remove them.
90
- ##
91
- iso_period = %r{^\s*P(?:[0-9.]Y)?(?:[0-9.]M)?(?:[0-9.]W)?(?:[0-9.]D)?(?:T(?:[0-9.]H)?(?:[0-9.]M)?(?:[0-9.]S)?)?\s*$} ## rubocop:disable Metrics/LineLength
88
+ # With `raise_exceptions` set, ChronicDuration will fail on the "P" and "T" in ISO8601
89
+ # periods, so we have to check for and remove them.
90
+ #
91
+ iso_period = %r{^\s*P(?:[0-9.]Y)?(?:[0-9.]M)?(?:[0-9.]W)?(?:[0-9.]D)?(?:T(?:[0-9.]H)?(?:[0-9.]M)?(?:[0-9.]S)?)?\s*$}
92
92
  value = value.delete 'PT' if value =~ iso_period
93
93
 
94
94
  value = ChronicDuration.parse value, keep_zero: true