redis-namespace 1.5.3 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8a331998a5b4c5b9f5f323da912dc2e4555a2db
4
- data.tar.gz: da08789df8269adf261ff47f7c1da894718ddc88
3
+ metadata.gz: '08244a1c35f2f0164e72385ebd64aae7c57354b6'
4
+ data.tar.gz: dd76131303f0cbb576780146d9c5e3a759302e57
5
5
  SHA512:
6
- metadata.gz: 68d3325257b3c5a9ba0a7e461c39d30ce9de639304e8926e809e5f51256c5da41a8cdb2f29a5c2cd5c700032dc6d4e5b42be3e29327bcdaf0439c93f4db03f0a
7
- data.tar.gz: cffdb70935cade3a38e66e46a71ad9082afb074ebbbc05627113b6504e5b6337ec8c917734eeaf871e6dea271e9483bdfa11b22bdf1b772eab04e0f973fc3bdc
6
+ metadata.gz: 4ca1e49aaf2c9e213a0859d1a0bda67f988ddf3a5af08bbf08388a8582298659d6a6869b7d8ee035501d8abf35779be20164dff5b849110f75f173cafb3444e5
7
+ data.tar.gz: ca1151681a327f2206370a12f63729ee4f9a0891830274fc0e219353137f09216757421cfb4d4d29c18f73ca2f6e2b7bcf8ff4a0dc55a88324cd0aa7957f2993
@@ -241,6 +241,7 @@ class Redis
241
241
  @deprecations = !!options.fetch(:deprecations) do
242
242
  ENV['REDIS_NAMESPACE_DEPRECATIONS']
243
243
  end
244
+ @has_new_client_method = @redis.respond_to?(:_client)
244
245
  end
245
246
 
246
247
  def deprecations?
@@ -252,7 +253,13 @@ class Redis
252
253
  end
253
254
 
254
255
  def client
255
- @redis.client
256
+ warn("The client method is deprecated as of redis-rb 4.0.0, please use the new _client" +
257
+ "method instead. Support for the old method will be removed in redis-namespace 2.0.") if @has_new_client_method
258
+ _client
259
+ end
260
+
261
+ def _client
262
+ @has_new_client_method ? @redis._client : @redis.client # for redis-4.0.0
256
263
  end
257
264
 
258
265
  # Ruby defines a now deprecated type method so we need to override it here
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Redis
4
4
  class Namespace
5
- VERSION = '1.5.3'
5
+ VERSION = '1.6.0'
6
6
  end
7
7
  end
@@ -4,6 +4,7 @@ require File.dirname(__FILE__) + '/spec_helper'
4
4
 
5
5
  describe "redis" do
6
6
  @redis_version = Gem::Version.new(Redis.current.info["redis_version"])
7
+ let(:redis_client) { @redis.respond_to?(:_client) ? @redis._client : @redis.client}
7
8
 
8
9
  before(:all) do
9
10
  # use database 15 for testing so we dont accidentally step on your real data
@@ -13,7 +14,7 @@ describe "redis" do
13
14
  before(:each) do
14
15
  @namespaced = Redis::Namespace.new(:ns, :redis => @redis)
15
16
  @redis.flushdb
16
- @redis['foo'] = 'bar'
17
+ @redis.set('foo', 'bar')
17
18
  end
18
19
 
19
20
  after(:each) do
@@ -24,20 +25,24 @@ describe "redis" do
24
25
  @redis.quit
25
26
  end
26
27
 
27
- it "proxies `client` to the client" do
28
- @namespaced.client.should eq(@redis.client)
28
+ it "proxies `client` to the _client and deprecated" do
29
+ @namespaced.client.should eq(redis_client)
30
+ end
31
+
32
+ it "proxies `_client` to the _client" do
33
+ @namespaced._client.should eq(redis_client)
29
34
  end
30
35
 
31
36
  it "should be able to use a namespace" do
32
- @namespaced['foo'].should eq(nil)
33
- @namespaced['foo'] = 'chris'
34
- @namespaced['foo'].should eq('chris')
35
- @redis['foo'] = 'bob'
36
- @redis['foo'].should eq('bob')
37
+ @namespaced.get('foo').should eq(nil)
38
+ @namespaced.set('foo', 'chris')
39
+ @namespaced.get('foo').should eq('chris')
40
+ @redis.set('foo', 'bob')
41
+ @redis.get('foo').should eq('bob')
37
42
 
38
43
  @namespaced.incrby('counter', 2)
39
- @namespaced['counter'].to_i.should eq(2)
40
- @redis['counter'].should eq(nil)
44
+ @namespaced.get('counter').to_i.should eq(2)
45
+ @redis.get('counter').should eq(nil)
41
46
  @namespaced.type('counter').should eq('string')
42
47
  end
43
48
 
@@ -60,21 +65,21 @@ describe "redis" do
60
65
  end
61
66
 
62
67
  it "should be able to use a namespace with del" do
63
- @namespaced['foo'] = 1000
64
- @namespaced['bar'] = 2000
65
- @namespaced['baz'] = 3000
68
+ @namespaced.set('foo', 1000)
69
+ @namespaced.set('bar', 2000)
70
+ @namespaced.set('baz', 3000)
66
71
  @namespaced.del 'foo'
67
- @namespaced['foo'].should eq(nil)
72
+ @namespaced.get('foo').should eq(nil)
68
73
  @namespaced.del 'bar', 'baz'
69
- @namespaced['bar'].should eq(nil)
70
- @namespaced['baz'].should eq(nil)
74
+ @namespaced.get('bar').should eq(nil)
75
+ @namespaced.get('baz').should eq(nil)
71
76
  end
72
77
 
73
78
  it 'should be able to use a namespace with append' do
74
- @namespaced['foo'] = 'bar'
79
+ @namespaced.set('foo', 'bar')
75
80
  @namespaced.append('foo','n').should eq(4)
76
- @namespaced['foo'].should eq('barn')
77
- @redis['foo'].should eq('bar')
81
+ @namespaced.get('foo').should eq('barn')
82
+ @redis.get('foo').should eq('bar')
78
83
  end
79
84
 
80
85
  it 'should be able to use a namespace with brpoplpush' do
@@ -124,15 +129,15 @@ describe "redis" do
124
129
 
125
130
  it 'should be able to use a namespace with setrange' do
126
131
  @namespaced.setrange('foo', 0, 'bar')
127
- @namespaced['foo'].should eq('bar')
132
+ @namespaced.get('foo').should eq('bar')
128
133
 
129
134
  @namespaced.setrange('bar', 2, 'foo')
130
- @namespaced['bar'].should eq("\000\000foo")
135
+ @namespaced.get('bar').should eq("\000\000foo")
131
136
  end
132
137
 
133
138
  it "should be able to use a namespace with mget" do
134
- @namespaced['foo'] = 1000
135
- @namespaced['bar'] = 2000
139
+ @namespaced.set('foo', 1000)
140
+ @namespaced.set('bar', 2000)
136
141
  @namespaced.mapped_mget('foo', 'bar').should eq({ 'foo' => '1000', 'bar' => '2000' })
137
142
  @namespaced.mapped_mget('foo', 'baz', 'bar').should eq({'foo'=>'1000', 'bar'=>'2000', 'baz' => nil})
138
143
  end
@@ -276,9 +281,9 @@ describe "redis" do
276
281
  end
277
282
 
278
283
  it "should yield the correct list of keys" do
279
- @namespaced["foo"] = 1
280
- @namespaced["bar"] = 2
281
- @namespaced["baz"] = 3
284
+ @namespaced.set("foo", 1)
285
+ @namespaced.set("bar", 2)
286
+ @namespaced.set("baz", 3)
282
287
  @namespaced.keys("*").sort.should eq(%w( bar baz foo ))
283
288
  @namespaced.keys.sort.should eq(%w( bar baz foo ))
284
289
  end
@@ -322,8 +327,8 @@ describe "redis" do
322
327
  it "should returned response array from pipelined block" do
323
328
  @namespaced.mset "foo", "bar", "key", "value"
324
329
  result = @namespaced.pipelined do |r|
325
- r["foo"]
326
- r["key"]
330
+ r.get("foo")
331
+ r.get("key")
327
332
  end
328
333
  result.should eq(["bar", "value"])
329
334
  end
@@ -344,32 +349,32 @@ describe "redis" do
344
349
  end
345
350
 
346
351
  it "can change its namespace" do
347
- @namespaced['foo'].should eq(nil)
348
- @namespaced['foo'] = 'chris'
349
- @namespaced['foo'].should eq('chris')
352
+ @namespaced.get('foo').should eq(nil)
353
+ @namespaced.set('foo', 'chris')
354
+ @namespaced.get('foo').should eq('chris')
350
355
 
351
356
  @namespaced.namespace.should eq(:ns)
352
357
  @namespaced.namespace = :spec
353
358
  @namespaced.namespace.should eq(:spec)
354
359
 
355
- @namespaced['foo'].should eq(nil)
356
- @namespaced['foo'] = 'chris'
357
- @namespaced['foo'].should eq('chris')
360
+ @namespaced.get('foo').should eq(nil)
361
+ @namespaced.set('foo', 'chris')
362
+ @namespaced.get('foo').should eq('chris')
358
363
  end
359
364
 
360
365
  it "can accept a temporary namespace" do
361
366
  @namespaced.namespace.should eq(:ns)
362
- @namespaced['foo'].should eq(nil)
367
+ @namespaced.get('foo').should eq(nil)
363
368
 
364
369
  @namespaced.namespace(:spec) do |temp_ns|
365
370
  temp_ns.namespace.should eq(:spec)
366
- temp_ns['foo'].should eq(nil)
367
- temp_ns['foo'] = 'jake'
368
- temp_ns['foo'].should eq('jake')
371
+ temp_ns.get('foo').should eq(nil)
372
+ temp_ns.set('foo', 'jake')
373
+ temp_ns.get('foo').should eq('jake')
369
374
  end
370
375
 
371
376
  @namespaced.namespace.should eq(:ns)
372
- @namespaced['foo'].should eq(nil)
377
+ @namespaced.get('foo').should eq(nil)
373
378
  end
374
379
 
375
380
  it "should respond to :namespace=" do
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: 1.5.3
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -11,15 +11,12 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-02-16 00:00:00.000000000 Z
14
+ date: 2017-11-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: redis
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
21
- - !ruby/object:Gem::Version
22
- version: '3.0'
23
20
  - - ">="
24
21
  - !ruby/object:Gem::Version
25
22
  version: 3.0.4
@@ -27,9 +24,6 @@ dependencies:
27
24
  prerelease: false
28
25
  version_requirements: !ruby/object:Gem::Requirement
29
26
  requirements:
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: '3.0'
33
27
  - - ">="
34
28
  - !ruby/object:Gem::Version
35
29
  version: 3.0.4
@@ -103,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
97
  version: '0'
104
98
  requirements: []
105
99
  rubyforge_project:
106
- rubygems_version: 2.5.1
100
+ rubygems_version: 2.5.2
107
101
  signing_key:
108
102
  specification_version: 4
109
103
  summary: Namespaces Redis commands.