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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3a8c8693c57b1528dc91a93f3cc4343315db4beb5e5f4eeea6d11be4bbb6fa8
4
- data.tar.gz: 3784c94e35340ef5dcab6d6ca380204f7d5beac63937b4df3baa4e9352da995b
3
+ metadata.gz: 8892ebc746ab5baf0ea2fee00e8bd3f7fc8f52494d8d2e9aec1e9d178e358333
4
+ data.tar.gz: d5443265d28678cb4f96fc5ec2fe3cea7afa3c3c7bb7a85f8d3155c1e61128a9
5
5
  SHA512:
6
- metadata.gz: 1f06a5b14da5781a04009b414943f0485b5f7729c87ca2585756d65d94fbea599c56c07aef4278fc28873752652591cf346fa2ffd678aed155d6570ce3ed5e68
7
- data.tar.gz: 48211d8f7ae7c20e59d411f08ba8b82cb366242510c4dabe2dbea94d8b3eb010a88d5f885dc0fd2f5e8b21c5199932eee43a9ebc59dc05fb8c0a5d1c7191f10c
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: 2.6
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: 'only_raise'
17
+ EnforcedStyle: "only_raise"
22
18
 
23
19
  Layout/DotPosition:
24
- EnforcedStyle: 'trailing'
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
- * Ensure Prius#load raises an error when unexpected options are passed
9
+ - Ensure Prius#load raises an error when unexpected options are passed
4
10
 
5
11
  # 4.1.0
6
12
 
7
- * Add support for coercing to a date.
13
+ - Add support for coercing to a date.
8
14
 
9
15
  # 4.0.0
10
16
 
11
- * Add support for Ruby 3.0
12
- * Enforce Ruby 2.6 as minimum required version
13
- * Drop support for Ruby 2.2, 2.3, 2.4, 2.5
14
- * Drop support for JRuby versions < 9.3.x (implicity enforced by C Ruby version 2.6 as minimum)
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
- * Enforce Ruby 2.2 as minimum required version
19
- * Use CircleCI instead of Travis for CI builds
20
- * Add Dependabot support
21
- * Some development dependency updates
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
- * Drop support for Ruby versions 1.9, 2.0, 2.1, and add support for 2.3 and 2.4
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
@@ -3,3 +3,10 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
+
7
+ group :development do
8
+ gem "gc_ruboconfig", "~> 4.4"
9
+ gem 'pry'
10
+ gem "rspec", "~> 3.12"
11
+ gem "rspec-github", "~> 2.4.0"
12
+ end
@@ -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 = env_var.nil? ? name.to_s.upcase : 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 value =~ /\A[0-9]+\z/
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prius
4
- VERSION = "5.0.0"
4
+ VERSION = "6.0.0"
5
5
  end
data/prius.gemspec CHANGED
@@ -1,27 +1,30 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
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.description = %q{Environmentally-friendly config}
12
- spec.summary = spec.description
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 = ">= 2.6"
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.add_development_dependency "rspec", "~> 3.1"
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: 5.0.0
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: 2022-10-24 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rspec
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
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
- post_install_message:
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: '2.6'
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.0.3.1
111
- signing_key:
55
+ rubygems_version: 3.5.3
56
+ signing_key:
112
57
  specification_version: 4
113
- summary: Environmentally-friendly config
114
- test_files:
115
- - spec/prius/registry_spec.rb
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
@@ -1,7 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: bundler
4
- directory: "/"
5
- schedule:
6
- interval: weekly
7
- open-pull-requests-limit: 10
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- Gemfile.lock
2
- .bundle
3
- *.gem
@@ -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