From 1ec23b324eab3ece66636f1d9c64dc3d56ddc908 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Wed, 21 Oct 2020 08:31:54 +0200 Subject: [PATCH 1/7] CI: add "head" Ruby to matrix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8776fa1f0..a802e9145 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ['2.4', '2.5', '2.6', '2.7'] + ruby: ['2.4', '2.5', '2.6', '2.7', 'head'] steps: - uses: actions/checkout@v1 From aae0f810e723f3c639b925dc673068347d70f6ce Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 22 Oct 2020 21:06:34 +0200 Subject: [PATCH 2/7] Gemfile: Allow Ruby 3 to use net-http-client 4.x --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 8c6f3b4ac..1bb115552 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ group :test, :development do gem 'excon', '>= 0.27.4' gem 'httpclient', '>= 2.2' gem 'multipart-parser' - gem 'net-http-persistent', '~> 3.0' + gem 'net-http-persistent', '>= 3.0' # Ruby 3 requires 4.0.0+ gem 'patron', '>= 0.4.2', platforms: :ruby gem 'rack-test', '>= 0.6', require: 'rack/test' gem 'rspec', '~> 3.7' From d9edc66404ad21c7ee1b993797b2d5c29dda6e62 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 22 Oct 2020 21:13:02 +0200 Subject: [PATCH 3/7] Gemfile: Select net-http-persistent 4 differently Check for Ruby version 3+ --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1bb115552..9ae58123b 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ group :test, :development do gem 'excon', '>= 0.27.4' gem 'httpclient', '>= 2.2' gem 'multipart-parser' - gem 'net-http-persistent', '>= 3.0' # Ruby 3 requires 4.0.0+ + gem 'net-http-persistent', RUBY_VERSION.start_with?('3') ? '~> 4.0' : '~> 3.0' # Ruby 3 requires 4.0.0+ gem 'patron', '>= 0.4.2', platforms: :ruby gem 'rack-test', '>= 0.6', require: 'rack/test' gem 'rspec', '~> 3.7' From 2f91c90d5fe41518c5d4bb8d7867d26daf192678 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 22 Oct 2020 21:59:29 +0200 Subject: [PATCH 4/7] Gemfile: doc net-http-persistent has no gemspec --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 9ae58123b..e04de1248 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,8 @@ group :test, :development do gem 'excon', '>= 0.27.4' gem 'httpclient', '>= 2.2' gem 'multipart-parser' - gem 'net-http-persistent', RUBY_VERSION.start_with?('3') ? '~> 4.0' : '~> 3.0' # Ruby 3 requires 4.0.0+ + # This does not currently work, since there's no .gemspec file in the repo: + gem 'net-http-persistent', (RUBY_VERSION.start_with?('3') ? '>= 3.0' : '~> 3.0'), **(RUBY_VERSION.start_with?('3') ? { github: 'drbrain/net-http-persistent' } : {}) gem 'patron', '>= 0.4.2', platforms: :ruby gem 'rack-test', '>= 0.6', require: 'rack/test' gem 'rspec', '~> 3.7' From 185387dd376365b1341e269e2913817a5066a5a4 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Fri, 27 Nov 2020 14:59:29 -0800 Subject: [PATCH 5/7] redo --- .github/workflows/ci.yml | 14 +++++++++----- Gemfile | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a802e9145..d0294cba6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,9 +39,15 @@ jobs: build: needs: [linting] runs-on: ubuntu-latest + name: build ${{ matrix.ruby }} strategy: + fail-fast: false matrix: - ruby: ['2.4', '2.5', '2.6', '2.7', 'head'] + ruby: ['2.4', '2.5', '2.6', '2.7'] + experimental: [false] + include: + - ruby: head + experimental: true steps: - uses: actions/checkout@v1 @@ -49,12 +55,10 @@ jobs: with: ruby-version: ${{ matrix.ruby }} - - name: Install dependencies run: | sudo apt-get install libcurl4-openssl-dev - - name: Build run: | sudo apt-get install libcurl4-openssl-dev @@ -62,6 +66,6 @@ jobs: bundle install --jobs 4 --retry 3 - name: Test - run: | - bundle exec rake + continue-on-error: ${{ matrix.experimental }} + run: bundle exec rake diff --git a/Gemfile b/Gemfile index e04de1248..5bc51036b 100644 --- a/Gemfile +++ b/Gemfile @@ -24,8 +24,9 @@ group :test, :development do gem 'excon', '>= 0.27.4' gem 'httpclient', '>= 2.2' gem 'multipart-parser' - # This does not currently work, since there's no .gemspec file in the repo: - gem 'net-http-persistent', (RUBY_VERSION.start_with?('3') ? '>= 3.0' : '~> 3.0'), **(RUBY_VERSION.start_with?('3') ? { github: 'drbrain/net-http-persistent' } : {}) + # TODO: remove this once v4 is released + options = (RUBY_VERSION.start_with?('3') ? { github: 'grosser/net-http-persistent', branch: 'grosser/spec' } : {}) + gem 'net-http-persistent', (RUBY_VERSION.start_with?('3') ? '>= 3.0' : '~> 3.0'), **options gem 'patron', '>= 0.4.2', platforms: :ruby gem 'rack-test', '>= 0.6', require: 'rack/test' gem 'rspec', '~> 3.7' From 2143bb2ccb4cef2ac563798d22e9181ad30617c3 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Fri, 27 Nov 2020 15:33:25 -0800 Subject: [PATCH 6/7] avoid argument warnings --- faraday.gemspec | 1 - lib/faraday/dependency_loader.rb | 6 ++--- lib/faraday/rack_builder.rb | 40 ++++++++++++++++---------------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/faraday.gemspec b/faraday.gemspec index 429cf445b..0723c2456 100644 --- a/faraday.gemspec +++ b/faraday.gemspec @@ -16,7 +16,6 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.4' spec.add_dependency 'multipart-post', '>= 1.2', '< 3' - spec.add_dependency 'ruby2_keywords' # Includes `examples` and `spec` to allow external adapter gems to run Faraday unit and integration tests spec.files = Dir['CHANGELOG.md', '{examples,lib,spec}/**/*', 'LICENSE.md', 'Rakefile', 'README.md'] diff --git a/lib/faraday/dependency_loader.rb b/lib/faraday/dependency_loader.rb index 3f1708f8c..c04e594c5 100644 --- a/lib/faraday/dependency_loader.rb +++ b/lib/faraday/dependency_loader.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'ruby2_keywords' - module Faraday # DependencyLoader helps Faraday adapters and middleware load dependencies. module DependencyLoader @@ -15,12 +13,12 @@ def dependency(lib = nil) self.load_error = e end - ruby2_keywords def new(*) + def new(*args, **kwargs) unless loaded? raise "missing dependency for #{self}: #{load_error.message}" end - super + super(*args, **kwargs) end def loaded? diff --git a/lib/faraday/rack_builder.rb b/lib/faraday/rack_builder.rb index 42da63478..389d8a8b2 100644 --- a/lib/faraday/rack_builder.rb +++ b/lib/faraday/rack_builder.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'ruby2_keywords' require 'faraday/adapter_registry' module Faraday @@ -28,10 +27,11 @@ class Handler attr_reader :name - ruby2_keywords def initialize(klass, *args, &block) + def initialize(klass, *args, **kwargs, &block) @name = klass.to_s REGISTRY.set(klass) if klass.respond_to?(:name) @args = args + @kwargs = kwargs @block = block end @@ -54,7 +54,7 @@ def ==(other) end def build(app = nil) - klass.new(app, *@args, &@block) + klass.new(app, *@args, **@kwargs, &@block) end end @@ -90,52 +90,52 @@ def locked? @handlers.frozen? end - ruby2_keywords def use(klass, *args, &block) + def use(klass, *args, **kwargs, &block) if klass.is_a? Symbol - use_symbol(Faraday::Middleware, klass, *args, &block) + use_symbol(Faraday::Middleware, klass, *args, **kwargs, &block) else raise_if_locked raise_if_adapter(klass) - @handlers << self.class::Handler.new(klass, *args, &block) + @handlers << self.class::Handler.new(klass, *args, **kwargs, &block) end end - ruby2_keywords def request(key, *args, &block) - use_symbol(Faraday::Request, key, *args, &block) + def request(key, *args, **kwargs, &block) + use_symbol(Faraday::Request, key, *args, **kwargs, &block) end - ruby2_keywords def response(key, *args, &block) - use_symbol(Faraday::Response, key, *args, &block) + def response(key, *args, **kwargs, &block) + use_symbol(Faraday::Response, key, *args, **kwargs, &block) end - ruby2_keywords def adapter(klass = NO_ARGUMENT, *args, &block) + def adapter(klass = NO_ARGUMENT, *args, **kwargs, &block) return @adapter if klass == NO_ARGUMENT klass = Faraday::Adapter.lookup_middleware(klass) if klass.is_a?(Symbol) - @adapter = self.class::Handler.new(klass, *args, &block) + @adapter = self.class::Handler.new(klass, *args, **kwargs, &block) end ## methods to push onto the various positions in the stack: - ruby2_keywords def insert(index, *args, &block) + def insert(index, *args, **kwargs, &block) raise_if_locked index = assert_index(index) - handler = self.class::Handler.new(*args, &block) + handler = self.class::Handler.new(*args, **kwargs, &block) @handlers.insert(index, handler) end alias insert_before insert - ruby2_keywords def insert_after(index, *args, &block) + def insert_after(index, *args, **kwargs, &block) index = assert_index(index) - insert(index + 1, *args, &block) + insert(index + 1, *args, **kwargs, &block) end - ruby2_keywords def swap(index, *args, &block) + def swap(index, *args, **kwargs, &block) raise_if_locked index = assert_index(index) @handlers.delete_at(index) - insert(index, *args, &block) + insert(index, *args, **kwargs, &block) end def delete(handler) @@ -235,8 +235,8 @@ def is_adapter?(klass) # rubocop:disable Naming/PredicateName klass <= Faraday::Adapter end - ruby2_keywords def use_symbol(mod, key, *args, &block) - use(mod.lookup_middleware(key), *args, &block) + def use_symbol(mod, key, *args, **kwargs, &block) + use(mod.lookup_middleware(key), *args, **kwargs, &block) end def assert_index(index) From fe69f84bd48dfab503c73454977513beed1ad85f Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Mon, 7 Dec 2020 08:54:32 +0100 Subject: [PATCH 7/7] dependency_loader: Shotgun style typo fix I made a bad #1211 merge. This tries to repair that. --- lib/faraday/dependency_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/faraday/dependency_loader.rb b/lib/faraday/dependency_loader.rb index 1cb902a5c..57345646d 100644 --- a/lib/faraday/dependency_loader.rb +++ b/lib/faraday/dependency_loader.rb @@ -18,7 +18,7 @@ def new(*) raise "missing dependency for #{self}: #{load_error.message}" end - super(*args, **kwargs) + super end def loaded?