Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8242115

Browse files
committedApr 9, 2025··
Modernize code.
1 parent 7ddc47f commit 8242115

20 files changed

+179
-71
lines changed
 
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Documentation Coverage
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
env:
9+
CONSOLE_OUTPUT: XTerm
10+
COVERAGE: PartialSummary
11+
12+
jobs:
13+
validate:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: "3.4"
21+
bundler-cache: true
22+
23+
- name: Validate coverage
24+
timeout-minutes: 5
25+
run: bundle exec bake decode:index:coverage lib

‎.github/workflows/documentation.yaml

Lines changed: 1 addition & 1 deletion
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/rubocop.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: RuboCop
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
env:
9+
CONSOLE_OUTPUT: XTerm
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: ruby
20+
bundler-cache: true
21+
22+
- name: Run RuboCop
23+
timeout-minutes: 10
24+
run: bundle exec rubocop

‎.github/workflows/coverage.yaml renamed to ‎.github/workflows/test-coverage.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Coverage
1+
name: Test Coverage
22

33
on: [push, pull_request]
44

@@ -21,7 +21,7 @@ jobs:
2121
- macos
2222

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

2626
steps:
2727
- uses: actions/checkout@v4
@@ -33,9 +33,11 @@ jobs:
3333
- name: Run tests
3434
timeout-minutes: 5
3535
run: bundle exec bake test
36-
37-
- uses: actions/upload-artifact@v3
36+
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
AllCops:
2+
DisabledByDefault: true
3+
4+
Layout/IndentationStyle:
5+
Enabled: true
6+
EnforcedStyle: tabs
7+
8+
Layout/InitialIndentation:
9+
Enabled: true
10+
11+
Layout/IndentationWidth:
12+
Enabled: true
13+
Width: 1
14+
15+
Layout/IndentationConsistency:
16+
Enabled: true
17+
EnforcedStyle: normal
18+
19+
Layout/BlockAlignment:
20+
Enabled: true
21+
22+
Layout/EndAlignment:
23+
Enabled: true
24+
EnforcedStyleAlignWith: start_of_line
25+
26+
Layout/BeginEndAlignment:
27+
Enabled: true
28+
EnforcedStyleAlignWith: start_of_line
29+
30+
Layout/ElseAlignment:
31+
Enabled: true
32+
33+
Layout/DefEndAlignment:
34+
Enabled: true
35+
36+
Layout/CaseIndentation:
37+
Enabled: true
38+
39+
Layout/CommentIndentation:
40+
Enabled: true
41+
42+
Layout/EmptyLinesAroundClassBody:
43+
Enabled: true
44+
45+
Layout/EmptyLinesAroundModuleBody:
46+
Enabled: true
47+
48+
Style/FrozenStringLiteralComment:
49+
Enabled: true
50+
51+
Style/StringLiterals:
52+
Enabled: true
53+
EnforcedStyle: double_quotes

‎async-await.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ Gem::Specification.new do |spec|
1010
spec.authors = ["Samuel Williams", "Kent 'picat' Gruber", "Olle Jonsson"]
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-await"
1717

1818
spec.metadata = {
1919
"source_code_uri" => "https://github.com/socketry/async-await.git",
2020
}
2121

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

2424
spec.required_ruby_version = ">= 3.1"
2525

‎config/sus.rb

Lines changed: 2 additions & 2 deletions
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, 2024, by Samuel Williams.
4+
# Copyright, 2024-2025, by Samuel Williams.
55

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

‎examples/chickens.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# frozen_string_literal: true
22

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

6-
require_relative '../lib/async/await'
6+
require_relative "../lib/async/await"
77

88
class Coop
99
include Async::Await

‎examples/echo.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# frozen_string_literal: true
22

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

6-
require_relative '../lib/async/await'
6+
require_relative "../lib/async/await"
77

8-
require 'async/io'
9-
require 'async/io/tcp_socket'
8+
require "async/io"
9+
require "async/io/tcp_socket"
1010

11-
require 'pry'
11+
require "pry"
1212

1313
class Echo
1414
include Async::Await

‎examples/port_scanner/port_scanner.rb

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@
33

44
# Released under the MIT License.
55
# Copyright, 2018, by Kent 'picat' Gruber.
6-
# Copyright, 2018-2024, by Samuel Williams.
6+
# Copyright, 2018-2025, by Samuel Williams.
77

8-
require 'async/io'
9-
require 'async/semaphore'
10-
require_relative '../../lib/async/await'
8+
require "async/io"
9+
require "async/semaphore"
10+
require_relative "../../lib/async/await"
1111

1212
class PortScanner
13-
include Async::Await
14-
include Async::IO
15-
16-
def initialize(host: '0.0.0.0', ports:, batch_size: 1024)
17-
@host = host
18-
@ports = ports
19-
@semaphore = Async::Semaphore.new(batch_size)
20-
end
21-
22-
def scan_port(port, timeout)
23-
with_timeout(timeout) do
24-
address = Async::IO::Address.tcp(@host, port)
25-
peer = Socket.connect(address)
26-
puts "#{port} open"
27-
peer.close
28-
end
29-
rescue Errno::ECONNREFUSED
30-
# puts "#{port} closed"
31-
rescue Async::TimeoutError
32-
puts "#{port} timeout"
33-
end
34-
35-
async def start(timeout = 1.0)
36-
@ports.map do |port|
37-
@semaphore.async do
38-
scan_port(port, timeout)
39-
end
40-
end.collect(&:result)
41-
end
13+
include Async::Await
14+
include Async::IO
15+
16+
def initialize(host: "0.0.0.0", ports:, batch_size: 1024)
17+
@host = host
18+
@ports = ports
19+
@semaphore = Async::Semaphore.new(batch_size)
20+
end
21+
22+
def scan_port(port, timeout)
23+
with_timeout(timeout) do
24+
address = Async::IO::Address.tcp(@host, port)
25+
peer = Socket.connect(address)
26+
puts "#{port} open"
27+
peer.close
28+
end
29+
rescue Errno::ECONNREFUSED
30+
# puts "#{port} closed"
31+
rescue Async::TimeoutError
32+
puts "#{port} timeout"
33+
end
34+
35+
async def start(timeout = 1.0)
36+
@ports.map do |port|
37+
@semaphore.async do
38+
scan_port(port, timeout)
39+
end
40+
end.collect(&:result)
41+
end
4242
end
4343

4444
limits = Process.getrlimit(Process::RLIMIT_NOFILE)

‎examples/sleep_sort.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# frozen_string_literal: true
22

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

6-
require_relative '../lib/async/await'
6+
require_relative "../lib/async/await"
77

88
class << self
99
include Async::Await

‎gems.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# frozen_string_literal: true
22

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

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

88
gemspec
99

@@ -15,6 +15,8 @@
1515
group :test do
1616
gem "sus"
1717
gem "covered"
18+
gem "decode"
19+
gem "rubocop"
1820

1921
gem "bake-test"
2022
gem "bake-test-external"

‎lib/async/await.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# frozen_string_literal: true
22

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

6-
require_relative 'await/version'
6+
require_relative "await/version"
77

88
module Async
99
module Await

‎lib/async/await/enumerable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# frozen_string_literal: true
22

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

6-
require 'async'
6+
require "async"
77

88
module Async
99
module Await

‎license.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright, 2017-2024, by Samuel Williams.
3+
Copyright, 2017-2025, by Samuel Williams.
44
Copyright, 2018, by Kent 'picat' Gruber.
55
Copyright, 2020, by Olle Jonsson.
66

‎readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ We welcome contributions to this project.
5454

5555
### Developer Certificate of Origin
5656

57-
This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
57+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
5858

59-
### Contributor Covenant
59+
### Community Guidelines
6060

61-
This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
61+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.

‎test/async/await.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# frozen_string_literal: true
22

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

6-
require 'async/await'
6+
require "async/await"
77

88
class Coop
99
include Async::Await
@@ -43,7 +43,7 @@ class Coop
4343
end
4444
end
4545

46-
with '#await' do
46+
with "#await" do
4747

4848
end
4949
end

‎test/async/await/enumerable.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# frozen_string_literal: true
22

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

6-
require 'async/await/enumerable'
6+
require "async/await/enumerable"
77

88
describe Async::Await::Enumerable do
9-
with '#async_map' do
9+
with "#async_map" do
1010
it "should map values" do
1111
result = [1, 2, 3].async_map do |value|
1212
value * 2
@@ -24,7 +24,7 @@
2424
end
2525
end
2626

27-
with '#async_each' do
27+
with "#async_each" do
2828
it "should iterate over values" do
2929
result = []
3030

0 commit comments

Comments
 (0)
Please sign in to comment.