redis-namespace 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redis-namespace might be problematic. Click here for more details.
- data/LICENSE +20 -0
- data/README.md +1 -1
- data/Rakefile +9 -1
- data/lib/redis/namespace.rb +1 -1
- data/spec/redis_spec.rb +22 -21
- metadata +4 -2
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Chris Wanstrath
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
task :default => :spec
|
2
|
+
task :test => :spec
|
3
|
+
|
4
|
+
desc "Run specs"
|
5
|
+
task :spec do
|
6
|
+
exec "spec spec/redis_spec.rb"
|
7
|
+
end
|
8
|
+
|
1
9
|
begin
|
2
10
|
require 'jeweler'
|
3
11
|
Jeweler::Tasks.new do |gemspec|
|
@@ -7,7 +15,7 @@ begin
|
|
7
15
|
gemspec.email = "chris@ozmm.org"
|
8
16
|
gemspec.homepage = "http://github.com/defunkt/redis-namespace"
|
9
17
|
gemspec.authors = ["Chris Wanstrath"]
|
10
|
-
gemspec.version = '0.1.
|
18
|
+
gemspec.version = '0.1.1'
|
11
19
|
end
|
12
20
|
rescue LoadError
|
13
21
|
puts "Jeweler not available. Install it with:"
|
data/lib/redis/namespace.rb
CHANGED
data/spec/redis_spec.rb
CHANGED
@@ -5,41 +5,42 @@ require 'logger'
|
|
5
5
|
describe "redis" do
|
6
6
|
before(:all) do
|
7
7
|
# use database 15 for testing so we dont accidentally step on you real data
|
8
|
-
@
|
8
|
+
@redis = Redis.new :db => 15
|
9
|
+
@namespaced = Redis::Namespace.new(:ns, :redis => @redis)
|
9
10
|
end
|
10
11
|
|
11
12
|
before(:each) do
|
12
|
-
@
|
13
|
+
@namespaced.flushdb
|
14
|
+
@redis['foo'] = 'bar'
|
13
15
|
end
|
14
16
|
|
15
17
|
after(:each) do
|
16
|
-
@
|
18
|
+
@redis.flushdb
|
17
19
|
end
|
18
20
|
|
19
21
|
after(:all) do
|
20
|
-
@
|
22
|
+
@redis.quit
|
21
23
|
end
|
24
|
+
|
22
25
|
it "should be able to use a namespace" do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@
|
30
|
-
@
|
31
|
-
|
32
|
-
|
33
|
-
r['counter'].to_i.should == 2
|
34
|
-
@r['counter'].should == nil
|
26
|
+
@namespaced['foo'].should == nil
|
27
|
+
@namespaced['foo'] = 'chris'
|
28
|
+
@namespaced['foo'].should == 'chris'
|
29
|
+
@redis['foo'] = 'bob'
|
30
|
+
@redis['foo'].should == 'bob'
|
31
|
+
|
32
|
+
@namespaced.incr('counter', 2)
|
33
|
+
@namespaced['counter'].to_i.should == 2
|
34
|
+
@redis['counter'].should == nil
|
35
|
+
@namespaced.type('counter').should == 'string'
|
35
36
|
end
|
36
37
|
|
37
38
|
it "should be able to use a namespace with mget" do
|
38
|
-
r = Redis::Namespace.new(:ns, :redis => @
|
39
|
+
r = Redis::Namespace.new(:ns, :redis => @redis)
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
@namespaced['foo'] = 1000
|
42
|
+
@namespaced['bar'] = 2000
|
43
|
+
@namespaced.mapped_mget('foo', 'bar').should == { 'foo' => '1000', 'bar' => '2000' }
|
44
|
+
@namespaced.mapped_mget('foo', 'baz', 'bar').should == {'foo'=>'1000', 'bar'=>'2000'}
|
44
45
|
end
|
45
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-namespace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-15 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,8 +20,10 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
+
- LICENSE
|
23
24
|
- README.md
|
24
25
|
files:
|
26
|
+
- LICENSE
|
25
27
|
- README.md
|
26
28
|
- Rakefile
|
27
29
|
- lib/redis/namespace.rb
|