Skip to content

Commit ad1a257

Browse files
committed
Modernize gem.
1 parent 8a1b0d6 commit ad1a257

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+243
-139
lines changed
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.3"
21+
bundler-cache: true
22+
23+
- name: Validate coverage
24+
timeout-minutes: 5
25+
run: bundle exec bake decode:index:coverage lib

.github/workflows/rubocop.yaml

+24
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

+4-4
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

@@ -33,8 +33,8 @@ 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:
3939
name: coverage-${{matrix.os}}-${{matrix.ruby}}
4040
path: .covered.db
@@ -50,7 +50,7 @@ jobs:
5050
ruby-version: "3.3"
5151
bundler-cache: true
5252

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

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

.rubocop.yml

+53
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
+12-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#!/usr/bin/env -S falcon serve --bind http://127.0.0.1:9001 --count 1 -c
2+
# frozen_string_literal: true
23

34
require "async/websocket/adapters/rack"
45

56
# TODO: This should probably be part of the library long-term
67
class RawConnection < Async::WebSocket::Connection
7-
def parse(buffer)
8-
buffer
9-
end
8+
def parse(buffer)
9+
buffer
10+
end
1011

11-
def dump(buffer)
12-
buffer
13-
end
12+
def dump(buffer)
13+
buffer
14+
end
1415
end
1516

1617
app = lambda do |env|
17-
Async::WebSocket::Adapters::Rack.open(env, handler: RawConnection) do |c|
18-
while message = c.read
19-
c.write(message)
20-
end
21-
end or [404, {}, []]
18+
Async::WebSocket::Adapters::Rack.open(env, handler: RawConnection) do |c|
19+
while message = c.read
20+
c.write(message)
21+
end
22+
end or [404, {}, []]
2223
end
2324

2425
run app

benchmark/mask_xor.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@ def mask_xor_string(data, mask)
2424
return result
2525
end
2626

27-
require 'benchmark/ips'
28-
require 'securerandom'
27+
require "benchmark/ips"
28+
require "securerandom"
2929

3030
MASK = SecureRandom.bytes(4)
3131
DATA = SecureRandom.bytes(1024 * 1024)
3232

3333
Benchmark.ips do |x|
34-
# Configure the number of seconds used during
35-
# the warmup phase (default 2) and calculation phase (default 5)
36-
x.config(:time => 5, :warmup => 2)
34+
# Configure the number of seconds used during
35+
# the warmup phase (default 2) and calculation phase (default 5)
36+
x.config(:time => 5, :warmup => 2)
3737

38-
# These parameters can also be configured this way
39-
x.time = 5
40-
x.warmup = 2
38+
# These parameters can also be configured this way
39+
x.time = 5
40+
x.warmup = 2
4141

4242
x.report("IO::Buffer") {mask_xor_buffer(DATA, MASK)}
4343
x.report("String") {mask_xor_string(DATA, MASK)}
4444

45-
# Compare the iterations per second of the various reports!
46-
x.compare!
45+
# Compare the iterations per second of the various reports!
46+
x.compare!
4747
end
4848

4949
# Warming up --------------------------------------

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, 2022-2023, by Samuel Williams.
55

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

fixtures/protocol/websocket/a_websocket_frame.rb

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

6-
require 'socket'
6+
require "socket"
77

88
module Protocol
99
module WebSocket
1010
AWebSocketFrame = Sus::Shared("a websocket frame") do
11-
require 'protocol/websocket/framer'
11+
require "protocol/websocket/framer"
1212

1313
let(:sockets) {Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)}
1414

gems.rb

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
group :test do
2020
gem "sus"
2121
gem "covered"
22+
gem "decode"
23+
gem "rubocop"
2224

2325
gem "sus-fixtures-async"
2426
gem "sus-fixtures-async-http"

lib/protocol/websocket.rb

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

6-
require_relative 'websocket/version'
7-
require_relative 'websocket/framer'
8-
require_relative 'websocket/connection'
9-
require_relative 'websocket/message'
6+
require_relative "websocket/version"
7+
require_relative "websocket/framer"
8+
require_relative "websocket/connection"
9+
require_relative "websocket/message"

lib/protocol/websocket/binary_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Copyright, 2019-2024, by Samuel Williams.
55
# Copyright, 2021, by Aurora Nockert.
66

7-
require_relative 'frame'
8-
require_relative 'message'
7+
require_relative "frame"
8+
require_relative "message"
99

1010
module Protocol
1111
module WebSocket

lib/protocol/websocket/close_frame.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright, 2019-2024, by Samuel Williams.
55
# Copyright, 2021, by Aurora Nockert.
66

7-
require_relative 'frame'
7+
require_relative "frame"
88

99
module Protocol
1010
module WebSocket

lib/protocol/websocket/coder.rb

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

6-
require_relative 'coder/json'
6+
require_relative "coder/json"
77

88
module Protocol
99
module WebSocket

lib/protocol/websocket/coder/json.rb

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

6-
require 'json'
6+
require "json"
77

88
module Protocol
99
module WebSocket

lib/protocol/websocket/connection.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
# Copyright, 2019, by William T. Nelson.
66
# Copyright, 2021, by Aurora Nockert.
77

8-
require_relative 'framer'
9-
require 'securerandom'
8+
require_relative "framer"
109

1110
module Protocol
1211
module WebSocket
@@ -267,7 +266,7 @@ def send_close(code = Error::NO_ERROR, reason = "")
267266
def write(message, **options)
268267
case message
269268
when String
270-
# This is a compatibility shim for the previous implementation. We may want to eventually deprecate this use case... or maybe it's convenient enough to leave it around.
269+
# This is a compatibility shim for the previous implementation. We may want to eventually deprecate this use case... or maybe it's convenient enough to leave it around.
271270
if message.encoding == Encoding::UTF_8
272271
return send_text(message, **options)
273272
else

lib/protocol/websocket/continuation_frame.rb

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

6-
require_relative 'frame'
6+
require_relative "frame"
77

88
module Protocol
99
module WebSocket

lib/protocol/websocket/error.rb

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

6-
require 'protocol/http/error'
6+
require "protocol/http/error"
77

88
module Protocol
99
module WebSocket

lib/protocol/websocket/extension/compression.rb

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

6-
require_relative 'compression/constants'
7-
require_relative 'compression/inflate'
8-
require_relative 'compression/deflate'
6+
require_relative "compression/constants"
7+
require_relative "compression/inflate"
8+
require_relative "compression/deflate"
99

1010
module Protocol
1111
module WebSocket
@@ -22,13 +22,13 @@ def self.offer(client_max_window_bits: true, server_max_window_bits: true, clien
2222
when 8..15
2323
header << "client_max_window_bits=#{client_max_window_bits}"
2424
when true
25-
header << 'client_max_window_bits'
25+
header << "client_max_window_bits"
2626
else
2727
raise ArgumentError, "Invalid local maximum window bits!"
2828
end
2929

3030
if client_no_context_takeover
31-
header << 'client_no_context_takeover'
31+
header << "client_no_context_takeover"
3232
end
3333

3434
case server_max_window_bits
@@ -41,7 +41,7 @@ def self.offer(client_max_window_bits: true, server_max_window_bits: true, clien
4141
end
4242

4343
if server_no_context_takeover
44-
header << 'server_no_context_takeover'
44+
header << "server_no_context_takeover"
4545
end
4646

4747
return header

lib/protocol/websocket/extension/compression/constants.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
# Released under the MIT License.
44
# Copyright, 2022-2023, by Samuel Williams.
55

6-
require 'zlib'
6+
require "zlib"
77

88
module Protocol
99
module WebSocket
1010
module Extension
1111
module Compression
12-
NAME = 'permessage-deflate'
12+
NAME = "permessage-deflate"
1313

1414
# Zlib is not capable of handling < 9 window bits.
1515
MINIMUM_WINDOW_BITS = 9

lib/protocol/websocket/extension/compression/deflate.rb

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

6-
require_relative 'constants'
6+
require_relative "constants"
77

88
module Protocol
99
module WebSocket

0 commit comments

Comments
 (0)