Skip to content

Commit

Permalink
Rubocop autocorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Jun 13, 2024
1 parent 3baa6d7 commit da5f1d1
Show file tree
Hide file tree
Showing 40 changed files with 1,547 additions and 1,283 deletions.
26 changes: 13 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# frozen_string_literal: true

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

gemspec

gem "rake"
gem "simplecov", require: false
gem "yard"
gem 'rake'
gem 'simplecov', require: false
gem 'yard'

gem "pry"
gem "pry-byebug", platform: :mri
gem "rspec", "~> 3.4.0"
gem 'pry'
gem 'pry-byebug', platform: :mri
gem 'rspec', '~> 3.4.0'

if RUBY_VERSION >= "3.0"
gem "rubocop"
gem "rubocop-performance"
if RUBY_VERSION >= '3.0'
gem 'rubocop'
gem 'rubocop-performance'
platform :mri do
gem "rbs"
gem "steep"
gem "typeprof"
gem 'rbs'
gem 'steep'
gem 'typeprof'
end
end

Expand Down
56 changes: 28 additions & 28 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
# frozen_string_literal: true

require "English"
require "bundler/gem_tasks"
require "open3"
require_relative "lib/tasks/generate_huffman_table"
require 'English'
require 'bundler/gem_tasks'
require 'open3'
require_relative 'lib/tasks/generate_huffman_table'

RUBY_MAJOR_MINOR = RUBY_VERSION.split(".").first(2).join(".")
RUBY_MAJOR_MINOR = RUBY_VERSION.split('.').first(2).join('.')

begin
require "rspec/core/rake_task"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.exclude_pattern = "./spec/hpack_test_spec.rb"
t.exclude_pattern = './spec/hpack_test_spec.rb'
end

RSpec::Core::RakeTask.new(:hpack) do |t|
t.pattern = "./spec/hpack_test_spec.rb"
t.pattern = './spec/hpack_test_spec.rb'
end
rescue LoadError
end

begin
require "rubocop/rake_task"
desc "Run rubocop"
require 'rubocop/rake_task'
desc 'Run rubocop'
RuboCop::RakeTask.new
rescue LoadError
end

begin
require "yard"
require 'yard'
YARD::Rake::YardocTask.new
rescue LoadError
end

namespace :coverage do
desc "Aggregates coverage reports"
desc 'Aggregates coverage reports'
task :report do
return unless ENV.key?("CI")
return unless ENV.key?('CI')

require "simplecov"
require 'simplecov'

SimpleCov.collate Dir["coverage/**/.resultset.json"]
SimpleCov.collate Dir['coverage/**/.resultset.json']
end
end

desc "install h2spec"
desc 'install h2spec'
task :h2spec_install do
platform = case RUBY_PLATFORM
when /darwin/
"h2spec_darwin_amd64.tar.gz"
'h2spec_darwin_amd64.tar.gz'
when /cygwin|mswin|mingw|bccwin|wince|emx/
"h2spec_windows_amd64.zip"
'h2spec_windows_amd64.zip'
else
"h2spec_linux_amd64.tar.gz"
'h2spec_linux_amd64.tar.gz'
end
# uri = "https://github.com/summerwind/h2spec/releases/download/v2.3.0/#{platform}"

tar_location = File.join(__dir__, "h2spec-releases", platform)
tar_location = File.join(__dir__, 'h2spec-releases', platform)
# require "net/http"
# File.open(tar_location, "wb") do |file|
# response = nil
Expand Down Expand Up @@ -83,24 +83,24 @@ task :h2spec_install do
# FileUtils.rm(tar_location)
end

desc "run h2spec"
desc 'run h2spec'
task :h2spec do
h2spec = File.join(__dir__, "h2spec")
h2spec = File.join(__dir__, 'h2spec')
unless File.exist?(h2spec)
abort 'Please install h2spec first.\n' \
'Run "rake h2spec_install",\n' \
"Or Download the binary from https://github.com/summerwind/h2spec/releases"
'Or Download the binary from https://github.com/summerwind/h2spec/releases'
end

server_pid = Process.spawn("ruby example/server.rb -p 9000", out: File::NULL)
sleep RUBY_ENGINE == "ruby" ? 5 : 20
server_pid = Process.spawn('ruby example/server.rb -p 9000', out: File::NULL)
sleep RUBY_ENGINE == 'ruby' ? 5 : 20
system("#{h2spec} -p 9000 -o 2 --strict")
Process.kill("TERM", server_pid)
Process.kill('TERM', server_pid)
exit($CHILD_STATUS.exitstatus)
end

default_tasks = %i[spec]
default_tasks << :rubocop if defined?(RuboCop) && RUBY_ENGINE == "ruby"
default_tasks += %i[h2spec_install h2spec] if ENV.key?("CI") && RUBY_VERSION >= "3.0.0"
default_tasks << :rubocop if defined?(RuboCop) && RUBY_ENGINE == 'ruby'
default_tasks += %i[h2spec_install h2spec] if ENV.key?('CI') && RUBY_VERSION >= '3.0.0'
task default: default_tasks
task all: %i[default hpack]
4 changes: 2 additions & 2 deletions example/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

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

gem "http_parser.rb"
gem 'http_parser.rb'
32 changes: 16 additions & 16 deletions example/client.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# frozen_string_literal: true

require_relative "helper"
require_relative 'helper'

options = {}
OptionParser.new do |opts|
opts.banner = "Usage: client.rb [options]"
opts.banner = 'Usage: client.rb [options]'

opts.on("-d", "--data [String]", "HTTP payload") do |v|
opts.on('-d', '--data [String]', 'HTTP payload') do |v|
options[:payload] = v
end
end.parse!

uri = URI.parse(ARGV[0] || "http://localhost:8080/")
uri = URI.parse(ARGV[0] || 'http://localhost:8080/')
tcp = TCPSocket.new(uri.host, uri.port)
sock = nil

if uri.scheme == "https"
if uri.scheme == 'https'
ctx = OpenSSL::SSL::SSLContext.new
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE

Expand Down Expand Up @@ -75,12 +75,12 @@
end

stream.on(:close) do
log.info "stream closed"
log.info 'stream closed'
conn.goaway
end

stream.on(:half_close) do
log.info "closing client-end of the stream"
log.info 'closing client-end of the stream'
end

stream.on(:headers) do |h|
Expand All @@ -96,23 +96,23 @@
end

head = {
":scheme" => uri.scheme,
":method" => (options[:payload].nil? ? "GET" : "POST"),
":authority" => [uri.host, uri.port].join(":"),
":path" => uri.path,
"accept" => "*/*"
':scheme' => uri.scheme,
':method' => (options[:payload].nil? ? 'GET' : 'POST'),
':authority' => [uri.host, uri.port].join(':'),
':path' => uri.path,
'accept' => '*/*'
}

puts "Sending HTTP 2.0 request"
if head[":method"] == "GET"
puts 'Sending HTTP 2.0 request'
if head[':method'] == 'GET'
stream.headers(head, end_stream: true)
else
stream.headers(head, end_stream: false)
stream.data(options[:payload])
end

require "memory_profiler"
report = MemoryProfiler.report(allow_files: "http-2-next") do
require 'memory_profiler'
report = MemoryProfiler.report(allow_files: 'http-2-next') do
while !sock.closed? && !sock.eof?
data = sock.read_nonblock(1024)
# puts "Received bytes: #{data.unpack("H*").first}"
Expand Down
18 changes: 9 additions & 9 deletions example/helper.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# frozen_string_literal: true

$LOAD_PATH << "lib" << "../lib"
$LOAD_PATH << 'lib' << '../lib'

require "optparse"
require "socket"
require "openssl"
require "uri"
require 'optparse'
require 'socket'
require 'openssl'
require 'uri'

# This will enable coverage within the CI environment
if ENV.key?("CI")
require "simplecov"
if ENV.key?('CI')
require 'simplecov'
SimpleCov.command_name "#{RUBY_ENGINE}-#{RUBY_VERSION}-h2spec"
SimpleCov.coverage_dir "coverage/#{RUBY_ENGINE}-#{RUBY_VERSION}-h2spec"
end

require "http/2"
require 'http/2'

DRAFT = "h2"
DRAFT = 'h2'

class Logger
def initialize(id)
Expand Down
4 changes: 2 additions & 2 deletions example/raw.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require "socket"
require 'socket'

puts "Starting server on port 9000"
puts 'Starting server on port 9000'
server = TCPServer.new(9000)

loop do
Expand Down
Loading

0 comments on commit da5f1d1

Please sign in to comment.