Skip to content

Commit

Permalink
Apply RuboCop rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 2, 2024
1 parent e505092 commit 242576f
Show file tree
Hide file tree
Showing 90 changed files with 343 additions and 341 deletions.
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 bake/falcon/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright, 2020-2023, by Samuel Williams.

def restart
require_relative '../../lib/falcon/command/supervisor'
require_relative "../../lib/falcon/command/supervisor"

Falcon::Command::Supervisor["restart"].call
end
2 changes: 1 addition & 1 deletion bin/falcon
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require_relative '../lib/falcon/command'
require_relative "../lib/falcon/command"

begin
Falcon::Command.call
Expand Down
2 changes: 1 addition & 1 deletion bin/falcon-host
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require_relative '../lib/falcon/command/host'
require_relative "../lib/falcon/command/host"

begin
Falcon::Command::Host.call
Expand Down
4 changes: 2 additions & 2 deletions config/sus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Released under the MIT License.
# Copyright, 2017-2024, by Samuel Williams.

require 'covered/sus'
require "covered/sus"
include Covered::Sus

require 'openssl'
require "openssl"
$stderr.puts "OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION}"
2 changes: 1 addition & 1 deletion examples/async-service/hello.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require 'falcon/environment/server'
require "falcon/environment/server"

service "hello-server" do
include Falcon::Environment::Server
Expand Down
8 changes: 4 additions & 4 deletions examples/beer/config.ru
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env falcon --verbose serve -c
# frozen_string_literal: true

require 'rack'
require 'cgi'
require "rack"
require "cgi"

def bottles(n)
n == 1 ? "#{n} bottle" : "#{n} bottles"
Expand All @@ -19,7 +19,7 @@ run lambda {|env|
body = Async::HTTP::Body::Writable.new

request = Rack::Request.new(env)
count = (request.params['count'] || 99).to_i
count = (request.params["count"] || 99).to_i

body.write("<!DOCTYPE html><html><head><title>#{count} Bottles of Beer</title></head><body>")

Expand Down Expand Up @@ -53,5 +53,5 @@ run lambda {|env|
end
end

[200, {'content-type' => 'text/html; charset=utf-8'}, body]
[200, {"content-type" => "text/html; charset=utf-8"}, body]
}
2 changes: 1 addition & 1 deletion examples/beer/falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

load :rack, :self_signed_tls, :supervisor

rack 'beer.localhost', :self_signed_tls
rack "beer.localhost", :self_signed_tls

supervisor
10 changes: 5 additions & 5 deletions examples/benchmark/bake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.

require 'etc'
require "etc"

require 'async'
require 'async/process'
require 'async/clock'
require 'async/http/endpoint'
require "async"
require "async/process"
require "async/clock"
require "async/http/endpoint"

def hello
@config_path = File.expand_path("../hello/config.ru", __dir__)
Expand Down
4 changes: 2 additions & 2 deletions examples/benchmark/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class Benchmark
end

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

PATH_INFO = 'PATH_INFO'.freeze
PATH_INFO = "PATH_INFO".freeze

SMALL = [200, {}, ["Hello World\n" * 10] * 10].freeze

Expand Down
2 changes: 1 addition & 1 deletion examples/benchmark/falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

load :rack, :self_signed_tls, :supervisor

rack 'benchmark.local', :self_signed_tls
rack "benchmark.local", :self_signed_tls
2 changes: 1 addition & 1 deletion examples/call/config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'trenni'
require "trenni"

class Output < Struct.new(:stream)
def <<(chunk)
Expand Down
6 changes: 3 additions & 3 deletions examples/cookies/config.ru
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env falcon --verbose serve -c
# frozen_string_literal: true

require 'rack/request'
require "rack/request"

KEY = 'my cookie'
KEY = "my cookie"

run do |env|
request = Rack::Request.new(env)
puts "My Cookie: #{request.cookies[KEY]}"
puts "All Cookies: #{request.cookies}"

headers = {}
Rack::Utils.set_cookie_header!(headers, KEY, 'bar')
Rack::Utils.set_cookie_header!(headers, KEY, "bar")

[200, headers, ["Hello World!"]]
end
2 changes: 1 addition & 1 deletion examples/csv/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MyApp
def initialize(app)
@app = app

@words = File.readlines('/usr/share/dict/words', chomp: true).each_slice(3).to_a
@words = File.readlines("/usr/share/dict/words", chomp: true).each_slice(3).to_a
end

def call(env)
Expand Down
2 changes: 1 addition & 1 deletion examples/echo/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class EchoBody
end

run lambda{|env|
[200, [], EchoBody.new(env['rack.input'])]
[200, [], EchoBody.new(env["rack.input"])]
}
4 changes: 2 additions & 2 deletions examples/google/falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
supervisor

proxy "google.localhost", :self_signed_tls do
url 'https://www.google.com'
url "https://www.google.com"
end

proxy "codeotaku.localhost", :self_signed_tls do
url 'https://www.codeotaku.com'
url "https://www.codeotaku.com"
end
2 changes: 1 addition & 1 deletion examples/headers/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "cgi"

run ->(env) {
params = CGI.parse env["QUERY_STRING"]
header = params.fetch("xid", []).first || ''
header = params.fetch("xid", []).first || ""

[200, {"xid" => "m" + header }, ["hello"]]
}
12 changes: 6 additions & 6 deletions examples/hello/falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require 'falcon/environment/self_signed_tls'
require 'falcon/environment/rack'
require 'falcon/environment/supervisor'
require "falcon/environment/self_signed_tls"
require "falcon/environment/rack"
require "falcon/environment/supervisor"

service 'hello.localhost' do
service "hello.localhost" do
include Falcon::Environment::SelfSignedTLS
include Falcon::Environment::Rack

scheme 'http'
scheme "http"
protocol {Async::HTTP::Protocol::HTTP}

# endpoint do
Expand All @@ -25,6 +25,6 @@
# report :supervisor
end

service 'supervisor' do
service "supervisor" do
include Falcon::Environment::Supervisor
end
12 changes: 6 additions & 6 deletions examples/internet/config.ru
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require 'async'
require 'async/http/internet'
require "async"
require "async/http/internet"

# Experimental.
require 'kernel/sync'
require "kernel/sync"

class Search
def initialize(app)
Expand Down Expand Up @@ -38,10 +38,10 @@ class Search

# The only point of this is to invoke one of the above two methods.
def call(env)
case env['PATH_INFO']
when '/sync'
case env["PATH_INFO"]
when "/sync"
self.sync
when '/async'
when "/async"
self.async
end

Expand Down
2 changes: 1 addition & 1 deletion examples/memory/config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative 'allocations'
require_relative "allocations"

use Allocations

Expand Down
6 changes: 3 additions & 3 deletions examples/push/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-2023, by Samuel Williams.

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

Async do
endpoint = Async::HTTP::Endpoint.parse("https://localhost:9292")
Expand Down
6 changes: 3 additions & 3 deletions examples/push/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class EarlyHints
end

def call(env)
path = env['PATH_INFO']
early_hints = early_hints = env['rack.early_hints']
path = env["PATH_INFO"]
early_hints = early_hints = env["rack.early_hints"]

Console.logger.debug("path: #{path} #{early_hints}")

Expand All @@ -23,6 +23,6 @@ end

use EarlyHints

use Rack::Static, :urls => [""], :root => __dir__, :index => 'index.html'
use Rack::Static, :urls => [""], :root => __dir__, :index => "index.html"

run lambda{|env| [404, [], ["Not Found"]]}
2 changes: 1 addition & 1 deletion examples/pushback/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
# Copyright, 2024, by Peter Schrammel.
# Copyright, 2024, by Samuel Williams.

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

gem "falcon"# frozen_string_literal: true
14 changes: 7 additions & 7 deletions examples/pushback/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# https://tmr08c.github.io/2020/05/concurrent-ruby-hello-async/
#
require 'async'
require "async"

class Pool
def initialize(size:, workers:)
Expand Down Expand Up @@ -79,7 +79,7 @@ class Task
end

def work
step 'working'
step "working"
sleep 5
@body.write "(#{Time.now}) Hello World #{Process.pid} #{@task}\n"
ensure
Expand All @@ -91,26 +91,26 @@ class Task
end

def wait_for_worker
step('waiting')
step("waiting")
Fiber.scheduler.yield while @wait
work
# @fiber.yield
# @task.yield
end

def continue
step('continue')
step("continue")
@wait = false
end

def finish
step('finish')
step("finish")
@body.close
print_timings
end

def pushback
step('finish')
step("finish")
@body.close
end

Expand All @@ -126,7 +126,7 @@ end
pool = Pool.new(size: 15, workers: 10)

run do |env|
request = env['protocol.http.request']
request = env["protocol.http.request"]
path = request.path
pool.push(path) # returns [code, {}, body]
end
6 changes: 3 additions & 3 deletions examples/redis/config.ru
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'sinatra/base'
require 'async/redis'
require 'async/clock'
require "sinatra/base"
require "async/redis"
require "async/clock"

CLIENT = Async::Redis::Client.new(Async::Redis.local_endpoint)

Expand Down
6 changes: 3 additions & 3 deletions examples/sequel/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

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

gem 'falcon'
gem 'sequel'
gem "falcon"
gem "sequel"
4 changes: 2 additions & 2 deletions examples/sequel/config.ru
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

# config.ru
require 'sequel'
require "sequel"

# Turn on single threaded mode
Sequel.single_threaded = true
DB = Sequel.sqlite('data.sqlite3')
DB = Sequel.sqlite("data.sqlite3")

run(proc{|env| [200, {}, [DB[:user].get(:name)]]})
Loading

0 comments on commit 242576f

Please sign in to comment.