environment_helpers 1.6.1 → 1.6.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.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/README.md +12 -8
- data/lib/environment_helpers/datetime_helpers.rb +1 -1
- data/lib/environment_helpers/range_helpers.rb +7 -15
- data/lib/environment_helpers/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d12712e590750fe71245080aff19319e1272213992393da3d456d8ae36595420
|
|
4
|
+
data.tar.gz: 82015537f401344b0e9e4d90bb5396d16525bc0c2f13d27264dd4d7015b59879
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2981f6825b6dc346bdf5bf3df8bbdbafb972164a83912e424d9a737e8041fba35f1f3505048708cbf30c5045c83bf5918733c07132cbf2745bfc0933173ffcdd
|
|
7
|
+
data.tar.gz: c24393bac5d5e8d847f370ed5493699586626593db22aab9db4c104601ac31522c0e48a06d86a6f9bf8208246ffb70ff1d47090d0ee831c2266c009a41af9a98
|
data/.github/workflows/rspec.yml
CHANGED
|
@@ -8,7 +8,7 @@ jobs:
|
|
|
8
8
|
strategy:
|
|
9
9
|
fail-fast: false
|
|
10
10
|
matrix:
|
|
11
|
-
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
|
|
11
|
+
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0', 'head']
|
|
12
12
|
env:
|
|
13
13
|
SIMPLECOV: "enabled"
|
|
14
14
|
BUNDLE_GEMFILE: Gemfile.ruby${{ matrix.ruby-version }}
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Release 1.6.2
|
|
4
|
+
|
|
5
|
+
* Support negative endpoints in `ENV.integer_range` for `..` and `...` formats (#46, #48)
|
|
6
|
+
* Fix typo in `InvalidDateTimeText` error message (#45, #47)
|
|
7
|
+
* Fix README: correct gem name in installation snippet, `integer` behavior
|
|
8
|
+
description, and document `date_time` format-string limitation (#44, #49)
|
|
9
|
+
* Test against updated rubies (#43)
|
|
10
|
+
|
|
3
11
|
## Relase 1.6.1
|
|
4
12
|
|
|
5
13
|
* Update all of the Gemfile(.lock) symlinks to actual file copies, for platform
|
data/README.md
CHANGED
|
@@ -26,7 +26,7 @@ quickly.
|
|
|
26
26
|
## Installation
|
|
27
27
|
|
|
28
28
|
```ruby
|
|
29
|
-
gem "
|
|
29
|
+
gem "environment_helpers"
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
There's not much to it - add the gem to your gemfile and when it's loaded it'll
|
|
@@ -65,12 +65,14 @@ The available methods added to `ENV`:
|
|
|
65
65
|
value, though you should probably just use "true" and "false" really. If you
|
|
66
66
|
specify `required: true` and get a value like "maybe?", it'll raise an
|
|
67
67
|
`EnvironmentHelpers::InvalidBooleanText` exception.
|
|
68
|
-
* `integer_range` - produces an integer Range object. It accepts `N
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
* `integer_range` - produces an integer Range object. It accepts `N..N` or
|
|
69
|
+
`N...N` (the latter excludes the upper bound, as in Ruby), and both formats
|
|
70
|
+
support negative endpoints (e.g. `-5..10`, `-10..-3`). A dash-separated
|
|
71
|
+
format `N-N` is also accepted, but only supports non-negative endpoints.
|
|
72
|
+
* `integer` - produces an integer from the environment variable. Only values
|
|
73
|
+
matching `/\A-?\d+\z/` are accepted; anything else is treated as if the
|
|
74
|
+
variable were absent (returning `nil` or the default, or raising
|
|
75
|
+
`InvalidIntegerText` if `required: true`).
|
|
74
76
|
* `file_path` - produces a `Pathname` initialized with the path specified by the
|
|
75
77
|
environment variable.
|
|
76
78
|
* `date` - produces a `Date` object, using `Date.strptime`. The default format
|
|
@@ -83,7 +85,9 @@ The available methods added to `ENV`:
|
|
|
83
85
|
an allowed 'format'. But if it is supplied as a _string_, it will be handled
|
|
84
86
|
as a strptime format string (the `:unix` format is equivalent to the format
|
|
85
87
|
string `"%s"`). It handles invalid or unparseable values like `ENV.date` does,
|
|
86
|
-
in that they are treated as if not supplied.
|
|
88
|
+
in that they are treated as if not supplied. Note that an invalid format string
|
|
89
|
+
(e.g. one containing an unknown directive) is indistinguishable from a
|
|
90
|
+
non-matching value and will be silently treated the same way.
|
|
87
91
|
* `array` - produces an array of strings, symbols, or integers, depending on the
|
|
88
92
|
value of the `of` parameter. You can specify the delimiter using a `delimiter`
|
|
89
93
|
parameter (it defaults to a comma).
|
|
@@ -19,7 +19,7 @@ module EnvironmentHelpers
|
|
|
19
19
|
|
|
20
20
|
return dt if dt
|
|
21
21
|
return default unless required
|
|
22
|
-
fail(InvalidDateTimeText, "
|
|
22
|
+
fail(InvalidDateTimeText, "Required date_time environment variable #{name} had inappropriate content '#{text}'")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
private
|
|
@@ -19,24 +19,16 @@ module EnvironmentHelpers
|
|
|
19
19
|
fail(BadDefault, "Invalid endpoint for default range of #{context} - must be Integer")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def parse_range_bound_from(text)
|
|
23
|
-
return nil if text.nil?
|
|
24
|
-
return nil if text.empty?
|
|
25
|
-
text.to_i
|
|
26
|
-
end
|
|
27
|
-
|
|
28
22
|
def parse_range_from(text)
|
|
29
|
-
text =~ /\A(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return nil if lower_bound.nil? || upper_bound.nil?
|
|
35
|
-
if separator == "..."
|
|
36
|
-
(lower_bound...upper_bound)
|
|
23
|
+
if text =~ /\A(-?\d+)(\.\.\.?)(-?\d+)\z/
|
|
24
|
+
lower_bound, separator, upper_bound = $1.to_i, $2, $3.to_i
|
|
25
|
+
elsif text =~ /\A(\d+)-(\d+)\z/
|
|
26
|
+
lower_bound, separator, upper_bound = $1.to_i, "..", $2.to_i
|
|
37
27
|
else
|
|
38
|
-
|
|
28
|
+
return nil
|
|
39
29
|
end
|
|
30
|
+
|
|
31
|
+
(separator == "...") ? (lower_bound...upper_bound) : (lower_bound..upper_bound)
|
|
40
32
|
end
|
|
41
33
|
end
|
|
42
34
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: environment_helpers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Mueller
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
177
|
- !ruby/object:Gem::Version
|
|
178
178
|
version: '0'
|
|
179
179
|
requirements: []
|
|
180
|
-
rubygems_version: 3.
|
|
180
|
+
rubygems_version: 3.3.22
|
|
181
181
|
signing_key:
|
|
182
182
|
specification_version: 4
|
|
183
183
|
summary: A set of convenience methods for accessing environment data
|