mirror of
https://github.com/mperham/connection_pool
synced 2023-03-27 23:22:21 -04:00
integrate standard
This commit is contained in:
parent
d2ff737ab6
commit
2c927744bb
8 changed files with 14 additions and 10 deletions
3
.standard.yml
Normal file
3
.standard.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
ruby_version: 2.5.0
|
||||
fix: true
|
||||
parallel: true
|
1
Gemfile
1
Gemfile
|
@ -1,3 +1,4 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gemspec(development_group: :runtime)
|
||||
gem "standard", group: [:development, :test]
|
||||
|
|
4
Rakefile
4
Rakefile
|
@ -1,6 +1,6 @@
|
|||
require "bundler/gem_tasks"
|
||||
|
||||
require "standard/rake"
|
||||
require "rake/testtask"
|
||||
Rake::TestTask.new
|
||||
|
||||
task default: :test
|
||||
task default: [:"standard:fix", :test]
|
||||
|
|
|
@ -10,9 +10,8 @@ Gem::Specification.new do |s|
|
|||
s.description = s.summary = "Generic connection pool for Ruby"
|
||||
|
||||
s.files = ["Changes.md", "LICENSE", "README.md", "connection_pool.gemspec",
|
||||
"lib/connection_pool.rb", "lib/connection_pool/timed_stack.rb",
|
||||
"lib/connection_pool/version.rb", "lib/connection_pool/wrapper.rb"]
|
||||
s.test_files = ["test/helper.rb", "test/test_connection_pool.rb", "test/test_connection_pool_timed_stack.rb"]
|
||||
"lib/connection_pool.rb", "lib/connection_pool/timed_stack.rb",
|
||||
"lib/connection_pool/version.rb", "lib/connection_pool/wrapper.rb"]
|
||||
s.executables = []
|
||||
s.require_paths = ["lib"]
|
||||
s.license = "MIT"
|
||||
|
|
|
@ -3,7 +3,9 @@ require_relative "connection_pool/version"
|
|||
|
||||
class ConnectionPool
|
||||
class Error < ::RuntimeError; end
|
||||
|
||||
class PoolShuttingDownError < ::ConnectionPool::Error; end
|
||||
|
||||
class TimeoutError < ::Timeout::Error; end
|
||||
end
|
||||
|
||||
|
@ -67,7 +69,7 @@ class ConnectionPool
|
|||
end
|
||||
end
|
||||
end
|
||||
alias then with
|
||||
alias_method :then, :with
|
||||
|
||||
def checkout(options = {})
|
||||
if ::Thread.current[@key]
|
||||
|
|
|
@ -49,7 +49,7 @@ class ConnectionPool::TimedStack
|
|||
@resource.broadcast
|
||||
end
|
||||
end
|
||||
alias << push
|
||||
alias_method :<<, :push
|
||||
|
||||
##
|
||||
# Retrieves a connection from the stack. If a connection is available it is
|
||||
|
@ -87,7 +87,7 @@ class ConnectionPool::TimedStack
|
|||
# +:reload+ is +true+.
|
||||
|
||||
def shutdown(reload: false, &block)
|
||||
raise ArgumentError, "shutdown must receive a block" unless block_given?
|
||||
raise ArgumentError, "shutdown must receive a block" unless block
|
||||
|
||||
@mutex.synchronize do
|
||||
@shutdown_block = block
|
||||
|
|
|
@ -30,7 +30,6 @@ class ConnectionPool
|
|||
METHODS.include?(id) || with { |c| c.respond_to?(id, *args) }
|
||||
end
|
||||
|
||||
# rubocop:disable Style/MethodMissingSuper
|
||||
# rubocop:disable Style/MissingRespondToMissing
|
||||
if ::RUBY_VERSION >= "3.0.0"
|
||||
def method_missing(name, *args, **kwargs, &block)
|
||||
|
|
|
@ -339,7 +339,7 @@ class TestConnectionPool < Minitest::Test
|
|||
assert_equal 5, pool.do_something_with_block { 3 }
|
||||
assert_equal 6, pool.with { |net| net.fast }
|
||||
assert_equal 8, pool.do_something(increment: 2)
|
||||
assert_equal 10, pool.do_something_with_positional_hash({ increment: 2, symbol_key: 3, "string_key" => 4 })
|
||||
assert_equal 10, pool.do_something_with_positional_hash({:increment => 2, :symbol_key => 3, "string_key" => 4})
|
||||
end
|
||||
|
||||
def test_passthru_respond_to
|
||||
|
|
Loading…
Reference in a new issue