prius 5.0.0 → 6.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 +4 -4
- data/.rubocop.yml +19 -14
- data/.ruby-version +1 -0
- data/CHANGELOG.md +17 -11
- data/Gemfile +7 -0
- data/lib/prius/registry.rb +5 -2
- data/lib/prius/version.rb +1 -1
- data/prius.gemspec +18 -15
- metadata +18 -73
- data/.circleci/config.yml +0 -60
- data/.github/dependabot.yml +0 -7
- data/.gitignore +0 -3
- data/spec/prius/registry_spec.rb +0 -142
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8892ebc746ab5baf0ea2fee00e8bd3f7fc8f52494d8d2e9aec1e9d178e358333
|
4
|
+
data.tar.gz: d5443265d28678cb4f96fc5ec2fe3cea7afa3c3c7bb7a85f8d3155c1e61128a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de66a2ae735c7cc8632085b01a47ddf3970cd68c928e60d82556305014770d3afc38e394beb72d0bb11d632ea270df97d7e259eb030a0a9eaf0c37c8c61e467d
|
7
|
+
data.tar.gz: 490b1e5e00a419cc500cd640fcc81af32d5b446f14a93f1cecbae0c33d3774d740a81068c1b622f50d92e1f2ec156090a0745f7430d9bbcfbc98db60aa1fa043
|
data/.rubocop.yml
CHANGED
@@ -1,28 +1,33 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
gc_ruboconfig: rubocop.yml
|
3
|
+
|
4
|
+
require:
|
5
|
+
- rubocop-rspec
|
6
|
+
|
1
7
|
AllCops:
|
8
|
+
NewCops: enable
|
2
9
|
Exclude:
|
3
|
-
- prius.gemspec
|
4
10
|
- vendor/**/*
|
5
|
-
TargetRubyVersion:
|
6
|
-
|
7
|
-
# Limit lines to 80 characters.
|
8
|
-
LineLength:
|
9
|
-
Max: 80
|
10
|
-
|
11
|
-
ClassLength:
|
12
|
-
Max: 300
|
13
|
-
|
14
|
-
StringLiterals:
|
15
|
-
Enabled: false
|
11
|
+
TargetRubyVersion: 3.1
|
16
12
|
|
17
13
|
Style/Documentation:
|
18
14
|
Enabled: false
|
19
15
|
|
20
16
|
Style/SignalException:
|
21
|
-
EnforcedStyle:
|
17
|
+
EnforcedStyle: "only_raise"
|
22
18
|
|
23
19
|
Layout/DotPosition:
|
24
|
-
EnforcedStyle:
|
20
|
+
EnforcedStyle: "trailing"
|
25
21
|
|
26
22
|
Metrics/BlockLength:
|
27
23
|
Exclude:
|
28
24
|
- "spec/**/*_spec.rb"
|
25
|
+
|
26
|
+
RSpec/NestedGroups:
|
27
|
+
Max: 5
|
28
|
+
|
29
|
+
Gemspec/RequiredRubyVersion:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
RSpec/MultipleExpectations:
|
33
|
+
Max: 5
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.0
|
data/CHANGELOG.md
CHANGED
@@ -1,28 +1,34 @@
|
|
1
|
+
# 6.0.0 - 2024-01-09
|
2
|
+
|
3
|
+
- Drop support for Ruby 2.6 and 2.7.
|
4
|
+
- Add support for Ruby 3.2 and 3.3.
|
5
|
+
- Downcase boolean values when checking for truthiness.
|
6
|
+
|
1
7
|
# 5.0.0
|
2
8
|
|
3
|
-
|
9
|
+
- Ensure Prius#load raises an error when unexpected options are passed
|
4
10
|
|
5
11
|
# 4.1.0
|
6
12
|
|
7
|
-
|
13
|
+
- Add support for coercing to a date.
|
8
14
|
|
9
15
|
# 4.0.0
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
- Add support for Ruby 3.0
|
18
|
+
- Enforce Ruby 2.6 as minimum required version
|
19
|
+
- Drop support for Ruby 2.2, 2.3, 2.4, 2.5
|
20
|
+
- Drop support for JRuby versions < 9.3.x (implicity enforced by C Ruby version 2.6 as minimum)
|
15
21
|
|
16
22
|
# 3.0.0
|
17
23
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
- Enforce Ruby 2.2 as minimum required version
|
25
|
+
- Use CircleCI instead of Travis for CI builds
|
26
|
+
- Add Dependabot support
|
27
|
+
- Some development dependency updates
|
22
28
|
|
23
29
|
# 2.0.0
|
24
30
|
|
25
|
-
|
31
|
+
- Drop support for Ruby versions 1.9, 2.0, 2.1, and add support for 2.3 and 2.4
|
26
32
|
|
27
33
|
# 1.0.0
|
28
34
|
|
data/Gemfile
CHANGED
data/lib/prius/registry.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "date"
|
3
4
|
require "prius/errors"
|
4
5
|
|
5
6
|
module Prius
|
@@ -15,7 +16,7 @@ module Prius
|
|
15
16
|
|
16
17
|
# See Prius.load for documentation.
|
17
18
|
def load(name, env_var: nil, type: :string, required: true)
|
18
|
-
env_var =
|
19
|
+
env_var = name.to_s.upcase if env_var.nil?
|
19
20
|
@registry[name] = case type
|
20
21
|
when :string then load_string(env_var, required)
|
21
22
|
when :int then load_int(env_var, required)
|
@@ -46,7 +47,7 @@ module Prius
|
|
46
47
|
value = load_string(name, required)
|
47
48
|
return value if value.nil?
|
48
49
|
|
49
|
-
unless
|
50
|
+
unless /\A[0-9]+\z/.match?(value)
|
50
51
|
raise TypeMismatchError, "'#{name}' value '#{value}' is not an integer"
|
51
52
|
end
|
52
53
|
|
@@ -56,6 +57,8 @@ module Prius
|
|
56
57
|
def load_bool(name, required)
|
57
58
|
value = load_string(name, required)
|
58
59
|
return nil if value.nil?
|
60
|
+
|
61
|
+
value = value.downcase
|
59
62
|
return true if %w[yes y true t 1].include?(value)
|
60
63
|
return false if %w[no n false f 0].include?(value)
|
61
64
|
|
data/lib/prius/version.rb
CHANGED
data/prius.gemspec
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
require 'prius/version'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/prius/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = "prius"
|
8
7
|
spec.version = Prius::VERSION
|
9
8
|
spec.authors = ["GoCardless Engineering"]
|
10
9
|
spec.email = ["engineering@gocardless.com"]
|
11
|
-
spec.
|
12
|
-
|
10
|
+
spec.summary = "Environmentally-friendly config. Validate and enforce the presence " \
|
11
|
+
"and correct types of environment variables."
|
12
|
+
spec.description = <<~MSG.strip.tr("\n", " ")
|
13
|
+
Prius is a powerful and versatile gem designed to simplify the management of environment variables
|
14
|
+
in your application. With Prius, you can guarantee that your environment variables are not only
|
15
|
+
present but also valid, ensuring a smoother and more reliable app experience.
|
16
|
+
MSG
|
13
17
|
spec.homepage = "https://github.com/gocardless/prius"
|
14
18
|
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = ">=
|
21
|
+
spec.required_ruby_version = ">= 3.0"
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/
|
25
|
+
.git .circleci appveyor])
|
26
|
+
end
|
27
|
+
end
|
22
28
|
|
23
|
-
spec.
|
24
|
-
spec.add_development_dependency "rubocop", "~> 1.24"
|
25
|
-
spec.add_development_dependency "rspec_junit_formatter", "~> 0.5.1"
|
26
|
-
spec.add_development_dependency "rubocop-performance", "~> 1.13"
|
29
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
27
30
|
end
|
metadata
CHANGED
@@ -1,82 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless Engineering
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.1'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rubocop
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.24'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.24'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec_junit_formatter
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.5.1
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.5.1
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop-performance
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.13'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.13'
|
69
|
-
description: Environmentally-friendly config
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Prius is a powerful and versatile gem designed to simplify the management
|
14
|
+
of environment variables in your application. With Prius, you can guarantee that
|
15
|
+
your environment variables are not only present but also valid, ensuring a smoother
|
16
|
+
and more reliable app experience.
|
70
17
|
email:
|
71
18
|
- engineering@gocardless.com
|
72
19
|
executables: []
|
73
20
|
extensions: []
|
74
21
|
extra_rdoc_files: []
|
75
22
|
files:
|
76
|
-
- ".circleci/config.yml"
|
77
|
-
- ".github/dependabot.yml"
|
78
|
-
- ".gitignore"
|
79
23
|
- ".rubocop.yml"
|
24
|
+
- ".ruby-version"
|
80
25
|
- CHANGELOG.md
|
81
26
|
- Gemfile
|
82
27
|
- LICENSE
|
@@ -87,12 +32,12 @@ files:
|
|
87
32
|
- lib/prius/registry.rb
|
88
33
|
- lib/prius/version.rb
|
89
34
|
- prius.gemspec
|
90
|
-
- spec/prius/registry_spec.rb
|
91
35
|
homepage: https://github.com/gocardless/prius
|
92
36
|
licenses:
|
93
37
|
- MIT
|
94
|
-
metadata:
|
95
|
-
|
38
|
+
metadata:
|
39
|
+
rubygems_mfa_required: 'true'
|
40
|
+
post_install_message:
|
96
41
|
rdoc_options: []
|
97
42
|
require_paths:
|
98
43
|
- lib
|
@@ -100,16 +45,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
45
|
requirements:
|
101
46
|
- - ">="
|
102
47
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
48
|
+
version: '3.0'
|
104
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
50
|
requirements:
|
106
51
|
- - ">="
|
107
52
|
- !ruby/object:Gem::Version
|
108
53
|
version: '0'
|
109
54
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
55
|
+
rubygems_version: 3.5.3
|
56
|
+
signing_key:
|
112
57
|
specification_version: 4
|
113
|
-
summary: Environmentally-friendly config
|
114
|
-
|
115
|
-
|
58
|
+
summary: Environmentally-friendly config. Validate and enforce the presence and correct
|
59
|
+
types of environment variables.
|
60
|
+
test_files: []
|
data/.circleci/config.yml
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
version: 2
|
2
|
-
|
3
|
-
references:
|
4
|
-
steps: &steps
|
5
|
-
- checkout
|
6
|
-
|
7
|
-
# CircleCI's Ruby images have Git installed, but the JRuby images lack it, so let's
|
8
|
-
# make sure it's installed
|
9
|
-
- run: apt-get update && apt-get install -y git
|
10
|
-
|
11
|
-
- type: cache-restore
|
12
|
-
key: prius-bundler-{{ checksum "prius.gemspec" }}
|
13
|
-
|
14
|
-
- run: gem install bundler -v 2.0.1
|
15
|
-
|
16
|
-
- run: bundle install --path vendor/bundle
|
17
|
-
|
18
|
-
- type: cache-save
|
19
|
-
key: prius-bundler-{{ checksum "prius.gemspec" }}
|
20
|
-
paths:
|
21
|
-
- vendor/bundle
|
22
|
-
|
23
|
-
- type: shell
|
24
|
-
command: |
|
25
|
-
bundle exec rspec --profile 10 \
|
26
|
-
--format RspecJunitFormatter \
|
27
|
-
--out /tmp/test-results/rspec.xml \
|
28
|
-
--format progress \
|
29
|
-
spec
|
30
|
-
|
31
|
-
- type: store_test_results
|
32
|
-
path: /tmp/test-results
|
33
|
-
|
34
|
-
- run: bundle exec rubocop
|
35
|
-
jobs:
|
36
|
-
build-ruby26:
|
37
|
-
docker:
|
38
|
-
- image: ruby:2.6
|
39
|
-
steps: *steps
|
40
|
-
build-ruby27:
|
41
|
-
docker:
|
42
|
-
- image: ruby:2.7
|
43
|
-
steps: *steps
|
44
|
-
build-ruby3:
|
45
|
-
docker:
|
46
|
-
- image: ruby:3
|
47
|
-
steps: *steps
|
48
|
-
build-jruby93:
|
49
|
-
docker:
|
50
|
-
- image: jruby:9.3
|
51
|
-
steps: *steps
|
52
|
-
|
53
|
-
workflows:
|
54
|
-
version: 2
|
55
|
-
tests:
|
56
|
-
jobs:
|
57
|
-
- build-ruby26
|
58
|
-
- build-ruby27
|
59
|
-
- build-ruby3
|
60
|
-
- build-jruby93
|
data/.github/dependabot.yml
DELETED
data/.gitignore
DELETED
data/spec/prius/registry_spec.rb
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "prius/registry"
|
4
|
-
|
5
|
-
describe Prius::Registry do
|
6
|
-
let(:env) do
|
7
|
-
{
|
8
|
-
"NAME" => "Harry",
|
9
|
-
"AGE" => "25",
|
10
|
-
"ALIVE" => "yes",
|
11
|
-
"BORN" => "2022-09-02",
|
12
|
-
"INVALID_DATE" => "2022-02-99"
|
13
|
-
}
|
14
|
-
end
|
15
|
-
let(:registry) { Prius::Registry.new(env) }
|
16
|
-
|
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
|
-
|
25
|
-
context "given a name that's present in the environment" do
|
26
|
-
it "doesn't blow up" do
|
27
|
-
expect { registry.load(:name) }.to_not raise_error
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "given a name that's not present in the environment" do
|
32
|
-
it "blows up" do
|
33
|
-
expect { registry.load(:slogan) }.
|
34
|
-
to raise_error(Prius::MissingValueError)
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when required is false" do
|
38
|
-
it "doesn't blow up" do
|
39
|
-
expect { registry.load(:slogan, required: false) }.to_not raise_error
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "given an invalid type" do
|
45
|
-
it "blows up" do
|
46
|
-
expect { registry.load(:name, type: :lightsabre) }.
|
47
|
-
to raise_error(ArgumentError)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when specifying :int as the type" do
|
52
|
-
context "given a integer value" do
|
53
|
-
it "doesn't blow up" do
|
54
|
-
expect { registry.load(:age, type: :int) }.to_not raise_error
|
55
|
-
end
|
56
|
-
|
57
|
-
it "stores an int" do
|
58
|
-
registry.load(:age, type: :int)
|
59
|
-
expect(registry.get(:age)).to be_a(Integer)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "given a non-integer value" do
|
64
|
-
it "blows up" do
|
65
|
-
expect { registry.load(:name, type: :int) }.
|
66
|
-
to raise_error(Prius::TypeMismatchError)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "when specifying :bool as the type" do
|
72
|
-
context "given a boolean value" do
|
73
|
-
it "doesn't blow up" do
|
74
|
-
expect { registry.load(:alive, type: :bool) }.to_not raise_error
|
75
|
-
end
|
76
|
-
|
77
|
-
it "stores an boolean" do
|
78
|
-
registry.load(:alive, type: :bool)
|
79
|
-
expect(registry.get(:alive)).to be_a(TrueClass)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "given a non-boolean value" do
|
84
|
-
it "blows up" do
|
85
|
-
expect { registry.load(:name, type: :bool) }.
|
86
|
-
to raise_error(Prius::TypeMismatchError)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context "when specifying :date as the type" do
|
92
|
-
context "given a date value" do
|
93
|
-
it "doesn't blow up" do
|
94
|
-
expect { registry.load(:born, type: :date) }.to_not raise_error
|
95
|
-
end
|
96
|
-
|
97
|
-
it "stores a date" do
|
98
|
-
registry.load(:born, type: :date)
|
99
|
-
expect(registry.get(:born)).to be_a(Date)
|
100
|
-
expect(registry.get(:born)).to eq(Date.parse(env["BORN"]))
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "given an invalid date value" do
|
105
|
-
it "blows up" do
|
106
|
-
expect { registry.load(:invalid_date, type: :date) }.
|
107
|
-
to raise_error(Prius::TypeMismatchError)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context "given a non-date value" do
|
112
|
-
it "blows up" do
|
113
|
-
expect { registry.load(:name, type: :date) }.
|
114
|
-
to raise_error(Prius::TypeMismatchError)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "#get" do
|
121
|
-
context "given a name that has been loaded" do
|
122
|
-
before { registry.load(:name) }
|
123
|
-
it "returns the value" do
|
124
|
-
expect(registry.get(:name)).to eq("Harry")
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context "given a name that hasn't been loaded" do
|
129
|
-
it "blows up" do
|
130
|
-
expect { registry.get(:name) }.
|
131
|
-
to raise_error(Prius::UndeclaredNameError)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
context "given a nillable name that has been loaded" do
|
136
|
-
before { registry.load(:lightsabre, required: false) }
|
137
|
-
it "returns nil" do
|
138
|
-
expect(registry.get(:lightsabre)).to be_nil
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|