Skip to content

Commit

Permalink
Modernize gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Sep 11, 2024
1 parent d4da564 commit aec454a
Show file tree
Hide file tree
Showing 36 changed files with 167 additions and 174 deletions.
20 changes: 4 additions & 16 deletions .github/workflows/rubocop.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test External
name: RuboCop

on: [push, pull_request]

Expand All @@ -9,26 +9,14 @@ env:
CONSOLE_OUTPUT: XTerm

jobs:
test:
name: ${{matrix.ruby}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest

strategy:
matrix:
os:
- ubuntu
- macos

ruby:
- "3.1"
- "3.2"
- "3.3"
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
ruby-version: ruby
bundler-cache: true

- name: Run RuboCop
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Run tests
timeout-minutes: 5
run: bundle exec bake test

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: coverage-${{matrix.os}}-${{matrix.ruby}}
path: .covered.db
Expand All @@ -50,7 +50,7 @@ jobs:
ruby-version: "3.3"
bundler-cache: true

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: Validate coverage
timeout-minutes: 5
Expand Down
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: normal

Layout/BlockAlignment:
Enabled: true

Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line
Expand Down Expand Up @@ -44,3 +47,7 @@ Layout/EmptyLinesAroundModuleBody:

Style/FrozenStringLiteralComment:
Enabled: true

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
6 changes: 3 additions & 3 deletions async-websocket.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
spec.authors = ["Samuel Williams", "Simon Crocker", "Olle Jonsson", "Thomas Morgan", "Aurora Nockert", "Bryan Powell", "Emily Love Mills", "Gleb Sinyavskiy", "Janko Marohnić", "Juan Antonio Martín Lucas", "Michel Boaventura", "Peter Runich", "Ryu Sato"]
spec.license = "MIT"

spec.cert_chain = ['release.cert']
spec.signing_key = File.expand_path('~/.gem/release.pem')
spec.cert_chain = ["release.cert"]
spec.signing_key = File.expand_path("~/.gem/release.pem")

spec.homepage = "https://github.com/socketry/async-websocket"

Expand All @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
"source_code_uri" => "https://github.com/socketry/async-websocket.git",
}

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

spec.required_ruby_version = ">= 3.1"

Expand Down
4 changes: 2 additions & 2 deletions config/sus.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2022, by Samuel Williams.
# Copyright, 2022-2024, by Samuel Williams.

require 'covered/sus'
require "covered/sus"
include Covered::Sus
6 changes: 3 additions & 3 deletions examples/binance/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.

require 'async'
require 'async/http'
require 'async/websocket'
require "async"
require "async/http"
require "async/websocket"

URL = "wss://stream.binance.com:9443/ws/btcusdt@bookTicker"

Expand Down
6 changes: 3 additions & 3 deletions examples/chat/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.

require 'async'
require 'async/http/endpoint'
require_relative '../../lib/async/websocket/client'
require "async"
require "async/http/endpoint"
require_relative "../../lib/async/websocket/client"

USER = ARGV.pop || "anonymous"
URL = ARGV.pop || "https://localhost:8080"
Expand Down
10 changes: 5 additions & 5 deletions examples/chat/config.ru
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env -S falcon serve --bind https://localhost:8080 --count 1 -c
# frozen_string_literal: true

require_relative '../../lib/async/websocket/adapters/rack'
require 'async/clock'
require 'async/semaphore'
require_relative "../../lib/async/websocket/adapters/rack"
require "async/clock"
require "async/semaphore"

require 'set'
require "set"

# GC.disable

Expand Down Expand Up @@ -70,7 +70,7 @@ class Room
end

def start_profile
require 'ruby-prof' unless defined?(RubyProf)
require "ruby-prof" unless defined?(RubyProf)

return false if @profile

Expand Down
12 changes: 6 additions & 6 deletions examples/chat/multi-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require 'async'
require 'async/semaphore'
require 'async/clock'
require 'async/http/endpoint'
require_relative '../../lib/async/websocket/client'
require "async"
require "async/semaphore"
require "async/clock"
require "async/http/endpoint"
require_relative "../../lib/async/websocket/client"

require 'samovar'
require "samovar"

# GC.disable
GC::Profiler.enable
Expand Down
6 changes: 3 additions & 3 deletions examples/mud/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2020, by Juan Antonio Martín Lucas.

require 'async'
require 'async/http/endpoint'
require 'async/websocket/client'
require "async"
require "async/http/endpoint"
require "async/websocket/client"

USER = ARGV.pop || "anonymous"
URL = ARGV.pop || "http://127.0.0.1:7070"
Expand Down
2 changes: 1 addition & 1 deletion examples/mud/config.ru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S falcon serve --count 1 --bind http://127.0.0.1:7070 -c
# frozen_string_literal: true

require 'async/websocket/adapters/rack'
require "async/websocket/adapters/rack"

class Room
def initialize(name, description = nil)
Expand Down
6 changes: 3 additions & 3 deletions examples/rack/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require 'async'
require 'async/http/endpoint'
require 'async/websocket/client'
require "async"
require "async/http/endpoint"
require "async/websocket/client"

URL = ARGV.pop || "http://127.0.0.1:7070"

Expand Down
2 changes: 1 addition & 1 deletion examples/rack/config.ru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S falcon serve --bind http://127.0.0.1:7070 --count 1 -c
# frozen_string_literal: true

require 'async/websocket/adapters/rack'
require "async/websocket/adapters/rack"

app = lambda do |env|
response = Async::WebSocket::Adapters::Rack.open(env) do |connection|
Expand Down
6 changes: 3 additions & 3 deletions fixtures/async/websocket/rack_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
# Released under the MIT License.
# Copyright, 2022-2024, by Samuel Williams.

require 'sus/fixtures/async/http/server_context'
require 'protocol/rack/adapter'
require "sus/fixtures/async/http/server_context"
require "protocol/rack/adapter"

module Async
module WebSocket
module RackApplication
include Sus::Fixtures::Async::HTTP::ServerContext

def builder
Rack::Builder.parse_file(File.expand_path('rack_application/config.ru', __dir__))
Rack::Builder.parse_file(File.expand_path("rack_application/config.ru", __dir__))
end

def app
Expand Down
6 changes: 3 additions & 3 deletions fixtures/async/websocket/rack_application/config.ru
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env -S falcon serve --bind http://localhost:7070 --count 1 -c
# frozen_string_literal: true

require 'async/websocket/adapters/rack'
require 'set'
require "async/websocket/adapters/rack"
require "set"

$connections = Set.new

Expand All @@ -26,7 +26,7 @@ end
use ClosedLogger

run do |env|
Async::WebSocket::Adapters::Rack.open(env, protocols: ['ws']) do |connection|
Async::WebSocket::Adapters::Rack.open(env, protocols: ["ws"]) do |connection|
$connections << connection

begin
Expand Down
2 changes: 1 addition & 1 deletion gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2015-2024, by Samuel Williams.

source 'https://rubygems.org'
source "https://rubygems.org"

gemspec

Expand Down
8 changes: 4 additions & 4 deletions lib/async/websocket.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2015-2023, by Samuel Williams.
# Copyright, 2015-2024, by Samuel Williams.

require_relative 'websocket/version'
require_relative 'websocket/server'
require_relative 'websocket/client'
require_relative "websocket/version"
require_relative "websocket/server"
require_relative "websocket/client"
8 changes: 4 additions & 4 deletions lib/async/websocket/adapters/http.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2021-2023, by Samuel Williams.
# Copyright, 2021-2024, by Samuel Williams.
# Copyright, 2021, by Aurora Nockert.

require_relative '../connection'
require_relative '../response'
require_relative "../connection"
require_relative "../response"

require 'protocol/websocket/extensions'
require "protocol/websocket/extensions"

module Async
module WebSocket
Expand Down
8 changes: 4 additions & 4 deletions lib/async/websocket/adapters/rack.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019-2022, by Samuel Williams.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'http'
require 'protocol/rack/request'
require 'protocol/rack/adapter'
require_relative "http"
require "protocol/rack/request"
require "protocol/rack/adapter"

module Async
module WebSocket
Expand Down
4 changes: 2 additions & 2 deletions lib/async/websocket/adapters/rails.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2021-2023, by Samuel Williams.
# Copyright, 2021-2024, by Samuel Williams.
# Copyright, 2023, by Emily Love Mills.

require_relative 'rack'
require_relative "rack"

module Async
module WebSocket
Expand Down
14 changes: 7 additions & 7 deletions lib/async/websocket/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
# Copyright, 2019, by Janko Marohnić.
# Copyright, 2023, by Thomas Morgan.

require_relative 'request'
require_relative 'connection'
require_relative "request"
require_relative "connection"

require 'protocol/websocket/headers'
require 'protocol/websocket/extensions'
require 'protocol/http/middleware'
require "protocol/websocket/headers"
require "protocol/websocket/extensions"
require "protocol/http/middleware"

require 'async/http/client'
require "async/http/client"

require 'delegate'
require "delegate"

module Async
module WebSocket
Expand Down
14 changes: 7 additions & 7 deletions lib/async/websocket/connect_request.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2023, by Thomas Morgan.

require 'protocol/http/request'
require 'protocol/http/headers'
require 'protocol/websocket/headers'
require 'protocol/http/body/readable'
require "protocol/http/request"
require "protocol/http/headers"
require "protocol/websocket/headers"
require "protocol/http/body/readable"

require 'async/variable'
require "async/variable"

module Async
module WebSocket
Expand Down Expand Up @@ -75,7 +75,7 @@ def initialize(request, protocols: [], version: 13, &block)
headers.add(SEC_WEBSOCKET_VERSION, String(version))

if protocols.any?
headers.add(SEC_WEBSOCKET_PROTOCOL, protocols.join(','))
headers.add(SEC_WEBSOCKET_PROTOCOL, protocols.join(","))
end

super(request.scheme, request.authority, ::Protocol::HTTP::Methods::CONNECT, request.path, nil, headers, body, PROTOCOL)
Expand Down
6 changes: 3 additions & 3 deletions lib/async/websocket/connect_response.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.
# Copyright, 2019-2024, by Samuel Williams.

require 'protocol/http/response'
require 'async/http/body/hijack'
require "protocol/http/response"
require "async/http/body/hijack"

module Async
module WebSocket
Expand Down
Loading

0 comments on commit aec454a

Please sign in to comment.