redis-objects 1.5.0 → 1.5.1
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.rdoc +17 -0
- data/README.md +10 -0
- data/lib/redis/counter.rb +2 -2
- data/lib/redis/enumerable_object.rb +1 -1
- data/lib/redis/helpers/core_commands.rb +1 -1
- data/lib/redis/objects.rb +0 -2
- data/lib/redis/objects/connection_pool_proxy.rb +1 -0
- data/lib/redis/objects/hashes.rb +9 -0
- data/lib/redis/objects/lists.rb +9 -0
- data/lib/redis/objects/sets.rb +9 -0
- data/lib/redis/objects/version.rb +1 -1
- data/lib/redis/sorted_set.rb +4 -4
- data/spec/redis_objects_instance_spec.rb +38 -9
- data/spec/redis_objects_model_spec.rb +22 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c7bc592d203647a8b7e9fd574a78eec1ec466e85fef95d30fac6d831f5d086a
|
4
|
+
data.tar.gz: e89a8a50ddac32cc8b0fd5692697c21620ef97bac6f28c1841c0e50e9a833429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a91ab932b94a4a36ab4da40d173804b71c46b21c28e917acefb5f1720da1dd60fe3e4c0d06e124c172118789c31fa11f0f4b96b7b27da97cbd8f7a90f01dd6c
|
7
|
+
data.tar.gz: d92e900d1fcec537a439e99ad7d311a83ad23c1e5c28ecc84e8922a0c7da56b4fdcfc9cadcb48aca382c4a6c8045dd24ecbeb81d681aa4fcad2c9d13b3cf9a8f
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
= Changelog for Redis::Objects
|
2
2
|
|
3
|
+
== 1.5.1 (10 Jul 2021)
|
4
|
+
|
5
|
+
* Added double-splat for **options to account for Ruby 3.0 [Nate Wiger]
|
6
|
+
|
7
|
+
* Fix ConnectionPoolProxy Ruby 3.0 compatibility Fix: https://github.com/nateware/redis-objects/pull/258 [Jean byroot Boussier]
|
8
|
+
|
9
|
+
* Change Redis#exists to Redis#exists? * bump redis version to 4.2 [Alina Hryshchuk]
|
10
|
+
|
11
|
+
* Local variable `dir` is not in use since 98226b95f35ef455f231692fdb679dfd61200a78 [Akira Matsuda]
|
12
|
+
|
13
|
+
* Issue 249: when atomic decrbyfloat fails, increment back instead of decrementing again [Slava Samoliuk]
|
14
|
+
|
15
|
+
* Update documentation to reflect ability to assign values directly [Artin Boghosian]
|
16
|
+
|
17
|
+
* Allow directly assigning values of lists, hashes and sets [Artin Boghosian]
|
18
|
+
|
19
|
+
|
3
20
|
== 1.5.0 (18 Sep 2019)
|
4
21
|
|
5
22
|
* updated README on expireat [Nate Wiger]
|
data/README.md
CHANGED
@@ -144,6 +144,7 @@ Familiar Ruby array operations Just Work (TM):
|
|
144
144
|
@team.on_base.shift
|
145
145
|
@team.on_base.length # 1
|
146
146
|
@team.on_base.delete('player2')
|
147
|
+
@team.on_base = ['player1', 'player2'] # ['player1', 'player2']
|
147
148
|
~~~
|
148
149
|
|
149
150
|
Sets work too:
|
@@ -157,6 +158,15 @@ Sets work too:
|
|
157
158
|
puts player
|
158
159
|
end
|
159
160
|
player = @team.outfielders.detect{|of| of == 'outfielder2'}
|
161
|
+
@team.outfielders = ['outfielder1', 'outfielder3'] # ['outfielder1', 'outfielder3']
|
162
|
+
~~~
|
163
|
+
|
164
|
+
Hashes work too:
|
165
|
+
|
166
|
+
~~~ruby
|
167
|
+
@team.pitchers_faced['player1'] = 'pitcher2'
|
168
|
+
@team.pitchers_faced['player2'] = 'pitcher1'
|
169
|
+
@team.pitchers_faced = { 'player1' => 'pitcher2', 'player2' => 'pitcher1' }
|
160
170
|
~~~
|
161
171
|
|
162
172
|
And you can do unions and intersections between objects (kinda cool):
|
data/lib/redis/counter.rb
CHANGED
@@ -102,7 +102,7 @@ class Redis
|
|
102
102
|
def decrbyfloat(by=1.0, &block)
|
103
103
|
allow_expiration do
|
104
104
|
val = redis.incrbyfloat(key, -by).to_f
|
105
|
-
block_given? ? rewindable_block(:incrbyfloat,
|
105
|
+
block_given? ? rewindable_block(:incrbyfloat, by, val, &block) : val
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -112,7 +112,7 @@ class Redis
|
|
112
112
|
alias_method :to_i, :value
|
113
113
|
|
114
114
|
def nil?
|
115
|
-
!redis.exists(key)
|
115
|
+
!redis.exists?(key)
|
116
116
|
end
|
117
117
|
|
118
118
|
##
|
@@ -16,7 +16,7 @@ class Redis
|
|
16
16
|
def sort(options={})
|
17
17
|
return super() if block_given?
|
18
18
|
options[:order] = "asc alpha" if options.keys.count == 0 # compat with Ruby
|
19
|
-
val = redis.sort(key, options)
|
19
|
+
val = redis.sort(key, **options)
|
20
20
|
val.is_a?(Array) ? val.map{|v| unmarshal(v)} : val
|
21
21
|
end
|
22
22
|
|
data/lib/redis/objects.rb
CHANGED
@@ -9,6 +9,7 @@ class Redis
|
|
9
9
|
def method_missing(name, *args, &block)
|
10
10
|
@pool.with { |x| x.send(name, *args, &block) }
|
11
11
|
end
|
12
|
+
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
12
13
|
|
13
14
|
def respond_to_missing?(name, include_all = false)
|
14
15
|
@pool.with { |x| x.respond_to?(name, include_all) }
|
data/lib/redis/objects/hashes.rb
CHANGED
data/lib/redis/objects/lists.rb
CHANGED
data/lib/redis/objects/sets.rb
CHANGED
data/lib/redis/sorted_set.rb
CHANGED
@@ -117,7 +117,7 @@ class Redis
|
|
117
117
|
options[:offset] || options[:limit] || options[:count]
|
118
118
|
args[:with_scores] = true if options[:withscores] || options[:with_scores]
|
119
119
|
|
120
|
-
redis.zrangebyscore(key, min, max, args).map{|v| unmarshal(v) }
|
120
|
+
redis.zrangebyscore(key, min, max, **args).map{|v| unmarshal(v) }
|
121
121
|
end
|
122
122
|
|
123
123
|
# Returns all the elements in the sorted set at key with a score between max and min
|
@@ -133,7 +133,7 @@ class Redis
|
|
133
133
|
options[:offset] || options[:limit] || options[:count]
|
134
134
|
args[:with_scores] = true if options[:withscores] || options[:with_scores]
|
135
135
|
|
136
|
-
redis.zrevrangebyscore(key, max, min, args).map{|v| unmarshal(v) }
|
136
|
+
redis.zrevrangebyscore(key, max, min, **args).map{|v| unmarshal(v) }
|
137
137
|
end
|
138
138
|
|
139
139
|
# Remove all elements in the sorted set at key with rank between start and end. Start and end are
|
@@ -222,7 +222,7 @@ class Redis
|
|
222
222
|
def interstore(name, *sets)
|
223
223
|
allow_expiration do
|
224
224
|
opts = sets.last.is_a?(Hash) ? sets.pop : {}
|
225
|
-
redis.zinterstore(key_from_object(name), keys_from_objects([self] + sets), opts)
|
225
|
+
redis.zinterstore(key_from_object(name), keys_from_objects([self] + sets), **opts)
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -258,7 +258,7 @@ class Redis
|
|
258
258
|
def unionstore(name, *sets)
|
259
259
|
allow_expiration do
|
260
260
|
opts = sets.last.is_a?(Hash) ? sets.pop : {}
|
261
|
-
redis.zunionstore(key_from_object(name), keys_from_objects([self] + sets), opts)
|
261
|
+
redis.zunionstore(key_from_object(name), keys_from_objects([self] + sets), **opts)
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
@@ -505,15 +505,44 @@ describe Redis::Counter do
|
|
505
505
|
@counter = Redis::Counter.new("spec/block_counter")
|
506
506
|
@counter.should == 0
|
507
507
|
@counter.increment(1)
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
508
|
+
|
509
|
+
# successfully increments
|
510
|
+
@updated = @counter.increment(1) { |updated| updated == 2 ? 'yep' : nil }
|
511
|
+
@updated.should == 'yep'
|
512
|
+
@counter.should == 2
|
513
|
+
|
514
|
+
# fails to increment
|
515
|
+
@updated = @counter.increment(1) { |updated| updated == 2 ? 'yep' : nil }
|
516
|
+
@updated.should == nil
|
517
|
+
@counter.should == 2
|
518
|
+
|
519
|
+
# successfully increments by float
|
520
|
+
@updated = @counter.incrbyfloat(1.5) { |updated| updated == 3.5 ? 'yep' : nil }
|
521
|
+
@updated.should == 'yep'
|
522
|
+
@counter.should == 3.5
|
523
|
+
|
524
|
+
# fails to increment by float
|
525
|
+
@updated = @counter.incrbyfloat(2.5) { |updated| updated == 5 ? 'yep' : nil }
|
526
|
+
@updated.should == nil
|
527
|
+
@counter.should == 3.5
|
528
|
+
|
529
|
+
# fails to decrement by float
|
530
|
+
@updated = @counter.decrbyfloat(0.5) { |updated| updated == 5 ? 'yep' : nil }
|
531
|
+
@updated.should == nil
|
532
|
+
@counter.should == 3.5
|
533
|
+
|
534
|
+
# successfully decrements by float
|
535
|
+
@updated = @counter.decrbyfloat(0.5) { |updated| updated == 3 ? 'yep' : nil }
|
536
|
+
@updated.should == 'yep'
|
537
|
+
@counter.should == 3
|
538
|
+
|
539
|
+
# fails to decrement
|
540
|
+
@updated = @counter.decrement(1) { |updated| updated == 3 ? 'yep' : nil }
|
541
|
+
@updated.should == nil
|
542
|
+
@counter.should == 3
|
543
|
+
|
544
|
+
# successfully decrements
|
545
|
+
@updated = @counter.decrement(1) { |updated| updated == 2 ? 'yep' : nil }
|
517
546
|
@updated.should == 'yep'
|
518
547
|
@counter.should == 2
|
519
548
|
end
|
@@ -162,6 +162,14 @@ describe Redis::Objects do
|
|
162
162
|
@roster.redis.get(k).should == '1'
|
163
163
|
end
|
164
164
|
|
165
|
+
it "should be able to directly assign value of hash" do
|
166
|
+
@roster.contact_information['John_Name'] = 'John Doe'
|
167
|
+
@roster.contact_information = { 'John_Phone' => '12345678', 'John_Address' => '321 LANE' }
|
168
|
+
@roster.contact_information['John_Phone'].should == '12345678'
|
169
|
+
@roster.contact_information['John_Address'].should == '321 LANE'
|
170
|
+
@roster.contact_information['John_Name'].should.be.nil
|
171
|
+
end
|
172
|
+
|
165
173
|
it "should be able to get/set contact info" do
|
166
174
|
@roster.contact_information['John_Phone'] = '123415352'
|
167
175
|
@roster.contact_information['John_Address'] = '123 LANE'
|
@@ -485,6 +493,12 @@ describe Redis::Objects do
|
|
485
493
|
@roster.starting_pitcher.should.be.nil
|
486
494
|
end
|
487
495
|
|
496
|
+
it "should be able to directly assign value of list" do
|
497
|
+
@roster.player_stats << 'c'
|
498
|
+
@roster.player_stats = ['a', 'b']
|
499
|
+
@roster.player_stats.get.should == ['a', 'b']
|
500
|
+
end
|
501
|
+
|
488
502
|
it "should handle lists of simple values" do
|
489
503
|
@roster.player_stats.should.be.empty
|
490
504
|
@roster.player_stats << 'a'
|
@@ -559,6 +573,14 @@ describe Redis::Objects do
|
|
559
573
|
@roster.player_stats.get.should == ['a','c','f','j','h','i','a']
|
560
574
|
end
|
561
575
|
|
576
|
+
it "should be able to directly assign values of set" do
|
577
|
+
@roster.outfielders << 'c'
|
578
|
+
@roster.outfielders = ['a', 'b']
|
579
|
+
@roster.outfielders.member?('a').should.be.true
|
580
|
+
@roster.outfielders.member?('b').should.be.true
|
581
|
+
@roster.outfielders.member?('c').should.be.false
|
582
|
+
end
|
583
|
+
|
562
584
|
it "should handle sets of simple values" do
|
563
585
|
@roster.outfielders.should.be.empty
|
564
586
|
@roster.outfielders << 'a' << 'a' << 'a'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Wiger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4.
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4.
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,7 +171,7 @@ homepage: http://github.com/nateware/redis-objects
|
|
171
171
|
licenses:
|
172
172
|
- Artistic-2.0
|
173
173
|
metadata: {}
|
174
|
-
post_install_message:
|
174
|
+
post_install_message:
|
175
175
|
rdoc_options: []
|
176
176
|
require_paths:
|
177
177
|
- lib
|
@@ -186,8 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
190
|
-
signing_key:
|
189
|
+
rubygems_version: 3.2.15
|
190
|
+
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Map Redis types directly to Ruby objects
|
193
193
|
test_files:
|