diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b173508..899fa7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3"] + ruby: ["3.3", "3.4", "4.0"] name: ${{ matrix.ruby }} @@ -39,7 +39,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.2", "3.3"] + ruby: ["3.4", "4.0"] name: http 6 / Ruby ${{ matrix.ruby }} diff --git a/.rubocop.yml b/.rubocop.yml index 827d668..0fd6a99 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ inherit_gem: AllCops: DisplayCopNames: true - TargetRubyVersion: 3.0 + TargetRubyVersion: 3.3 Include: - bin/console - Gemfile diff --git a/Gemfile.lock b/Gemfile.lock index 28cf5f0..5532a49 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,24 +7,27 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (7.1.4) + activesupport (8.1.3) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) - base64 (0.2.0) - bigdecimal (3.1.8) + base64 (0.3.0) + bigdecimal (4.1.2) coderay (1.1.3) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) + concurrent-ruby (1.3.7) + connection_pool (3.0.2) coveralls (0.7.2) multi_json (~> 1.3) rest-client (= 1.6.7) @@ -37,7 +40,7 @@ GEM diff-lcs (1.5.1) docile (1.4.1) domain_name (0.6.20240107) - drb (2.2.1) + drb (2.2.3) ffi (1.17.0) ffi-compiler (1.3.2) ffi (>= 1.15.5) @@ -52,33 +55,40 @@ GEM http-cookie (1.0.7) domain_name (~> 0.5) http-form_data (2.3.0) - i18n (1.14.6) + i18n (1.15.1) concurrent-ruby (~> 1.0) + io-console (0.8.2) json (2.7.2) language_server-protocol (3.17.0.3) llhttp-ffi (0.5.0) ffi-compiler (~> 1.0) rake (~> 13.0) + logger (1.7.0) method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) mime-types-data (3.2024.0903) - minitest (5.25.1) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) multi_json (1.15.0) - mutex_m (0.2.0) parallel (1.26.3) parser (3.3.5.0) ast (~> 2.4.1) racc - pry (0.14.2) + prism (1.9.0) + pry (0.16.0) coderay (~> 1.1) method_source (~> 1.0) + reline (>= 0.6.0) public_suffix (6.0.1) racc (1.8.1) rack (3.1.7) rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) + reline (0.6.3) + io-console (~> 0.5) rest-client (1.6.7) mime-types (>= 1.16) rexml (3.3.7) @@ -132,6 +142,7 @@ GEM rubocop-sequel (0.3.4) rubocop (~> 1.0) ruby-progressbar (1.13.0) + securerandom (0.4.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -146,6 +157,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.6.0) + uri (1.1.1) webmock (3.23.1) addressable (>= 2.8.0) crack (>= 0.3.2) diff --git a/ezclient.gemspec b/ezclient.gemspec index f767b0f..394aba7 100644 --- a/ezclient.gemspec +++ b/ezclient.gemspec @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "ezclient/version" Gem::Specification.new do |spec| - spec.required_ruby_version = ">= 3.0" + spec.required_ruby_version = ">= 3.3" spec.name = "ezclient" spec.version = EzClient::VERSION diff --git a/lib/ezclient.rb b/lib/ezclient.rb index 4cc6ada..e2fb924 100644 --- a/lib/ezclient.rb +++ b/lib/ezclient.rb @@ -13,8 +13,8 @@ require_relative "ezclient/check_options" module EzClient - def self.new(*args) - Client.new(*args) + def self.new(*) + Client.new(*) end def self.get_time diff --git a/lib/ezclient/client.rb b/lib/ezclient/client.rb index 663ee61..efc06d5 100644 --- a/lib/ezclient/client.rb +++ b/lib/ezclient/client.rb @@ -32,23 +32,23 @@ def request(verb, url, **options) if keep_alive_timeout client = persistent_client_registry.for( - url, ssl_context: ssl_context, timeout: keep_alive_timeout + url, ssl_context:, timeout: keep_alive_timeout ) else client = HTTP::Client.new end - EzClient::Request.new(verb, url, client: client, **options).tap do |request| + EzClient::Request.new(verb, url, client:, **options).tap do |request| request.api_auth!(*api_auth) if api_auth end end - def perform(*args, **kwargs) - request(*args, **kwargs).perform + def perform(*, **) + request(*, **).perform end - def perform!(*args, **kwargs) - request(*args, **kwargs).perform! + def perform!(*, **) + request(*, **).perform! end private diff --git a/lib/ezclient/httprb_compatibility.rb b/lib/ezclient/httprb_compatibility.rb index 86ea72f..d8fee4c 100644 --- a/lib/ezclient/httprb_compatibility.rb +++ b/lib/ezclient/httprb_compatibility.rb @@ -41,7 +41,7 @@ def persistent_client(origin, keep_alive_timeout) if client_supports_build_request? HTTP.persistent(origin, timeout: keep_alive_timeout) else - HTTP::Client.new(persistent: origin, keep_alive_timeout: keep_alive_timeout) + HTTP::Client.new(persistent: origin, keep_alive_timeout:) end end diff --git a/lib/ezclient/request.rb b/lib/ezclient/request.rb index 16f463a..e699779 100644 --- a/lib/ezclient/request.rb +++ b/lib/ezclient/request.rb @@ -86,10 +86,10 @@ def perform! end end - def api_auth!(*args) + def api_auth!(*) raise "ApiAuth gem is not loaded" unless defined?(ApiAuth) - ApiAuth.sign!(api_auth_request, *args) + ApiAuth.sign!(api_auth_request, *) self end @@ -205,11 +205,11 @@ def redirector(options) EzClient::HttprbCompatibility.redirector(options) end - def with_retry(&block) + def with_retry(&) retries = 0 begin - retry_on_connection_error(&block) + retry_on_connection_error(&) rescue *retried_exceptions => error if retries < max_retries.to_i retries += 1 @@ -298,7 +298,7 @@ def basic_auth case options[:basic_auth] when Array user, password = options[:basic_auth] - { user: user, pass: password } + { user:, pass: password } when Hash options[:basic_auth] end diff --git a/spec/ezclient_spec.rb b/spec/ezclient_spec.rb index 17f3c20..d67e622 100644 --- a/spec/ezclient_spec.rb +++ b/spec/ezclient_spec.rb @@ -52,7 +52,7 @@ def self.sign!(*); end end context "when headers request option is provided" do - let(:request_options) { { headers: headers } } + let(:request_options) { { headers: } } let(:headers) { { some_header: 1 } } it "makes request with proper headers" do @@ -78,7 +78,7 @@ def self.sign!(*); end end context "when cookies request option is provided" do - let(:request_options) { { headers: headers, cookies: cookies } } + let(:request_options) { { headers:, cookies: } } let(:cookies) { { a: 1 } } it "makes request with proper headers" do @@ -137,7 +137,7 @@ def self.sign!(*); end end context "when params request option is provided" do - let(:request_options) { { params: params } } + let(:request_options) { { params: } } let(:params) { { a: 1 } } it "makes proper request" do @@ -184,7 +184,7 @@ def self.sign!(*); end end context "when on_complete callback is provided" do - let(:client_options) { { on_complete: on_complete } } + let(:client_options) { { on_complete: } } let(:calls) { [] } let(:on_complete) do @@ -265,7 +265,7 @@ def self.sign!(*); end end context "when on_error callback is provided" do - let(:client_options) { { on_error: on_error } } + let(:client_options) { { on_error: } } let(:calls) { [] } let(:on_error) do @@ -285,7 +285,7 @@ def self.sign!(*); end end context "when error_wrapper callback is provided" do - let(:client_options) { { error_wrapper: error_wrapper } } + let(:client_options) { { error_wrapper: } } let(:calls) { [] } let(:error_wrapper) do @@ -314,7 +314,7 @@ def self.sign!(*); end end context "when on_retry callback is provided" do - let(:client_options) { { on_retry: on_retry } } + let(:client_options) { { on_retry: } } let(:request_options) { { metadata: :smth } } let(:calls) { [] } @@ -549,7 +549,7 @@ def self.sign!(*); end end context "when on_retry callback is provided" do - let(:client_options) { { on_retry: on_retry } } + let(:client_options) { { on_retry: } } let(:request_options) { { retry_exceptions: SomeError, metadata: :smth } } let(:calls) { [] } @@ -669,7 +669,7 @@ def build(verb, url) context "when follow redirect has on_redirect callback" do let(:verb) { :get } let(:calls) { [] } - let(:request_options) { { follow: { on_redirect: on_redirect } } } + let(:request_options) { { follow: { on_redirect: } } } let(:on_redirect) do proc do |response, redirect_request| @@ -769,7 +769,7 @@ def build(verb, url) let(:cookies) { { sid: "a;b" } } let(:ezclient_request) do - EzClient.new.request(:get, "http://example.com", cookies: cookies) + EzClient.new.request(:get, "http://example.com", cookies:) end let(:http_request) { ezclient_request.send(:http_request) } @@ -804,7 +804,7 @@ def build(verb, url) attr_reader :credentials def basic_auth(user:, pass:) - @credentials = { user: user, pass: pass } + @credentials = { user:, pass: } self end end @@ -824,7 +824,7 @@ def basic_auth(user:, pass:) attr_reader :options def initialize(max_hops:) - @options = { max_hops: max_hops } + @options = { max_hops: } end end end @@ -844,7 +844,7 @@ def initialize(max_hops:) attr_reader :attributes def initialize(status:, headers:) - @attributes = { status: status, headers: headers } + @attributes = { status:, headers: } end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4b85fb5..f607898 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -40,11 +40,11 @@ def from_webmock(request, webmock_response, _request_signature = nil) body = build_http_rb_response_body_from_webmock_response(webmock_response) EzClient::HttprbCompatibility.response( - status: status, + status:, version: "1.1", - headers: headers, - body: body, - request: request, + headers:, + body:, + request:, ) end end