mock_redis 0.43.0 → 0.45.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 969253c25125b742381d6aead58cd6409bf484b017139b1962dafdd0e22fe6b1
4
- data.tar.gz: 0a53a3fd81ae5703b36c945c474502c128d8bc46c1128c7e2e679b9a4c93f790
3
+ metadata.gz: 5d1b68c8d02b25dcd30e463797ca26ad87142cbba1e85f43ef635e59adc1b6f2
4
+ data.tar.gz: 7daf9875e33a704d73917a83d71878ea931671c5a34d4382b3b8f888b98c18ff
5
5
  SHA512:
6
- metadata.gz: 5e581129197ec6decf7e8dfecff284cadf315422108ec41c2ad8ca98ae1dad8b0eddec710985bd48b2618457d00b1fa7d6fc114151b02b7cc6eac744d4ffc960
7
- data.tar.gz: bb55f3ee896fe5037d40dce8b45fc57f432f34b5c96a9731c8c0f6ebcaf619025eba72b837c5b2a7a82cba6c91abbff6e8801678136b326bf3513938318a3317
6
+ metadata.gz: 60b2f391b1ce3e8bce7986bdc19918c5ef5f8453bcea9ffc0ced69e61fd8233ade6c93a9efa71aff4ec7f8b348b8737a1347bb2494f7d5f6587c32a2c4698a18
7
+ data.tar.gz: 9dd87f2dfae5a2fd7e97cbc3f8396b70f5cc6f30d29d1c9f3b5849b60b7180d02a32a17e8686f9cdc716cbb44d04ae411839aaa518d4da70cc07cca9b1893f66
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # MockRedis Changelog
2
2
 
3
+ ### 0.45.0
4
+
5
+ * Add support for `count` argument of `rpop`
6
+
7
+ ### 0.44.0
8
+
9
+ * Add support for `memory usage` command
10
+
3
11
  ### 0.43.0
4
12
 
5
13
  * Fix issue when using with `redis-store` gem
data/README.md CHANGED
@@ -27,13 +27,12 @@ call the same methods on it as you can call on a real `Redis` object.
27
27
 
28
28
  For example:
29
29
 
30
- >> require 'mock_redis'
31
- >> mr = MockRedis.new
32
- >> mr.set('some key', 'some value')
33
- => "OK"
34
- >> mr.get('some key')
35
- => "some value"
36
-
30
+ ```ruby
31
+ require 'mock_redis'
32
+ mr = MockRedis.new
33
+ mr.set('some key', 'some value') # => "OK"
34
+ mr.get('some key') # => "some value"
35
+ ```
37
36
  ## Supported Features
38
37
 
39
38
  mock_redis supports most of the methods that redis-rb does. Examples
@@ -12,6 +12,7 @@ require 'mock_redis/utility_methods'
12
12
  require 'mock_redis/geospatial_methods'
13
13
  require 'mock_redis/stream_methods'
14
14
  require 'mock_redis/connection_method'
15
+ require 'mock_redis/memory_method'
15
16
 
16
17
  class MockRedis
17
18
  class Database
@@ -26,6 +27,7 @@ class MockRedis
26
27
  include GeospatialMethods
27
28
  include StreamMethods
28
29
  include ConnectionMethod
30
+ include MemoryMethod
29
31
 
30
32
  attr_reader :data, :expire_times
31
33
 
@@ -186,8 +186,13 @@ class MockRedis
186
186
  end
187
187
  end
188
188
 
189
- def rpop(key)
190
- with_list_at(key) { |list| list&.pop }
189
+ def rpop(key, count = nil)
190
+ return with_list_at(key) { |list| list&.pop } if count.nil?
191
+
192
+ record_count = llen(key)
193
+ return nil if record_count.zero?
194
+
195
+ [record_count, count].min.times.map { with_list_at(key, &:pop) }
191
196
  end
192
197
 
193
198
  def rpoplpush(source, destination)
@@ -0,0 +1,11 @@
1
+ class MockRedis
2
+ module MemoryMethod
3
+ def memory(usage, key = nil, *_options)
4
+ raise ArgumentError, "unhandled command `memory #{usage}`" if usage != 'usage'
5
+
6
+ return nil unless @data.key?(key)
7
+
8
+ 160
9
+ end
10
+ end
11
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  class MockRedis
5
- VERSION = '0.43.0'
5
+ VERSION = '0.45.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.45.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-17 00:00:00.000000000 Z
12
+ date: 2024-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -104,6 +104,7 @@ files:
104
104
  - lib/mock_redis/indifferent_hash.rb
105
105
  - lib/mock_redis/info_method.rb
106
106
  - lib/mock_redis/list_methods.rb
107
+ - lib/mock_redis/memory_method.rb
107
108
  - lib/mock_redis/multi_db_wrapper.rb
108
109
  - lib/mock_redis/pipelined_wrapper.rb
109
110
  - lib/mock_redis/set_methods.rb
@@ -123,10 +124,10 @@ licenses:
123
124
  - MIT
124
125
  metadata:
125
126
  bug_tracker_uri: https://github.com/sds/mock_redis/issues
126
- changelog_uri: https://github.com/sds/mock_redis/blob/v0.43.0/CHANGELOG.md
127
- documentation_uri: https://www.rubydoc.info/gems/mock_redis/0.43.0
127
+ changelog_uri: https://github.com/sds/mock_redis/blob/v0.45.0/CHANGELOG.md
128
+ documentation_uri: https://www.rubydoc.info/gems/mock_redis/0.45.0
128
129
  homepage_uri: https://github.com/sds/mock_redis
129
- source_code_uri: https://github.com/sds/mock_redis/tree/v0.43.0
130
+ source_code_uri: https://github.com/sds/mock_redis/tree/v0.45.0
130
131
  post_install_message:
131
132
  rdoc_options: []
132
133
  require_paths:
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
143
  - !ruby/object:Gem::Version
143
144
  version: '0'
144
145
  requirements: []
145
- rubygems_version: 3.4.10
146
+ rubygems_version: 3.5.9
146
147
  signing_key:
147
148
  specification_version: 4
148
149
  summary: Redis mock that just lives in memory; useful for testing.