Skip to content

Commit bdab654

Browse files
committed
Modernize code.
1 parent e584d4c commit bdab654

File tree

27 files changed

+106
-72
lines changed

27 files changed

+106
-72
lines changed

.github/workflows/documentation-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1717
- uses: ruby/setup-ruby@v1
1818
with:
1919
ruby-version: ruby

.github/workflows/documentation.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ubuntu-latest
2525

2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v6
2828

2929
- uses: ruby/setup-ruby@v1
3030
with:
@@ -39,7 +39,7 @@ jobs:
3939
run: bundle exec bake utopia:project:static --force no
4040

4141
- name: Upload documentation artifact
42-
uses: actions/upload-pages-artifact@v3
42+
uses: actions/upload-pages-artifact@v4
4343
with:
4444
path: docs
4545

.github/workflows/rubocop.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1414
- uses: ruby/setup-ruby@v1
1515
with:
1616
ruby-version: ruby

.github/workflows/test-coverage.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- ruby
2424

2525
steps:
26-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v6
2727
- uses: ruby/setup-ruby@v1
2828
with:
2929
ruby-version: ${{matrix.ruby}}
@@ -33,7 +33,7 @@ jobs:
3333
timeout-minutes: 5
3434
run: bundle exec bake test
3535

36-
- uses: actions/upload-artifact@v4
36+
- uses: actions/upload-artifact@v5
3737
with:
3838
include-hidden-files: true
3939
if-no-files-found: error
@@ -45,13 +45,13 @@ jobs:
4545
runs-on: ubuntu-latest
4646

4747
steps:
48-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v6
4949
- uses: ruby/setup-ruby@v1
5050
with:
5151
ruby-version: ruby
5252
bundler-cache: true
5353

54-
- uses: actions/download-artifact@v4
54+
- uses: actions/download-artifact@v6
5555

5656
- name: Validate coverage
5757
timeout-minutes: 5

.github/workflows/test-external.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ jobs:
2020
- "3.2"
2121
- "3.3"
2222
- "3.4"
23+
- "4.0"
2324

2425
steps:
25-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v6
2627
- uses: ruby/setup-ruby@v1
2728
with:
2829
ruby-version: ${{matrix.ruby}}

.github/workflows/test.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- "3.2"
2222
- "3.3"
2323
- "3.4"
24+
- "4.0"
2425

2526
experimental: [false]
2627

@@ -36,7 +37,7 @@ jobs:
3637
experimental: true
3738

3839
steps:
39-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@v6
4041
- uses: ruby/setup-ruby@v1
4142
with:
4243
ruby-version: ${{matrix.ruby}}

.rubocop.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ plugins:
55
AllCops:
66
DisabledByDefault: true
77

8+
# Socketry specific rules:
9+
810
Layout/ConsistentBlankLineIndentation:
911
Enabled: true
1012

13+
Layout/BlockDelimiterSpacing:
14+
Enabled: true
15+
16+
Style/GlobalExceptionVariables:
17+
Enabled: true
18+
19+
# General Layout rules:
20+
1121
Layout/IndentationStyle:
1222
Enabled: true
1323
EnforcedStyle: tabs
@@ -52,6 +62,7 @@ Layout/CommentIndentation:
5262

5363
Layout/FirstHashElementIndentation:
5464
Enabled: true
65+
EnforcedStyle: consistent
5566

5667
Layout/EmptyLinesAroundClassBody:
5768
Enabled: true
@@ -71,6 +82,25 @@ Layout/SpaceAroundBlockParameters:
7182
Enabled: true
7283
EnforcedStyleInsidePipes: no_space
7384

85+
Layout/FirstArrayElementIndentation:
86+
Enabled: true
87+
EnforcedStyle: consistent
88+
89+
Layout/ArrayAlignment:
90+
Enabled: true
91+
EnforcedStyle: with_fixed_indentation
92+
93+
Layout/FirstArgumentIndentation:
94+
Enabled: true
95+
EnforcedStyle: consistent
96+
97+
Layout/ArgumentAlignment:
98+
Enabled: true
99+
EnforcedStyle: with_fixed_indentation
100+
101+
Layout/ClosingParenthesisIndentation:
102+
Enabled: true
103+
74104
Style/FrozenStringLiteralComment:
75105
Enabled: true
76106

bake.rb

Lines changed: 1 addition & 1 deletion
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, 2020-2024, by Samuel Williams.
4+
# Copyright, 2020-2026, by Samuel Williams.
55

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

examples/download/chunked.rb

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

44
# Released under the MIT License.
5-
# Copyright, 2020-2025, by Samuel Williams.
5+
# Copyright, 2020-2026, by Samuel Williams.
66

77
require "async"
88
require "async/clock"
@@ -20,7 +20,7 @@
2020
headers = {"user-agent" => "curl/7.69.1", "accept" => "*/*"}
2121

2222
file = File.open("products.csv", "w")
23-
Console.info(self) {"Saving download to #{Dir.pwd}"}
23+
Console.info(self){"Saving download to #{Dir.pwd}"}
2424

2525
begin
2626
response = client.head(endpoint.path, headers)
@@ -39,7 +39,7 @@
3939
response&.close
4040
end
4141

42-
Console.info(self) {"Content length: #{content_length/(1024**2)}MiB"}
42+
Console.info(self){"Content length: #{content_length/(1024**2)}MiB"}
4343

4444
parts = []
4545
offset = 0
@@ -56,7 +56,7 @@
5656
offset += chunk_size
5757
end
5858

59-
Console.info(self) {"Breaking download into #{parts.size} parts..."}
59+
Console.info(self){"Breaking download into #{parts.size} parts..."}
6060

6161
semaphore = Async::Semaphore.new(8)
6262
barrier = Async::Barrier.new(parent: semaphore)
@@ -65,21 +65,21 @@
6565
barrier.async do
6666
part = parts.shift
6767

68-
Console.info(self) {"Issuing range request range: bytes=#{part.min}-#{part.max}"}
68+
Console.info(self){"Issuing range request range: bytes=#{part.min}-#{part.max}"}
6969

7070
response = client.get(endpoint.path, [
7171
["range", "bytes=#{part.min}-#{part.max-1}"],
7272
*headers
7373
])
7474

7575
if response.success?
76-
Console.info(self) {"Got response: #{response}... writing data for #{part}."}
76+
Console.info(self){"Got response: #{response}... writing data for #{part}."}
7777
written = file.pwrite(response.read, part.min)
7878

7979
amount += written
8080

8181
duration = Async::Clock.now - start_time
82-
Console.info(self) {"Rate: #{((amount.to_f/(1024**2))/duration).round(2)}MiB/s"}
82+
Console.info(self){"Rate: #{((amount.to_f/(1024**2))/duration).round(2)}MiB/s"}
8383
end
8484
end
8585
end

examples/google/search.rb

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

44
# Released under the MIT License.
5-
# Copyright, 2019-2025, by Samuel Williams.
5+
# Copyright, 2019-2026, by Samuel Williams.
66

77
require "async"
88
require "async/clock"
@@ -14,7 +14,7 @@
1414

1515
class Google < Protocol::HTTP::Middleware
1616
def search(term)
17-
Console.info(self) {"Searching for #{term}..."}
17+
Console.info(self){"Searching for #{term}..."}
1818

1919
self.get("/search?q=#{term}", {"user-agent" => "Hi Google!"})
2020
end
@@ -40,10 +40,10 @@ def search(term)
4040
end
4141
end.map(&:wait).to_h
4242

43-
Console.info(self, name: "counts") {counts}
43+
Console.info(self, name: "counts"){counts}
4444
end
4545

46-
Console.info(self, name: "duration") {duration}
46+
Console.info(self, name: "duration"){duration}
4747
ensure
4848
google.close
4949
end

0 commit comments

Comments
 (0)