mock_redis 0.52.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/mock_redis/database.rb +9 -4
- data/lib/mock_redis/info_method.rb +56 -26
- data/lib/mock_redis/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc774e7b8052b25ca3ca059f197038b854da5cd7d82cae73d5b786cd94fdd318
|
|
4
|
+
data.tar.gz: 674f66037a10dbae4fc547e402931d689a9a1603ffa20335e394c0b9d37db90d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4934a3233fc0f9bae10f33ced22aac334038f9d7e11563105b19ea4f591980242f16c06c73503342791415af09633189a9f7c57788cd6cf050cdda50374436a4
|
|
7
|
+
data.tar.gz: 166130d7f1cb05e56eaff5be78b52a388bf8eeed60552d95b64884b14139d931323fae97bbcc879f204a61e96e0be833f8f7d3f4d8a7712af2df8adbafe1b68b
|
data/CHANGELOG.md
CHANGED
data/lib/mock_redis/database.rb
CHANGED
|
@@ -49,13 +49,18 @@ class MockRedis
|
|
|
49
49
|
# i.e. `call("EXPIRE", "foo", 40, "NX")` (which redis-rb will simply transmit to redis-server)
|
|
50
50
|
# will be passed to `#expire` without keywords transformation.
|
|
51
51
|
def call(*command, &_block)
|
|
52
|
-
#
|
|
53
|
-
command = command
|
|
52
|
+
# flatten any nested arrays (eg from [:call, ["GET", "X"]] in pipelined commands)
|
|
53
|
+
command = command.flatten
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
cmd_name = command[0].downcase.to_s
|
|
56
|
+
|
|
57
|
+
if cmd_name.include?('expire')
|
|
56
58
|
send_expires(command)
|
|
59
|
+
elsif cmd_name == 'info'
|
|
60
|
+
# call(:info) returns a string, not a parsed hash
|
|
61
|
+
info_raw(*command[1..])
|
|
57
62
|
else
|
|
58
|
-
public_send(
|
|
63
|
+
public_send(cmd_name, *command[1..])
|
|
59
64
|
end
|
|
60
65
|
end
|
|
61
66
|
|
|
@@ -125,35 +125,65 @@ class MockRedis
|
|
|
125
125
|
}.freeze
|
|
126
126
|
# rubocop:enable Layout/LineLength
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
SERVER_INFO,
|
|
130
|
-
CLIENTS_INFO,
|
|
131
|
-
MEMORY_INFO,
|
|
132
|
-
PERSISTENCE_INFO,
|
|
133
|
-
STATS_INFO,
|
|
134
|
-
REPLICATION_INFO,
|
|
135
|
-
CPU_INFO,
|
|
136
|
-
KEYSPACE_INFO,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
SECTIONS = {
|
|
129
|
+
server: SERVER_INFO,
|
|
130
|
+
clients: CLIENTS_INFO,
|
|
131
|
+
memory: MEMORY_INFO,
|
|
132
|
+
persistence: PERSISTENCE_INFO,
|
|
133
|
+
stats: STATS_INFO,
|
|
134
|
+
replication: REPLICATION_INFO,
|
|
135
|
+
cpu: CPU_INFO,
|
|
136
|
+
keyspace: KEYSPACE_INFO,
|
|
137
|
+
commandstats: COMMAND_STATS_COMBINED_INFO,
|
|
138
|
+
}.freeze
|
|
139
|
+
SECTION_NAMES = {
|
|
140
|
+
server: 'Server',
|
|
141
|
+
clients: 'Clients',
|
|
142
|
+
memory: 'Memory',
|
|
143
|
+
persistence: 'Persistence',
|
|
144
|
+
stats: 'Stats',
|
|
145
|
+
replication: 'Replication',
|
|
146
|
+
cpu: 'Cpu',
|
|
147
|
+
keyspace: 'Keyspace',
|
|
148
|
+
commandstats: 'Commandstats',
|
|
149
|
+
}.freeze
|
|
150
|
+
DEFAULT_SECTIONS = [
|
|
151
|
+
:server, :clients, :memory, :persistence, :stats, :replication, :cpu, :keyspace
|
|
152
|
+
].freeze
|
|
153
|
+
ALL_SECTIONS = DEFAULT_SECTIONS + [:commandstats].freeze
|
|
143
154
|
|
|
144
155
|
def info(section = :default)
|
|
156
|
+
if section.to_s.downcase == 'commandstats'
|
|
157
|
+
# `redis.info(:commandstats)` gives a nested hash structure,
|
|
158
|
+
# unlike when commandstats is printed as part of `redis.info(:all)`
|
|
159
|
+
COMMAND_STATS_SOLO_INFO
|
|
160
|
+
else
|
|
161
|
+
sections = relevant_info_sections(section)
|
|
162
|
+
sections.inject({}) { |memo, name| memo.merge(SECTIONS[name]) }
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
private
|
|
167
|
+
|
|
168
|
+
# Format info hash as raw string (used by call("info"))
|
|
169
|
+
def info_raw(section = :default)
|
|
170
|
+
sections = relevant_info_sections(section)
|
|
171
|
+
sections.map do |name|
|
|
172
|
+
header = "# #{SECTION_NAMES[name]}"
|
|
173
|
+
lines = SECTIONS[name].map { |k, v| "#{k}:#{v}" }
|
|
174
|
+
[header, *lines].join("\n")
|
|
175
|
+
end.join("\n\n") << "\n"
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def relevant_info_sections(section)
|
|
179
|
+
section = section.to_s.downcase.to_sym
|
|
145
180
|
case section
|
|
146
|
-
when :default
|
|
147
|
-
|
|
148
|
-
when :
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
when :stats; STATS_INFO
|
|
153
|
-
when :replication; REPLICATION_INFO
|
|
154
|
-
when :cpu; CPU_INFO
|
|
155
|
-
when :keyspace; KEYSPACE_INFO
|
|
156
|
-
when :commandstats; COMMAND_STATS_SOLO_INFO
|
|
181
|
+
when :default
|
|
182
|
+
DEFAULT_SECTIONS
|
|
183
|
+
when :all
|
|
184
|
+
ALL_SECTIONS
|
|
185
|
+
else
|
|
186
|
+
[section]
|
|
157
187
|
end
|
|
158
188
|
end
|
|
159
189
|
end
|
data/lib/mock_redis/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mock_redis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.53.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane da Silva
|
|
8
8
|
- Samuel Merritt
|
|
9
|
+
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date: 2025-08
|
|
12
|
+
date: 2025-11-08 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: redis
|
|
@@ -124,10 +125,11 @@ licenses:
|
|
|
124
125
|
- MIT
|
|
125
126
|
metadata:
|
|
126
127
|
bug_tracker_uri: https://github.com/sds/mock_redis/issues
|
|
127
|
-
changelog_uri: https://github.com/sds/mock_redis/blob/v0.
|
|
128
|
-
documentation_uri: https://www.rubydoc.info/gems/mock_redis/0.
|
|
128
|
+
changelog_uri: https://github.com/sds/mock_redis/blob/v0.53.0/CHANGELOG.md
|
|
129
|
+
documentation_uri: https://www.rubydoc.info/gems/mock_redis/0.53.0
|
|
129
130
|
homepage_uri: https://github.com/sds/mock_redis
|
|
130
|
-
source_code_uri: https://github.com/sds/mock_redis/tree/v0.
|
|
131
|
+
source_code_uri: https://github.com/sds/mock_redis/tree/v0.53.0
|
|
132
|
+
post_install_message:
|
|
131
133
|
rdoc_options: []
|
|
132
134
|
require_paths:
|
|
133
135
|
- lib
|
|
@@ -142,7 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
142
144
|
- !ruby/object:Gem::Version
|
|
143
145
|
version: '0'
|
|
144
146
|
requirements: []
|
|
145
|
-
rubygems_version: 3.
|
|
147
|
+
rubygems_version: 3.0.3.1
|
|
148
|
+
signing_key:
|
|
146
149
|
specification_version: 4
|
|
147
150
|
summary: Redis mock that just lives in memory; useful for testing.
|
|
148
151
|
test_files: []
|