Skip to content

Commit 077624a

Browse files
committed
Modernize code.
1 parent 42578fa commit 077624a

19 files changed

+92
-81
lines changed

.github/workflows/documentation-coverage.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- uses: ruby/setup-ruby@v1
1919
with:
20-
ruby-version: "3.3"
20+
ruby-version: "3.4"
2121
bundler-cache: true
2222

2323
- name: Validate coverage

.github/workflows/documentation.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- uses: ruby/setup-ruby@v1
3131
with:
32-
ruby-version: "3.3"
32+
ruby-version: "3.4"
3333
bundler-cache: true
3434

3535
- name: Installing packages

.github/workflows/test-coverage.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- macos
2222

2323
ruby:
24-
- "3.3"
24+
- "3.4"
2525

2626
steps:
2727
- uses: actions/checkout@v4
@@ -34,8 +34,10 @@ jobs:
3434
timeout-minutes: 5
3535
run: bundle exec bake test
3636

37-
- uses: actions/upload-artifact@v3
37+
- uses: actions/upload-artifact@v4
3838
with:
39+
include-hidden-files: true
40+
if-no-files-found: error
3941
name: coverage-${{matrix.os}}-${{matrix.ruby}}
4042
path: .covered.db
4143

@@ -47,10 +49,10 @@ jobs:
4749
- uses: actions/checkout@v4
4850
- uses: ruby/setup-ruby@v1
4951
with:
50-
ruby-version: "3.3"
52+
ruby-version: "3.4"
5153
bundler-cache: true
5254

53-
- uses: actions/download-artifact@v3
55+
- uses: actions/download-artifact@v4
5456

5557
- name: Validate coverage
5658
timeout-minutes: 5

.github/workflows/test-external.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- "3.1"
2424
- "3.2"
2525
- "3.3"
26+
- "3.4"
2627

2728
steps:
2829
- uses: actions/checkout@v4

.github/workflows/test.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- "3.1"
2525
- "3.2"
2626
- "3.3"
27+
- "3.4"
2728

2829
experimental: [false]
2930

.rubocop.yml

+4
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ Layout/EmptyLinesAroundModuleBody:
4747

4848
Style/FrozenStringLiteralComment:
4949
Enabled: true
50+
51+
Style/StringLiterals:
52+
Enabled: true
53+
EnforcedStyle: double_quotes

async-http-faraday.gemspec

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
77
spec.version = Async::HTTP::Faraday::VERSION
88

99
spec.summary = "Provides an adaptor between async-http and faraday."
10-
spec.authors = ["Samuel Williams", "Igor Sidorov", "Andreas Garnaes", "Genki Takiuchi", "Olle Jonsson", "Benoit Daloze", "Denis Talakevich", "Flavio Fernandes", "Jacob Frautschi"]
10+
spec.authors = ["Samuel Williams", "Igor Sidorov", "Andreas Garnaes", "Genki Takiuchi", "Nikolaos Anastopoulos", "Olle Jonsson", "Benoit Daloze", "Denis Talakevich", "Flavio Fernandes", "Jacob Frautschi"]
1111
spec.license = "MIT"
1212

13-
spec.cert_chain = ['release.cert']
14-
spec.signing_key = File.expand_path('~/.gem/release.pem')
13+
spec.cert_chain = ["release.cert"]
14+
spec.signing_key = File.expand_path("~/.gem/release.pem")
1515

1616
spec.homepage = "https://github.com/socketry/async-http-faraday"
1717

@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
2121
"source_code_uri" => "https://github.com/socketry/async-http.git",
2222
}
2323

24-
spec.files = Dir.glob(['{examples,lib}/**/*', '*.md'], File::FNM_DOTMATCH, base: __dir__)
24+
spec.files = Dir.glob(["{examples,lib}/**/*", "*.md"], File::FNM_DOTMATCH, base: __dir__)
2525

2626
spec.required_ruby_version = ">= 3.1"
2727

bake.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2025, by Samuel Williams.
4+
# Copyright, 2024-2025, by Samuel Williams.
55

66
# Update the project documentation with the new version number.
77
#

config/sus.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Released under the MIT License.
44
# Copyright, 2024, by Samuel Williams.
55

6-
require 'covered/sus'
6+
require "covered/sus"
77
include Covered::Sus

examples/topics.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
88

9-
require 'async'
10-
require 'faraday'
11-
require 'async/http/faraday'
9+
require "async"
10+
require "faraday"
11+
require "async/http/faraday"
1212

1313
# Async.logger.debug!
1414

1515
module TestAsync
16-
URL = 'https://www.google.com/search'
16+
URL = "https://www.google.com/search"
1717
TOPICS = %W{ruby python lisp javascript cobol}
1818

1919
def self.fetch_topics_async

gems.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Released under the MIT License.
44
# Copyright, 2018-2024, by Samuel Williams.
55

6-
source 'https://rubygems.org'
6+
source "https://rubygems.org"
77

88
gemspec
99

lib/async/http/faraday/adapter.rb

+14-13
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
# Copyright, 2023, by Genki Takiuchi.
99
# Copyright, 2023, by Flavio Fernandes.
1010
# Copyright, 2024, by Jacob Frautschi.
11+
# Copyright, 2025, by Nikolaos Anastopoulos.
1112

12-
require 'faraday'
13-
require 'faraday/adapter'
13+
require "faraday"
14+
require "faraday/adapter"
1415

15-
require 'async/barrier'
16-
require 'kernel/sync'
16+
require "async/barrier"
17+
require "kernel/sync"
1718

18-
require 'async/http/client'
19-
require 'async/http/proxy'
19+
require "async/http/client"
20+
require "async/http/proxy"
2021

21-
require_relative 'clients'
22+
require_relative "clients"
2223

2324
module Async
2425
module HTTP
@@ -136,7 +137,7 @@ def call(env)
136137
super
137138

138139
# For compatibility with the default adapter:
139-
env.url.path = '/' if env.url.path.empty?
140+
env.url.path = "/" if env.url.path.empty?
140141

141142
if parallel_manager = env.parallel_manager
142143
parallel_manager.async do
@@ -234,11 +235,11 @@ def with_timeout(task: Async::Task.current)
234235

235236
def encoded_body(response)
236237
body = response.read
237-
return +'' if body.nil?
238-
content_type = response.headers['content-type']
238+
return +"" if body.nil?
239+
content_type = response.headers["content-type"]
239240
return body unless content_type
240241
params = extract_type_parameters(content_type)
241-
if charset = params['charset']
242+
if charset = params["charset"]
242243
body = body.dup if body.frozen?
243244
body.force_encoding(charset)
244245
end
@@ -249,10 +250,10 @@ def encoded_body(response)
249250

250251
def extract_type_parameters(content_type)
251252
result = {}
252-
list = content_type.split(';')
253+
list = content_type.split(";")
253254
list.shift
254255
list.each do |param|
255-
key, value = *param.split('=', 2)
256+
key, value = *param.split("=", 2)
256257
result[key.strip] = value.strip
257258
end
258259
result

lib/async/http/faraday/clients.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Released under the MIT License.
44
# Copyright, 2024, by Samuel Williams.
55

6-
require 'faraday'
7-
require 'faraday/adapter'
8-
require 'kernel/sync'
6+
require "faraday"
7+
require "faraday/adapter"
8+
require "kernel/sync"
99

10-
require 'async/http/client'
11-
require 'async/http/proxy'
10+
require "async/http/client"
11+
require "async/http/proxy"
1212

1313
module Async
1414
module HTTP

lib/async/http/faraday/default.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Released under the MIT License.
44
# Copyright, 2020-2024, by Samuel Williams.
55

6-
require_relative 'adapter'
6+
require_relative "adapter"
77

88
# Set the default adapter to use Async::HTTP.
99
::Faraday.default_adapter = :async_http

license.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright, 2018-2024, by Samuel Williams.
3+
Copyright, 2018-2025, by Samuel Williams.
44
Copyright, 2018, by Andreas Garnaes.
55
Copyright, 2019, by Denis Talakevich.
66
Copyright, 2019-2020, by Igor Sidorov.
@@ -9,6 +9,7 @@ Copyright, 2020, by Benoit Daloze.
99
Copyright, 2023, by Genki Takiuchi.
1010
Copyright, 2023, by Flavio Fernandes.
1111
Copyright, 2024, by Jacob Frautschi.
12+
Copyright, 2025, by Nikolaos Anastopoulos.
1213

1314
Permission is hereby granted, free of charge, to any person obtaining a copy
1415
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)