Skip to content

Commit

Permalink
Modernize gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Sep 17, 2024
1 parent fd5a7e5 commit 1c63676
Show file tree
Hide file tree
Showing 76 changed files with 573 additions and 569 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ Layout/EmptyLinesAroundModuleBody:

Style/FrozenStringLiteralComment:
Enabled: true

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
4 changes: 2 additions & 2 deletions bake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#
# @parameter version [String] The new version number.
def after_gem_release_version_increment(version)
context['releases:update'].call(version)
context['utopia:project:readme:update'].call
context["releases:update"].call(version)
context["utopia:project:readme:update"].call
end
2 changes: 1 addition & 1 deletion benchmark/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def consumer_with_clear
return nil
end

require 'benchmark'
require "benchmark"

Benchmark.bm do |x|
x.report("consumer_with_clear") do
Expand Down
2 changes: 1 addition & 1 deletion config/sus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.

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

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

require 'protocol/http/body/streamable'
require 'protocol/http/body/writable'
require 'protocol/http/body/stream'
require "protocol/http/body/streamable"
require "protocol/http/body/writable"
require "protocol/http/body/stream"

endpoint = Async::HTTP::Endpoint.parse('http://localhost:3000')
endpoint = Async::HTTP::Endpoint.parse("http://localhost:3000")

Async do
server = Async::HTTP::Server.for(endpoint) do |request|
Expand Down
16 changes: 8 additions & 8 deletions examples/streaming/bidirectional2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

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

require 'protocol/http/body/streamable'
require 'protocol/http/body/writable'
require 'protocol/http/body/stream'
require "protocol/http/body/streamable"
require "protocol/http/body/writable"
require "protocol/http/body/stream"

endpoint = Async::HTTP::Endpoint.parse('http://localhost:3000')
endpoint = Async::HTTP::Endpoint.parse("http://localhost:3000")

Async do
server = Async::HTTP::Server.for(endpoint) do |request|
Expand Down
16 changes: 8 additions & 8 deletions examples/streaming/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

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

require 'protocol/http/body/streamable'
require 'protocol/http/body/writable'
require 'protocol/http/body/stream'
require "protocol/http/body/streamable"
require "protocol/http/body/writable"
require "protocol/http/body/stream"

endpoint = Async::HTTP::Endpoint.parse('http://localhost:3000')
endpoint = Async::HTTP::Endpoint.parse("http://localhost:3000")

Async do
server = Async::HTTP::Server.for(endpoint) do |request|
Expand Down
14 changes: 7 additions & 7 deletions examples/streaming/unidirectional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

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

require 'protocol/http/body/stream'
require 'protocol/http/body/writable'
require "protocol/http/body/stream"
require "protocol/http/body/writable"

endpoint = Async::HTTP::Endpoint.parse('http://localhost:3000')
endpoint = Async::HTTP::Endpoint.parse("http://localhost:3000")

Async do
server = Async::HTTP::Server.for(endpoint) do |request|
Expand Down
14 changes: 7 additions & 7 deletions examples/streaming/unidirectional2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

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

require 'protocol/http/body/stream'
require 'protocol/http/body/writable'
require "protocol/http/body/stream"
require "protocol/http/body/writable"

def make_server(endpoint)
Async::HTTP::Server.for(endpoint) do |request|
Expand Down Expand Up @@ -39,7 +39,7 @@ def make_server(endpoint)
end

Async do |task|
endpoint = Async::HTTP::Endpoint.parse('http://localhost:3000')
endpoint = Async::HTTP::Endpoint.parse("http://localhost:3000")

server_task = task.async{make_server(endpoint).run}

Expand Down
8 changes: 4 additions & 4 deletions lib/protocol/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

require_relative "http/version"

require_relative 'http/headers'
require_relative 'http/request'
require_relative 'http/response'
require_relative 'http/middleware'
require_relative "http/headers"
require_relative "http/request"
require_relative "http/response"
require_relative "http/middleware"

# @namespace
module Protocol
Expand Down
14 changes: 7 additions & 7 deletions lib/protocol/http/accept_encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.

require_relative 'middleware'
require_relative "middleware"

require_relative 'body/buffered'
require_relative 'body/inflate'
require_relative "body/buffered"
require_relative "body/inflate"

module Protocol
module HTTP
# Set a valid accept-encoding header and decode the response.
class AcceptEncoding < Middleware
ACCEPT_ENCODING = 'accept-encoding'.freeze
CONTENT_ENCODING = 'content-encoding'.freeze
ACCEPT_ENCODING = "accept-encoding".freeze
CONTENT_ENCODING = "content-encoding".freeze

DEFAULT_WRAPPERS = {
'gzip' => Body::Inflate.method(:for),
"gzip" => Body::Inflate.method(:for),

# There is no point including this:
# 'identity' => ->(body){body},
Expand All @@ -25,7 +25,7 @@ class AcceptEncoding < Middleware
def initialize(app, wrappers = DEFAULT_WRAPPERS)
super(app)

@accept_encoding = wrappers.keys.join(', ')
@accept_encoding = wrappers.keys.join(", ")
@wrappers = wrappers
end

Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/http/body/buffered.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2020, by Bryan Powell.

require_relative 'readable'
require_relative "readable"

module Protocol
module HTTP
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/http/body/completable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'wrapper'
require_relative "wrapper"

module Protocol
module HTTP
Expand Down
8 changes: 4 additions & 4 deletions lib/protocol/http/body/deflate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'wrapper'
require_relative "wrapper"

require 'zlib'
require "zlib"

module Protocol
module HTTP
Expand All @@ -17,8 +17,8 @@ class ZStream < Wrapper
GZIP = Zlib::MAX_WBITS | 16

ENCODINGS = {
'deflate' => DEFLATE,
'gzip' => GZIP,
"deflate" => DEFLATE,
"gzip" => GZIP,
}

def initialize(body, stream)
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/http/body/digestable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Released under the MIT License.
# Copyright, 2020-2024, by Samuel Williams.

require_relative 'wrapper'
require_relative "wrapper"

require 'digest/sha2'
require "digest/sha2"

module Protocol
module HTTP
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/http/body/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'readable'
require_relative "readable"

module Protocol
module HTTP
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/http/body/head.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2020-2023, by Samuel Williams.

require_relative 'readable'
require_relative "readable"

module Protocol
module HTTP
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/http/body/inflate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require 'zlib'
require "zlib"

require_relative 'deflate'
require_relative "deflate"

module Protocol
module HTTP
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/http/body/rewindable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'wrapper'
require_relative 'buffered'
require_relative "wrapper"
require_relative "buffered"

module Protocol
module HTTP
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/http/body/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2023, by Genki Takiuchi.

require_relative 'buffered'
require_relative "buffered"

module Protocol
module HTTP
Expand Down Expand Up @@ -43,7 +43,7 @@ module Reader
# @param buffer [String] the buffer which will receive the data
# @return a buffer containing the data
def read(length = nil, buffer = nil)
return '' if length == 0
return "" if length == 0

buffer ||= String.new.force_encoding(Encoding::BINARY)

Expand Down
6 changes: 3 additions & 3 deletions lib/protocol/http/body/streamable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'readable'
require_relative 'writable'
require_relative "readable"
require_relative "writable"

require_relative 'stream'
require_relative "stream"

module Protocol
module HTTP
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/http/body/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'readable'
require_relative "readable"

module Protocol
module HTTP
Expand Down
10 changes: 5 additions & 5 deletions lib/protocol/http/body/writable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

require_relative 'readable'
require_relative "readable"

module Protocol
module HTTP
Expand Down Expand Up @@ -137,15 +137,15 @@ def inspect
def status
if @queue.empty?
if @queue.closed?
'closed'
"closed"
else
'waiting'
"waiting"
end
else
if @queue.closed?
'closing'
"closing"
else
'ready'
"ready"
end
end
end
Expand Down
Loading

0 comments on commit 1c63676

Please sign in to comment.