Skip to content

Commit 52f83bc

Browse files
committed
Modernize gem.
1 parent 63d2ef0 commit 52f83bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+183
-172
lines changed

.github/workflows/test-coverage.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ jobs:
4444
timeout-minutes: 5
4545
run: bundle exec bake test
4646

47-
- uses: actions/upload-artifact@v3
47+
- uses: actions/upload-artifact@v4
4848
with:
49+
include-hidden-files: true
50+
if-no-files-found: error
4951
name: coverage-${{matrix.os}}-${{matrix.ruby}}
5052
path: .covered.db
5153

@@ -77,6 +79,8 @@ jobs:
7779

7880
- uses: actions/upload-artifact@v3
7981
with:
82+
include-hidden-files: true
83+
if-no-files-found: error
8084
name: coverage-${{matrix.os}}-${{matrix.ruby}}
8185
path: .covered.db
8286

@@ -108,6 +112,8 @@ jobs:
108112

109113
- uses: actions/upload-artifact@v3
110114
with:
115+
include-hidden-files: true
116+
if-no-files-found: error
111117
name: coverage-${{matrix.os}}-${{matrix.ruby}}
112118
path: .covered.db
113119

@@ -125,7 +131,7 @@ jobs:
125131
ruby-version: "3.3"
126132
bundler-cache: true
127133

128-
- uses: actions/download-artifact@v3
134+
- uses: actions/download-artifact@v4
129135

130136
- name: Validate coverage
131137
timeout-minutes: 5

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ Layout/EmptyLinesAroundModuleBody:
4747

4848
Style/FrozenStringLiteralComment:
4949
Enabled: true
50+
51+
Style/StringLiterals:
52+
Enabled: true
53+
EnforcedStyle: double_quotes

async-redis.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
77
spec.version = Async::Redis::VERSION
88

99
spec.summary = "A Redis client library."
10-
spec.authors = ["Samuel Williams", "Huba Nagy", "David Ortiz", "Gleb Sinyavskiy", "Mikael Henriksson", "Troex Nevelin", "Alex Matchneer", "Jeremy Jung", "Olle Jonsson", "Pierre Montelle", "Salim Semaoune", "Tim Willard"]
10+
spec.authors = ["Samuel Williams", "Huba Nagy", "David Ortiz", "Gleb Sinyavskiy", "Mikael Henriksson", "Troex Nevelin", "Alex Matchneer", "Jeremy Jung", "Joan Lledó", "Olle Jonsson", "Pierre Montelle", "Salim Semaoune", "Tim Willard"]
1111
spec.license = "MIT"
1212

13-
spec.cert_chain = ['release.cert']
14-
spec.signing_key = File.expand_path('~/.gem/release.pem')
13+
spec.cert_chain = ["release.cert"]
14+
spec.signing_key = File.expand_path("~/.gem/release.pem")
1515

1616
spec.homepage = "https://github.com/socketry/async-redis"
1717

@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
2020
"source_code_uri" => "https://github.com/socketry/async-redis.git",
2121
}
2222

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

2525
spec.required_ruby_version = ">= 3.1"
2626

bake.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Copyright, 2018-2023, by Samuel Williams.
55

66
def client
7-
require 'irb'
8-
require 'async/redis/client'
7+
require "irb"
8+
require "async/redis/client"
99

1010
endpoint = Async::Redis.local_endpoint
1111
client = Async::Redis::Client.new(endpoint)

benchmark/performance.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
# Copyright, 2019-2024, by Samuel Williams.
66
# Copyright, 2019, by David Ortiz.
77

8-
require 'async/redis'
8+
require "async/redis"
99

10-
require 'redis'
11-
require 'redis/connection/hiredis'
10+
require "redis"
11+
require "redis/connection/hiredis"
1212

13-
require 'benchmark'
14-
require 'benchmark/ips'
13+
require "benchmark"
14+
require "benchmark/ips"
1515

1616
keys = ["X","Y","Z"].freeze
1717
endpoint = Async::Redis.local_endpoint

cluster/test/async/redis/cluster_client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Released under the MIT License.
44
# Copyright, 2024, by Samuel Williams.
55

6-
require 'async/redis/cluster_client'
7-
require 'sus/fixtures/async'
8-
require 'securerandom'
6+
require "async/redis/cluster_client"
7+
require "sus/fixtures/async"
8+
require "securerandom"
99

1010
describe Async::Redis::ClusterClient do
1111
include Sus::Fixtures::Async::ReactorContext

config/sus.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Released under the MIT License.
44
# Copyright, 2023, by Samuel Williams.
55

6-
require 'covered/sus'
6+
require "covered/sus"
77
include Covered::Sus

examples/auth/protocol.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Released under the MIT License.
44
# Copyright, 2021-2023, by Samuel Williams.
55

6-
require_relative '../../lib/async/redis'
6+
require_relative "../../lib/async/redis"
77

88
class AuthenticatedRESP2
99
def initialize(credentials, protocol: Async::Redis::Protocol::RESP2)

examples/auth/wrapper.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright, 2021, by Troex Nevelin.
55
# Copyright, 2023-2024, by Samuel Williams.
66

7-
require_relative '../../lib/async/redis'
7+
require_relative "../../lib/async/redis"
88

99
# Friendly client wrapper that supports SSL, AUTH and db SELECT
1010
class AsyncRedisClientWrapper
@@ -13,7 +13,7 @@ class << self
1313
# @param ssl_params [Hash] passed to OpenSSL::SSL::SSLContext
1414
# @param options [Hash] passed to Async::Redis::Client.new
1515
# @return [Async::Redis::Client]
16-
def call(url = 'redis://localhost:6379', ssl_params: nil, **options)
16+
def call(url = "redis://localhost:6379", ssl_params: nil, **options)
1717
uri = URI(url)
1818

1919
endpoint = prepare_endpoint(uri, ssl_params)
@@ -36,9 +36,9 @@ def call(url = 'redis://localhost:6379', ssl_params: nil, **options)
3636
def prepare_endpoint(uri, ssl_params = nil)
3737
tcp_endpoint = ::IO::Endpoint.tcp(uri.hostname, uri.port)
3838
case uri.scheme
39-
when 'redis'
39+
when "redis"
4040
tcp_endpoint
41-
when 'rediss'
41+
when "rediss"
4242
ssl_context = OpenSSL::SSL::SSLContext.new
4343
ssl_context.set_params(ssl_params) if ssl_params
4444
::IO::SSLEndpoint.new(tcp_endpoint, ssl_context: ssl_context)

examples/redis/pop.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Released under the MIT License.
55
# Copyright, 2022-2023, by Samuel Williams.
66

7-
require 'async'
8-
require 'async/barrier'
9-
require 'redis'
7+
require "async"
8+
require "async/barrier"
9+
require "redis"
1010

1111
Async do |parent|
1212
child = Async do |task|

examples/redis/pres/pop.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Released under the MIT License.
55
# Copyright, 2022-2023, by Samuel Williams.
66

7-
require 'async'
8-
require 'redis'
7+
require "async"
8+
require "redis"
99

1010
Async do |parent|
1111
child = Async do |task|

examples/slow-log/analysis.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Released under the MIT License.
55
# Copyright, 2022-2023, by Samuel Williams.
66

7-
require 'set'
8-
require 'async'
9-
require_relative '../../lib/async/redis'
7+
require "set"
8+
require "async"
9+
require_relative "../../lib/async/redis"
1010

1111
endpoint = Async::Redis.local_endpoint(port: 6380)
1212
client = Async::Redis::Client.new(endpoint)

examples/slow-log/queues.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Released under the MIT License.
55
# Copyright, 2022-2023, by Samuel Williams.
66

7-
require 'async'
8-
require_relative '../../lib/async/redis'
7+
require "async"
8+
require_relative "../../lib/async/redis"
99

1010
endpoint = Async::Redis.local_endpoint(port: 6380)
1111
client = Async::Redis::Client.new(endpoint)

examples/subscribe/pubsub.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Released under the MIT License.
55
# Copyright, 2023, by Samuel Williams.
66

7-
require_relative '../../lib/async/redis'
7+
require_relative "../../lib/async/redis"
88

99
class Subscription
1010
def initialize(topic, endpoint = Async::Redis.local_endpoint)

fixtures/client_context.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Copyright, 2018, by Huba Nagy.
55
# Copyright, 2018-2024, by Samuel Williams.
66

7-
require 'async/redis'
8-
require 'async/redis/client'
9-
require 'async/redis/key'
7+
require "async/redis"
8+
require "async/redis/client"
9+
require "async/redis/key"
1010

11-
require 'sus/fixtures/async'
11+
require "sus/fixtures/async"
1212

13-
require 'securerandom'
13+
require "securerandom"
1414

1515
ClientContext = Sus::Shared("client context") do
1616
include Sus::Fixtures::Async::ReactorContext

gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Released under the MIT License.
44
# Copyright, 2018-2024, by Samuel Williams.
55

6-
source 'https://rubygems.org'
6+
source "https://rubygems.org"
77

88
gemspec
99

lib/async/redis.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2018-2023, by Samuel Williams.
4+
# Copyright, 2018-2024, by Samuel Williams.
55
# Copyright, 2020, by David Ortiz.
66

7-
require_relative 'redis/version'
8-
require_relative 'redis/client'
7+
require_relative "redis/version"
8+
require_relative "redis/client"
99

10-
require_relative 'redis/cluster_client'
11-
require_relative 'redis/sentinel_client'
10+
require_relative "redis/cluster_client"
11+
require_relative "redis/sentinel_client"

lib/async/redis/client.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
# Copyright, 2019, by David Ortiz.
88
# Copyright, 2020, by Salim Semaoune.
99

10-
require_relative 'context/pipeline'
11-
require_relative 'context/transaction'
12-
require_relative 'context/subscribe'
13-
require_relative 'endpoint'
10+
require_relative "context/pipeline"
11+
require_relative "context/transaction"
12+
require_relative "context/subscribe"
13+
require_relative "endpoint"
1414

15-
require 'io/endpoint/host_endpoint'
16-
require 'async/pool/controller'
17-
require 'protocol/redis/methods'
15+
require "io/endpoint/host_endpoint"
16+
require "async/pool/controller"
17+
require "protocol/redis/methods"
1818

19-
require 'io/stream'
19+
require "io/stream"
2020

2121
module Async
2222
module Redis

lib/async/redis/cluster_client.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2020, by David Ortiz.
5-
# Copyright, 2023-2024, by Samuel Williams.
4+
# Copyright, 2024, by Samuel Williams.
65

7-
require_relative 'client'
8-
require 'io/stream'
6+
require_relative "client"
7+
require "io/stream"
98

109
module Async
1110
module Redis
@@ -107,20 +106,20 @@ def reload_cluster!(endpoints = @endpoints)
107106
shards = RangeMap.new
108107
endpoints = []
109108

110-
client.call('CLUSTER', 'SHARDS').each do |shard|
109+
client.call("CLUSTER", "SHARDS").each do |shard|
111110
shard = shard.each_slice(2).to_h
112111

113-
slots = shard['slots']
112+
slots = shard["slots"]
114113
range = Range.new(*slots)
115114

116-
nodes = shard['nodes'].map do |node|
115+
nodes = shard["nodes"].map do |node|
117116
node = node.each_slice(2).to_h
118-
endpoint = Endpoint.remote(node['ip'], node['port'])
117+
endpoint = Endpoint.remote(node["ip"], node["port"])
119118

120119
# Collect all endpoints:
121120
endpoints << endpoint
122121

123-
Node.new(node['id'], endpoint, node['role'].to_sym, node['health'].to_sym)
122+
Node.new(node["id"], endpoint, node["role"].to_sym, node["health"].to_sym)
124123
end
125124

126125
shards.add(range, nodes)
@@ -193,8 +192,8 @@ def crc16(bytes)
193192
def slot_for(key)
194193
key = key.to_s
195194

196-
if s = key.index('{')
197-
if e = key.index('}', s + 1) and e != s + 1
195+
if s = key.index("{")
196+
if e = key.index("}", s + 1) and e != s + 1
198197
key = key[s + 1..e - 1]
199198
end
200199
end

lib/async/redis/context/generic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright, 2019, by Mikael Henriksson.
55
# Copyright, 2019-2023, by Samuel Williams.
66

7-
require 'protocol/redis/methods'
7+
require "protocol/redis/methods"
88

99
module Async
1010
module Redis

lib/async/redis/context/pipeline.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Copyright, 2019-2024, by Samuel Williams.
66
# Copyright, 2022, by Tim Willard.
77

8-
require_relative 'generic'
8+
require_relative "generic"
99

1010
module Async
1111
module Redis

lib/async/redis/context/subscribe.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# Released under the MIT License.
44
# Copyright, 2018, by Huba Nagy.
5-
# Copyright, 2018-2023, by Samuel Williams.
5+
# Copyright, 2018-2024, by Samuel Williams.
66

7-
require_relative 'generic'
7+
require_relative "generic"
88

99
module Async
1010
module Redis
1111
module Context
1212
class Subscribe < Generic
13-
MESSAGE = 'message'
13+
MESSAGE = "message"
1414

1515
def initialize(pool, channels)
1616
super(pool)
@@ -40,12 +40,12 @@ def each
4040
end
4141

4242
def subscribe(channels)
43-
@connection.write_request ['SUBSCRIBE', *channels]
43+
@connection.write_request ["SUBSCRIBE", *channels]
4444
@connection.flush
4545
end
4646

4747
def unsubscribe(channels)
48-
@connection.write_request ['UNSUBSCRIBE', *channels]
48+
@connection.write_request ["UNSUBSCRIBE", *channels]
4949
@connection.flush
5050
end
5151
end

0 commit comments

Comments
 (0)