prius 4.1.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/prius/registry.rb +2 -4
- data/lib/prius/version.rb +1 -1
- data/lib/prius.rb +2 -2
- data/spec/prius/registry_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3a8c8693c57b1528dc91a93f3cc4343315db4beb5e5f4eeea6d11be4bbb6fa8
|
4
|
+
data.tar.gz: 3784c94e35340ef5dcab6d6ca380204f7d5beac63937b4df3baa4e9352da995b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f06a5b14da5781a04009b414943f0485b5f7729c87ca2585756d65d94fbea599c56c07aef4278fc28873752652591cf346fa2ffd678aed155d6570ce3ed5e68
|
7
|
+
data.tar.gz: 48211d8f7ae7c20e59d411f08ba8b82cb366242510c4dabe2dbea94d8b3eb010a88d5f885dc0fd2f5e8b21c5199932eee43a9ebc59dc05fb8c0a5d1c7191f10c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Environment variables need to be loaded into the Prius registry before being
|
|
48
48
|
used. Typically this is done in an initialiser.
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
Prius.load(name, options
|
51
|
+
Prius.load(name, **options)
|
52
52
|
```
|
53
53
|
|
54
54
|
If an environment variable can't be loaded, Prius will raise one of:
|
data/lib/prius/registry.rb
CHANGED
@@ -14,10 +14,8 @@ module Prius
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# See Prius.load for documentation.
|
17
|
-
def load(name,
|
18
|
-
env_var =
|
19
|
-
type = options.fetch(:type, :string)
|
20
|
-
required = options.fetch(:required, true)
|
17
|
+
def load(name, env_var: nil, type: :string, required: true)
|
18
|
+
env_var = env_var.nil? ? name.to_s.upcase : env_var
|
21
19
|
@registry[name] = case type
|
22
20
|
when :string then load_string(env_var, required)
|
23
21
|
when :int then load_int(env_var, required)
|
data/lib/prius/version.rb
CHANGED
data/lib/prius.rb
CHANGED
@@ -25,8 +25,8 @@ module Prius
|
|
25
25
|
# Raises a MissingValueError for required values that are missing.
|
26
26
|
# Raises a TypeMismatchError if a value can't be coerced to the given `type`.
|
27
27
|
# Raises an ArgumentError if an invalid `type` is provided.
|
28
|
-
def self.load(name, options
|
29
|
-
registry.load(name, options)
|
28
|
+
def self.load(name, **options)
|
29
|
+
registry.load(name, **options)
|
30
30
|
end
|
31
31
|
|
32
32
|
# Fetch a value from the registry.
|
data/spec/prius/registry_spec.rb
CHANGED
@@ -15,6 +15,13 @@ describe Prius::Registry do
|
|
15
15
|
let(:registry) { Prius::Registry.new(env) }
|
16
16
|
|
17
17
|
describe "#load" do
|
18
|
+
context "given an invalid option" do
|
19
|
+
it "raises an error" do
|
20
|
+
expect { registry.load(:age, unsupported_option: :foo) }.
|
21
|
+
to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
18
25
|
context "given a name that's present in the environment" do
|
19
26
|
it "doesn't blow up" do
|
20
27
|
expect { registry.load(:name) }.to_not raise_error
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|