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 6c06685 commit bf18c8b
Show file tree
Hide file tree
Showing 55 changed files with 333 additions and 227 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/documentation-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Documentation Coverage

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm
COVERAGE: PartialSummary

jobs:
validate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true

- name: Validate coverage
timeout-minutes: 5
run: bundle exec bake decode:index:coverage lib
24 changes: 24 additions & 0 deletions .github/workflows/rubocop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: RuboCop

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true

- name: Run RuboCop
timeout-minutes: 10
run: bundle exec rubocop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Coverage
name: Test Coverage

on: [push, pull_request]

Expand Down Expand Up @@ -33,9 +33,11 @@ jobs:
- name: Run tests
timeout-minutes: 5
run: bundle exec bake test

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
include-hidden-files: true
if-no-files-found: error
name: coverage-${{matrix.os}}-${{matrix.ruby}}
path: .covered.db

Expand All @@ -50,7 +52,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
53 changes: 53 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
AllCops:
DisabledByDefault: true

Layout/IndentationStyle:
Enabled: true
EnforcedStyle: tabs

Layout/InitialIndentation:
Enabled: true

Layout/IndentationWidth:
Enabled: true
Width: 1

Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: normal

Layout/BlockAlignment:
Enabled: true

Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/BeginEndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/ElseAlignment:
Enabled: true

Layout/DefEndAlignment:
Enabled: true

Layout/CaseIndentation:
Enabled: true

Layout/CommentIndentation:
Enabled: true

Layout/EmptyLinesAroundClassBody:
Enabled: true

Layout/EmptyLinesAroundModuleBody:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
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, 2023, by Samuel Williams.
# Copyright, 2023-2024, by Samuel Williams.

require 'covered/sus'
require "covered/sus"
include Covered::Sus
10 changes: 5 additions & 5 deletions examples/http2/request.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

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

$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)

require 'async'
require 'async/io/stream'
require 'async/http/endpoint'
require 'protocol/http2/client'
require "async"
require "async/io/stream"
require "async/http/endpoint"
require "protocol/http2/client"

Async do
endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
Expand Down
10 changes: 5 additions & 5 deletions examples/http2/requests.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

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

$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)

require 'async'
require 'async/io/stream'
require 'async/http/endpoint'
require 'protocol/http2/client'
require "async"
require "async/io/stream"
require "async/http/endpoint"
require "protocol/http2/client"

queries = ["apple", "orange", "teapot", "async"]

Expand Down
4 changes: 2 additions & 2 deletions fixtures/protocol/http2/a_frame.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

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

require 'protocol/http2/framer'
require "protocol/http2/framer"

module Protocol
module HTTP2
Expand Down
10 changes: 5 additions & 5 deletions fixtures/protocol/http2/connection_context.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, 2019-2023, by Samuel Williams.
# Copyright, 2019-2024, by Samuel Williams.

require 'protocol/http2/client'
require 'protocol/http2/server'
require 'protocol/http2/stream'
require "protocol/http2/client"
require "protocol/http2/server"
require "protocol/http2/stream"

require 'socket'
require "socket"

module Protocol
module HTTP2
Expand Down
4 changes: 2 additions & 2 deletions fuzz/framer/bake.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, 2020-2023, by Samuel Williams.
# Copyright, 2020-2024, by Samuel Williams.

# Run the fuzz test.
def run
system("AFL_SKIP_BIN_CHECK=1 afl-fuzz -i input/ -o output/ -m 100 -- ruby script.rb")
end

def generate
require_relative '../../lib/protocol/http2/framer'
require_relative "../../lib/protocol/http2/framer"

framer = Protocol::HTTP2::Framer.new($stdout)

Expand Down
10 changes: 5 additions & 5 deletions fuzz/framer/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# frozen_string_literal: true

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

require 'socket'
require_relative '../../lib/protocol/http2/framer'
require "socket"
require_relative "../../lib/protocol/http2/framer"

def test
framer = Protocol::HTTP2::Framer.new($stdin)
Expand All @@ -18,9 +18,9 @@ def test
end

if ENV["_"] =~ /afl/
require 'kisaten'
require "kisaten"

Kisaten.crash_at [Exception], [EOFError, Protocol::HTTP2::FrameSizeError, Protocol::HTTP2::ProtocolError], Signal.list['USR1']
Kisaten.crash_at [Exception], [EOFError, Protocol::HTTP2::FrameSizeError, Protocol::HTTP2::ProtocolError], Signal.list["USR1"]

while Kisaten.loop 10_000
test
Expand Down
4 changes: 3 additions & 1 deletion gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
end

group "test" do
gem "covered"
gem "sus"
gem "covered"
gem "decode"
gem "rubocop"

gem "bake-test"
gem "bake-test-external"
Expand Down
6 changes: 3 additions & 3 deletions lib/protocol/http2.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, 2019-2023, by Samuel Williams.
# Copyright, 2019-2024, by Samuel Williams.

require_relative 'http2/version'
require_relative 'http2/connection'
require_relative "http2/version"
require_relative "http2/connection"
4 changes: 2 additions & 2 deletions lib/protocol/http2/client.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

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

require_relative 'connection'
require_relative "connection"

module Protocol
module HTTP2
Expand Down
8 changes: 4 additions & 4 deletions lib/protocol/http2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2023, by Marco Concetto Rudilosso.

require_relative 'framer'
require_relative 'dependency'
require_relative 'flow_controlled'
require_relative "framer"
require_relative "dependency"
require_relative "flow_controlled"

require 'protocol/hpack'
require "protocol/hpack"

module Protocol
module HTTP2
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/http2/continuation_frame.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

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

require_relative 'frame'
require_relative "frame"

module Protocol
module HTTP2
Expand Down
6 changes: 3 additions & 3 deletions lib/protocol/http2/data_frame.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_relative 'frame'
require_relative 'padded'
require_relative "frame"
require_relative "padded"

module Protocol
module HTTP2
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/http2/error.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

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

require 'protocol/http/error'
require "protocol/http/error"

module Protocol
module HTTP2
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol/http2/flow_controlled.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.
# Copyright, 2019, by Yuta Iwama.

require_relative 'window_update_frame'
require_relative "window_update_frame"

module Protocol
module HTTP2
Expand Down
6 changes: 3 additions & 3 deletions lib/protocol/http2/frame.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.
# Copyright, 2019, by Yuta Iwama.

require_relative 'error'
require_relative "error"

module Protocol
module HTTP2
Expand Down Expand Up @@ -106,7 +106,7 @@ def connection?
@stream_id.zero?
end

HEADER_FORMAT = 'CnCCN'.freeze
HEADER_FORMAT = "CnCCN".freeze
STREAM_ID_MASK = 0x7fffffff

# Generates common 9-byte frame header.
Expand Down
Loading

0 comments on commit bf18c8b

Please sign in to comment.