prius 4.1.0 → 5.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4ec85e28d88e7ac3605c1f22d6a71c9d14ec4e25c67cce15fb0655b9e878ea0
4
- data.tar.gz: 81451517255e0cb04890cc93a1f39c4848e726019030cc45ccb11f07b7d934e0
3
+ metadata.gz: f3a8c8693c57b1528dc91a93f3cc4343315db4beb5e5f4eeea6d11be4bbb6fa8
4
+ data.tar.gz: 3784c94e35340ef5dcab6d6ca380204f7d5beac63937b4df3baa4e9352da995b
5
5
  SHA512:
6
- metadata.gz: 417aa19312808fac0140c6e052695268ea7291ea2dcec5aae6af3f5ee300e8cfdeb325380380a7b71ebec28b06b9ff127802f310d5e6b680287aaf83b0d49a43
7
- data.tar.gz: fdd5adfc03b58811922487ca08e94add9ee99abf19e0840775f58cb1ee93e315787723ce29cd38b99af49904eed2b96aa6cc388fcd6256b33872bbbff17ad9e0
6
+ metadata.gz: 1f06a5b14da5781a04009b414943f0485b5f7729c87ca2585756d65d94fbea599c56c07aef4278fc28873752652591cf346fa2ffd678aed155d6570ce3ed5e68
7
+ data.tar.gz: 48211d8f7ae7c20e59d411f08ba8b82cb366242510c4dabe2dbea94d8b3eb010a88d5f885dc0fd2f5e8b21c5199932eee43a9ebc59dc05fb8c0a5d1c7191f10c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 5.0.0
2
+
3
+ * Ensure Prius#load raises an error when unexpected options are passed
4
+
1
5
  # 4.1.0
2
6
 
3
7
  * Add support for coercing to a date.
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:
@@ -14,10 +14,8 @@ module Prius
14
14
  end
15
15
 
16
16
  # See Prius.load for documentation.
17
- def load(name, options = {})
18
- env_var = options.fetch(:env_var, name.to_s.upcase)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prius
4
- VERSION = "4.1.0"
4
+ VERSION = "5.0.0"
5
5
  end
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.
@@ -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.1.0
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-09-05 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec