Skip to content

Commit

Permalink
Modernize code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 5, 2024
1 parent 6fcaea4 commit dfd9419
Show file tree
Hide file tree
Showing 44 changed files with 114 additions and 108 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:

- 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 Down
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
6 changes: 3 additions & 3 deletions async-container.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
spec.authors = ["Samuel Williams", "Olle Jonsson", "Anton Sozontov", "Juan Antonio Martín Lucas", "Yuji Yaginuma"]
spec.license = "MIT"

spec.cert_chain = ['release.cert']
spec.signing_key = File.expand_path('~/.gem/release.pem')
spec.cert_chain = ["release.cert"]
spec.signing_key = File.expand_path("~/.gem/release.pem")

spec.homepage = "https://github.com/socketry/async-container"

Expand All @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
"source_code_uri" => "https://github.com/socketry/async-container.git",
}

spec.files = Dir.glob(['{lib}/**/*', '*.md'], File::FNM_DOTMATCH, base: __dir__)
spec.files = Dir.glob(["{lib}/**/*", "*.md"], File::FNM_DOTMATCH, base: __dir__)

spec.required_ruby_version = ">= 3.1"

Expand Down
4 changes: 2 additions & 2 deletions config/sus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2022, by Samuel Williams.

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

ENV['CONSOLE_LEVEL'] ||= 'fatal'
ENV["CONSOLE_LEVEL"] ||= "fatal"
6 changes: 3 additions & 3 deletions examples/benchmark/scalability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# gem install async-container
gem "async-container"

require 'async/clock'
require_relative '../../lib/async/container'
require "async/clock"
require_relative "../../lib/async/container"

def fibonacci(n)
if n < 2
Expand All @@ -17,7 +17,7 @@ def fibonacci(n)
end
end

require 'sqlite3'
require "sqlite3"

def work(*)
512.times do
Expand Down
2 changes: 1 addition & 1 deletion examples/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright, 2020-2022, by Samuel Williams.
# Copyright, 2020, by Olle Jonsson.

require 'json'
require "json"

class Channel
def initialize
Expand Down
2 changes: 1 addition & 1 deletion examples/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Copyright, 2019, by Yuji Yaginuma.
# Copyright, 2022, by Anton Sozontov.

require '../lib/async/container'
require "../lib/async/container"

Console.logger.debug!

Expand Down
2 changes: 1 addition & 1 deletion examples/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Copyright, 2022, by Anton Sozontov.
# Copyright, 2024, by Samuel Williams.

require '../lib/async/container/controller'
require "../lib/async/container/controller"

class Controller < Async::Container::Controller
def setup(container)
Expand Down
2 changes: 1 addition & 1 deletion examples/fan-out/pipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Released under the MIT License.
# Copyright, 2020-2024, by Samuel Williams.

require 'async/container'
require "async/container"

container = Async::Container.new
input, output = IO.pipe
Expand Down
4 changes: 2 additions & 2 deletions examples/grace/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

require '../../lib/async/container'
require 'io/endpoint/host_endpoint'
require "../../lib/async/container"
require "io/endpoint/host_endpoint"

Console.logger.debug!

Expand Down
6 changes: 3 additions & 3 deletions examples/http/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Released under the MIT License.
# Copyright, 2022-2024, by Samuel Williams.

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

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

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

require 'async/container'
require "async/container"

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

container = Async::Container::Forked.new

Expand Down
12 changes: 6 additions & 6 deletions examples/queue/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# Released under the MIT License.
# Copyright, 2020-2024, by Samuel Williams.

require 'async'
require 'async/container'
require 'io/endpoint'
require 'io/endpoint/unix_endpoint'
require 'msgpack'
require "async"
require "async/container"
require "io/endpoint"
require "io/endpoint/unix_endpoint"
require "msgpack"

class Wrapper < MessagePack::Factory
def initialize
Expand All @@ -29,7 +29,7 @@ def initialize
end
end

endpoint = IO::Endpoint.unix('test.ipc')
endpoint = IO::Endpoint.unix("test.ipc")
bound_endpoint = endpoint.bound

wrapper = Wrapper.new
Expand Down
6 changes: 3 additions & 3 deletions examples/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.

require_relative 'group'
require_relative 'thread'
require_relative 'process'
require_relative "group"
require_relative "thread"
require_relative "process"

group = Async::Container::Group.new

Expand Down
8 changes: 4 additions & 4 deletions fixtures/async/container/a_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module Container
expect(input.read).to be == "true"
end

with '#sleep' do
with "#sleep" do
it "can sleep for a short time" do
container.spawn do
sleep(0.01)
Expand All @@ -63,8 +63,8 @@ module Container
end
end

with '#stop' do
it 'can stop the child process' do
with "#stop" do
it "can stop the child process" do
container.spawn do
sleep(1)
end
Expand All @@ -77,7 +77,7 @@ module Container
end
end

with '#ready' do
with "#ready" do
it "can notify the ready pipe in an asynchronous context" do
container.run do |instance|
Async do
Expand Down
2 changes: 1 addition & 1 deletion gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2017-2024, by Samuel Williams.

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

gemspec

Expand Down
4 changes: 2 additions & 2 deletions gems/async-head.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.

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

eval_gemfile "../gems.rb"

gem 'async', git: "https://github.com/socketry/async"
gem "async", git: "https://github.com/socketry/async"
4 changes: 2 additions & 2 deletions gems/async-v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.

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

eval_gemfile "../gems.rb"

gem 'async', '~> 1.0'
gem "async", "~> 1.0"
2 changes: 1 addition & 1 deletion lib/async/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2017-2022, by Samuel Williams.

require_relative 'container/controller'
require_relative "container/controller"

module Async
module Container
Expand Down
6 changes: 3 additions & 3 deletions lib/async/container/best.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Released under the MIT License.
# Copyright, 2019-2022, by Samuel Williams.

require_relative 'forked'
require_relative 'threaded'
require_relative 'hybrid'
require_relative "forked"
require_relative "threaded"
require_relative "hybrid"

module Async
module Container
Expand Down
2 changes: 1 addition & 1 deletion lib/async/container/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.

require 'json'
require "json"

module Async
module Container
Expand Down
8 changes: 4 additions & 4 deletions lib/async/container/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.

require_relative 'error'
require_relative 'best'
require_relative "error"
require_relative "best"

require_relative 'statistics'
require_relative 'notify'
require_relative "statistics"
require_relative "notify"

module Async
module Container
Expand Down
4 changes: 2 additions & 2 deletions lib/async/container/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class Error < StandardError

# Similar to {Interrupt}, but represents `SIGTERM`.
class Terminate < SignalException
SIGTERM = Signal.list['TERM']
SIGTERM = Signal.list["TERM"]

def initialize
super(SIGTERM)
end
end

class Hangup < SignalException
SIGHUP = Signal.list['HUP']
SIGHUP = Signal.list["HUP"]

def initialize
super(SIGHUP)
Expand Down
4 changes: 2 additions & 2 deletions lib/async/container/forked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Released under the MIT License.
# Copyright, 2017-2022, by Samuel Williams.

require_relative 'generic'
require_relative 'process'
require_relative "generic"
require_relative "process"

module Async
module Container
Expand Down
12 changes: 6 additions & 6 deletions lib/async/container/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require 'async'
require "async"

require 'etc'
require "etc"

require_relative 'group'
require_relative 'keyed'
require_relative 'statistics'
require_relative "group"
require_relative "keyed"
require_relative "statistics"

module Async
module Container
# An environment variable key to override {.processor_count}.
ASYNC_CONTAINER_PROCESSOR_COUNT = 'ASYNC_CONTAINER_PROCESSOR_COUNT'
ASYNC_CONTAINER_PROCESSOR_COUNT = "ASYNC_CONTAINER_PROCESSOR_COUNT"

# The processor count which may be used for the default number of container threads/processes. You can override the value provided by the system by specifying the `ASYNC_CONTAINER_PROCESSOR_COUNT` environment variable.
# @returns [Integer] The number of hardware processors which can run threads/processes simultaneously.
Expand Down
6 changes: 3 additions & 3 deletions lib/async/container/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.

require 'fiber'
require 'async/clock'
require "fiber"
require "async/clock"

require_relative 'error'
require_relative "error"

module Async
module Container
Expand Down
4 changes: 2 additions & 2 deletions lib/async/container/hybrid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Copyright, 2019-2022, by Samuel Williams.
# Copyright, 2022, by Anton Sozontov.

require_relative 'forked'
require_relative 'threaded'
require_relative "forked"
require_relative "threaded"

module Async
module Container
Expand Down
6 changes: 3 additions & 3 deletions lib/async/container/notify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.

require_relative 'notify/pipe'
require_relative 'notify/socket'
require_relative 'notify/console'
require_relative "notify/pipe"
require_relative "notify/socket"
require_relative "notify/console"

module Async
module Container
Expand Down
4 changes: 2 additions & 2 deletions lib/async/container/notify/console.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 'client'
require_relative "client"

require 'console/logger'
require "console/logger"

module Async
module Container
Expand Down
Loading

0 comments on commit dfd9419

Please sign in to comment.