From b65b2a128a5744edc62274f0b63481b087f1af24 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 21 Nov 2023 07:44:54 +0100 Subject: [PATCH 1/3] add spec for keyword arguments --- spec/configurate/lookup_chain_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/configurate/lookup_chain_spec.rb b/spec/configurate/lookup_chain_spec.rb index b2af663..d86e562 100644 --- a/spec/configurate/lookup_chain_spec.rb +++ b/spec/configurate/lookup_chain_spec.rb @@ -27,6 +27,11 @@ def lookup(_setting, *_args); end expect(ValidConfigurationProvider).to receive(:new).with(:extra) subject.add_provider ValidConfigurationProvider, :extra end + + it "passes keyword args to the provider" do + expect(ValidConfigurationProvider).to receive(:new).with(required: false) + subject.add_provider ValidConfigurationProvider, required: false + end end describe "#lookup" do From 89fbb490ca00f53c32486fd79ccc3def909de65e Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 21 Nov 2023 07:46:29 +0100 Subject: [PATCH 2/3] use argument forwarding operator for add_provider --- configurate.gemspec | 2 +- lib/configurate/lookup_chain.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configurate.gemspec b/configurate.gemspec index adff9e0..fbc8917 100644 --- a/configurate.gemspec +++ b/configurate.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.test_files = Dir["spec/**/*.rb"] s.require_paths = ["lib"] - s.required_ruby_version = ">= 2.3.0" + s.required_ruby_version = ">= 2.7.0" s.add_development_dependency "rake", ">= 10.0.3" s.add_development_dependency "rspec", ">= 3.0" diff --git a/lib/configurate/lookup_chain.rb b/lib/configurate/lookup_chain.rb index cce9eec..ac8876c 100644 --- a/lib/configurate/lookup_chain.rb +++ b/lib/configurate/lookup_chain.rb @@ -12,15 +12,15 @@ def initialize # they are added, so the order is important. # # @param provider [#lookup] - # @param *args the arguments passed to the providers constructor + # @param ... the arguments passed to the providers constructor # @raise [ArgumentError] if an invalid provider is given # @return [void] - def add_provider(provider, *args) + def add_provider(provider, ...) unless provider.respond_to?(:instance_methods) && provider.instance_methods.include?(:lookup) raise ArgumentError, "the given provider does not respond to lookup" end - @provider << provider.new(*args) + @provider << provider.new(...) end # Tries all providers in the order they were added to provide a response @@ -31,11 +31,11 @@ def add_provider(provider, *args) # @param ... further args passed to the provider # @return [Array,Hash,String,Boolean,nil] whatever the responding # provider provides is casted to a {String}, except for some special values - def lookup(setting, *args) + def lookup(setting, ...) setting = SettingPath.new setting if setting.is_a? String @provider.each do |provider| begin - return special_value_or_string(provider.lookup(setting.clone, *args)) + return special_value_or_string(provider.lookup(setting.clone, ...)) rescue SettingNotFoundError; end end From 716aa4e2c24bbdf475e1e44b348e1da5a2915c0c Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Tue, 21 Nov 2023 10:52:11 +0100 Subject: [PATCH 3/3] drop support for Ruby < 2.7, add 3.2 to the test matrix --- .github/workflows/ci.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51ecb92..2365000 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.3', '2.7', '3.0', '3.1'] + ruby-version: ['2.7', '3.0', '3.1', '3.2'] steps: - uses: actions/checkout@v3 - name: Set up Ruby diff --git a/README.md b/README.md index 8a0eb5e..11b4885 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ your default settings with a user configuration file and let those be overridden by environment variables. The query interface allows to group and nest your configuration options to a practically unlimited level. -Configurate supports Ruby 2.3 or later. +Configurate supports Ruby 2.7 or later. ## Installation