Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inherit_gem:

AllCops:
DisplayCopNames: true
TargetRubyVersion: 3.0
TargetRubyVersion: 3.3
Include:
- bin/console
- Gemfile
Expand Down
38 changes: 25 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ezclient.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/ezclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/ezclient/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ezclient/httprb_compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions lib/ezclient/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions spec/ezclient_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) { [] }

Expand Down Expand Up @@ -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) { [] }

Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading