Skip to content

Commit

Permalink
Modernize gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 17, 2024
1 parent fb2d89f commit 1f5c352
Show file tree
Hide file tree
Showing 29 changed files with 283 additions and 178 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
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: bundle exec bake utopia:project:static --force no

- name: Upload documentation artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: docs

Expand All @@ -55,4 +55,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v4
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,7 +33,7 @@ jobs:
- name: Run tests
timeout-minutes: 5
run: bundle exec bake test

- uses: actions/upload-artifact@v3
with:
name: coverage-${{matrix.os}}-${{matrix.ruby}}
Expand Down
49 changes: 49 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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
1 change: 1 addition & 0 deletions bin/falcon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
#
Expand Down
1 change: 1 addition & 0 deletions bin/falcon-host
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
#
Expand Down
12 changes: 6 additions & 6 deletions examples/benchmark/bake.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, 2018-2023, by Samuel Williams.
# Copyright, 2018-2024, by Samuel Williams.

require 'etc'

Expand Down Expand Up @@ -88,16 +88,16 @@ def compare

n = 2

# threads.times do |n|
threads.times do |n|
c = (n*n).to_s
puts "Running #{command.first} with #{c} concurrent connections..."

Async::Process.spawn("curl", "-o", "/dev/null", "#{host}#{@request_path}")

# Async::Process.spawn("ab", "-k", "-n", "1000", "#{host}#{@request_path}")

Async::Process.spawn("wrk", "-c", c.to_s, "-t", (n).to_s, "-d", "10", "#{host}#{@request_path}")
# end
end
ensure
child_process.kill(:INT)
end
Expand Down
4 changes: 4 additions & 0 deletions examples/benchmark/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class Benchmark
@app = app
end

def hello(env)
[200, {'content-length' => 12}, ["Hello World\n"]]
end

PATH_INFO = 'PATH_INFO'.freeze

SMALL = [200, {}, ["Hello World\n" * 10] * 10].freeze
Expand Down
45 changes: 21 additions & 24 deletions examples/bug/config.ru
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
# frozen_string_literal: true
class HelloWorld
JSON_TYPE = "application/json".freeze
PLAINTEXT_TYPE = "text/plain".freeze

def respond(type, body)
[200, { "Content-Type" => type }, [body]]
end

def call(env)
case env["PATH_INFO"]
when "/json"
# Test type 1: JSON serialization
return respond JSON_TYPE,
Oj.dump({ message: "Hello, World!" }, { mode: :strict })
when "/plaintext"
# Test type 6: Plaintext
return respond PLAINTEXT_TYPE, "Hello, World!"
end

[200, {}, []]
end
JSON_TYPE = "application/json".freeze
PLAINTEXT_TYPE = "text/plain".freeze

def respond(type, body)
[200, { "Content-Type" => type }, [body]]
end

def call(env)
case env["PATH_INFO"]
when "/json"
# Test type 1: JSON serialization
return respond JSON_TYPE, Oj.dump({ message: "Hello, World!" }, { mode: :strict })
when "/plaintext"
# Test type 6: Plaintext
return respond PLAINTEXT_TYPE, "Hello, World!"
end

[200, {}, []]
end
end

# run HelloWorld.new

run do
end
run HelloWorld.new
4 changes: 1 addition & 3 deletions examples/bug/falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

hostname = File.basename(__dir__)
rack hostname do
endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:8080").with(
protocol: Async::HTTP::Protocol::HTTP11
)
endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:8080").with(protocol: Async::HTTP::Protocol::HTTP11)
end

supervisor
19 changes: 9 additions & 10 deletions examples/echo/config.ru
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# frozen_string_literal: true

class EchoBody
def initialize(input)
@input = input
end
def initialize(input)
@input = input
end

def each(&output)
while chunk = @input.read(1024)
output.call(chunk)
end
end
def each(&output)
while chunk = @input.read(1024)
output.call(chunk)
end
end
end

run lambda{|env|
[200, [], EchoBody.new(env['rack.input'])]
[200, [], EchoBody.new(env['rack.input'])]
}

2 changes: 1 addition & 1 deletion examples/hello/falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

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

require 'falcon/environment/self_signed_tls'
require 'falcon/environment/rack'
Expand Down
Loading

0 comments on commit 1f5c352

Please sign in to comment.