redis-namespace 0.4.4 → 0.5.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.
Potentially problematic release.
This version of redis-namespace might be problematic. Click here for more details.
- data/lib/redis/namespace.rb +6 -2
- data/spec/redis_spec.rb +20 -24
- data/spec/spec_helper.rb +6 -0
- metadata +9 -9
data/lib/redis/namespace.rb
CHANGED
@@ -125,7 +125,11 @@ class Redis
|
|
125
125
|
}
|
126
126
|
|
127
127
|
# support previous versions of redis gem
|
128
|
-
ALIASES =
|
128
|
+
ALIASES = case
|
129
|
+
when defined? Redis::Client::ALIASES then Redis::Client::ALIASES
|
130
|
+
when defined? Redis::ALIASES then Redis::ALIASES
|
131
|
+
else {}
|
132
|
+
end
|
129
133
|
|
130
134
|
attr_accessor :namespace
|
131
135
|
|
@@ -159,7 +163,7 @@ class Redis
|
|
159
163
|
args = add_namespace(args)
|
160
164
|
args.push(last) if last
|
161
165
|
when :alternate
|
162
|
-
args
|
166
|
+
args.each_with_index { |a, i| args[i] = add_namespace(a) if i.even? }
|
163
167
|
end
|
164
168
|
|
165
169
|
# Dispatch the command to Redis and store the result.
|
data/spec/redis_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe "redis" do
|
|
29
29
|
@redis['foo'] = 'bob'
|
30
30
|
@redis['foo'].should == 'bob'
|
31
31
|
|
32
|
-
@namespaced.
|
32
|
+
@namespaced.incrby('counter', 2)
|
33
33
|
@namespaced['counter'].to_i.should == 2
|
34
34
|
@redis['counter'].should == nil
|
35
35
|
@namespaced.type('counter').should == 'string'
|
@@ -54,13 +54,13 @@ describe "redis" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should be able to use a namespace with mset" do
|
57
|
-
@namespaced.mset('foo'
|
57
|
+
@namespaced.mset('foo', '1000', 'bar', '2000')
|
58
58
|
@namespaced.mapped_mget('foo', 'bar').should == { 'foo' => '1000', 'bar' => '2000' }
|
59
59
|
@namespaced.mapped_mget('foo', 'baz', 'bar').should == { 'foo' => '1000', 'bar' => '2000'}
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should be able to use a namespace with msetnx" do
|
63
|
-
@namespaced.msetnx('foo'
|
63
|
+
@namespaced.msetnx('foo', '1000', 'bar', '2000')
|
64
64
|
@namespaced.mapped_mget('foo', 'bar').should == { 'foo' => '1000', 'bar' => '2000' }
|
65
65
|
@namespaced.mapped_mget('foo', 'baz', 'bar').should == { 'foo' => '1000', 'bar' => '2000'}
|
66
66
|
end
|
@@ -115,30 +115,26 @@ describe "redis" do
|
|
115
115
|
@namespaced['foo'].should == 'chris'
|
116
116
|
end
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
@namespaced.set_add('bar', 'quux')
|
125
|
-
@namespaced.smembers('bar').should include('quux')
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should support command aliases (push_head)" do
|
129
|
-
@namespaced.push_head('bar', 'quux')
|
130
|
-
@redis.llen('ns:bar').should == 1
|
131
|
-
end
|
118
|
+
# Only test aliasing functionality for Redis clients that support aliases.
|
119
|
+
unless Redis::Namespace::ALIASES.empty?
|
120
|
+
it "should support command aliases (delete)" do
|
121
|
+
@namespaced.delete('foo')
|
122
|
+
@redis.should_not have_key('ns:foo')
|
123
|
+
end
|
132
124
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
125
|
+
it "should support command aliases (set_add)" do
|
126
|
+
@namespaced.set_add('bar', 'quux')
|
127
|
+
@namespaced.smembers('bar').should include('quux')
|
128
|
+
end
|
137
129
|
|
130
|
+
it "should support command aliases (push_head)" do
|
131
|
+
@namespaced.push_head('bar', 'quux')
|
132
|
+
@redis.llen('ns:bar').should == 1
|
133
|
+
end
|
138
134
|
|
139
|
-
|
140
|
-
|
141
|
-
redis.
|
135
|
+
it "should support command aliases (zset_add)" do
|
136
|
+
@namespaced.zset_add('bar', 1, 'quux')
|
137
|
+
@redis.zcard('ns:bar').should == 1
|
142
138
|
end
|
143
139
|
end
|
144
140
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-namespace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Wanstrath
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-05-
|
18
|
+
date: 2010-05-26 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,14 +24,14 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - <
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 7
|
30
30
|
segments:
|
31
|
-
-
|
31
|
+
- 3
|
32
32
|
- 0
|
33
33
|
- 0
|
34
|
-
version:
|
34
|
+
version: 3.0.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
description: |
|