redis-namespace 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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGI3Mjc4NGZmMjkyOTgyNzQ3MzMwNzAwZjkyZTk3MzE2ZjJlYTA0YQ==
5
+ data.tar.gz: !binary |-
6
+ ZGVlNjU3MDUxNDA3M2I0ZjVlYjQ5ZGJmYmYzOGNiOGJkMjI3NTUwZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NWU5MzVmOTNjMDUzOTcwYzUwYzhlZmU1NzAxZTY2M2MzMGY3MjlkYTVhNjNl
10
+ OGYyMmE1M2M1ZDY0MWZmZWIwNDA1NDk5M2VlYTcyZDliMTJmZDBhMGFiYTUx
11
+ MWMzMjJiYmFhMGE1YjlkMDM2ODY5NzFiNjM1YjQyNDBhMWQzZjc=
12
+ data.tar.gz: !binary |-
13
+ YjY1MGZkZmEzOWNhNmRhMTEzNjQ0MGNkYTQ4YWZmZjQ1YTAwNzA2MmJkZWJl
14
+ OTQ0MWQ3NWNiMzU1YjNkYzYzZGM4MTAyNGE3NTFkMTk0N2UzN2IyZThjY2Zk
15
+ NjJhODIyMGY1NzNmNThmN2E2MDUyOWJkNWU1OWZlZjA5MDdmM2I=
@@ -182,6 +182,7 @@ class Redis
182
182
  "ttl" => [ :first ],
183
183
  "type" => [ :first ],
184
184
  "unsubscribe" => [ :all ],
185
+ "unwatch" => [ :all ],
185
186
  "watch" => [ :all ],
186
187
  "zadd" => [ :first ],
187
188
  "zcard" => [ :first ],
@@ -215,7 +216,9 @@ class Redis
215
216
  def initialize(namespace, options = {})
216
217
  @namespace = namespace
217
218
  @redis = options[:redis] || Redis.current
218
- @warning = options.fetch(:warning, true)
219
+ @warning = !!options.fetch(:warning) do
220
+ !ENV['REDIS_NAMESPACE_QUIET']
221
+ end
219
222
  @deprecations = !!options.fetch(:deprecations) do
220
223
  ENV['REDIS_NAMESPACE_DEPRECATIONS']
221
224
  end
@@ -225,6 +228,10 @@ class Redis
225
228
  @deprecations
226
229
  end
227
230
 
231
+ def warning?
232
+ @warning
233
+ end
234
+
228
235
  def client
229
236
  @redis.client
230
237
  end
@@ -285,9 +292,11 @@ class Redis
285
292
  # redis-namespace does not know how to handle this command.
286
293
  # Passing it to @redis as is, where redis-namespace shows
287
294
  # a warning message if @warning is set.
288
- if @warning
295
+ if warning?
289
296
  call_site = caller.reject { |l| l.start_with?(__FILE__) }.first
290
- warn("Passing '#{command}' command to redis as is (at #{call_site})")
297
+ warn("Passing '#{command}' command to redis as is; blind " +
298
+ "passthrough has been deprecated and will be removed in " +
299
+ "redis-namespace 2.0 (at #{call_site})")
291
300
  end
292
301
  @redis.send(command, *args, &block)
293
302
  else
@@ -401,13 +410,14 @@ class Redis
401
410
  private
402
411
 
403
412
  def namespaced_block(command, &block)
404
- original = @redis
405
- result = redis.send(command) do |r|
406
- @redis = r
407
- yield self
413
+ redis.send(command) do |r|
414
+ begin
415
+ original, @redis = @redis, r
416
+ yield self
417
+ ensure
418
+ @redis = original
419
+ end
408
420
  end
409
- @redis = original
410
- result
411
421
  end
412
422
 
413
423
  def add_namespace(key)
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Redis
4
4
  class Namespace
5
- VERSION = '1.5.0'
5
+ VERSION = '1.5.1'
6
6
  end
7
7
  end
@@ -18,12 +18,18 @@ describe Redis::Namespace do
18
18
  subject { namespaced }
19
19
 
20
20
  its(:deprecations?) { should be false }
21
+ its(:warning?) { should be true }
21
22
 
22
23
  context('with REDIS_NAMESPACE_DEPRECATIONS') do
23
24
  around(:each) {|e| with_env('REDIS_NAMESPACE_DEPRECATIONS'=>'1', &e) }
24
25
  its(:deprecations?) { should be true }
25
26
  end
26
27
 
28
+ context('with REDIS_NAMESPACE_QUIET') do
29
+ around(:each) {|e| with_env('REDIS_NAMESPACE_QUIET'=>'1', &e) }
30
+ its(:warning?) { should be false }
31
+ end
32
+
27
33
  before(:each) do
28
34
  allow(redis).to receive(:unhandled) do |*args|
29
35
  "unhandled(#{args.inspect})"
@@ -73,6 +79,17 @@ describe Redis::Namespace do
73
79
  expect(warning).to include %q(Passing 'unhandled' command to redis as is)
74
80
  expect(warning).to include __FILE__
75
81
  end
82
+
83
+ context('and warnings disabled') do
84
+ let(:options) { super().merge(:warning => false)}
85
+ it 'does not warn' do
86
+ capture_stderr(stderr = StringIO.new) do
87
+ namespaced.unhandled('bar')
88
+ end
89
+ warning = stderr.tap(&:rewind).read
90
+ expect(warning).to be_empty
91
+ end
92
+ end
76
93
  end
77
94
  end
78
95
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-namespace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
5
- prerelease:
4
+ version: 1.5.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Wanstrath
@@ -12,12 +11,11 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2014-06-24 00:00:00.000000000 Z
14
+ date: 2014-08-01 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: redis
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
20
  - - ~>
23
21
  - !ruby/object:Gem::Version
@@ -28,7 +26,6 @@ dependencies:
28
26
  type: :runtime
29
27
  prerelease: false
30
28
  version_requirements: !ruby/object:Gem::Requirement
31
- none: false
32
29
  requirements:
33
30
  - - ~>
34
31
  - !ruby/object:Gem::Version
@@ -39,7 +36,6 @@ dependencies:
39
36
  - !ruby/object:Gem::Dependency
40
37
  name: rake
41
38
  requirement: !ruby/object:Gem::Requirement
42
- none: false
43
39
  requirements:
44
40
  - - ~>
45
41
  - !ruby/object:Gem::Version
@@ -47,7 +43,6 @@ dependencies:
47
43
  type: :development
48
44
  prerelease: false
49
45
  version_requirements: !ruby/object:Gem::Requirement
50
- none: false
51
46
  requirements:
52
47
  - - ~>
53
48
  - !ruby/object:Gem::Version
@@ -55,7 +50,6 @@ dependencies:
55
50
  - !ruby/object:Gem::Dependency
56
51
  name: rspec
57
52
  requirement: !ruby/object:Gem::Requirement
58
- none: false
59
53
  requirements:
60
54
  - - ~>
61
55
  - !ruby/object:Gem::Version
@@ -63,7 +57,6 @@ dependencies:
63
57
  type: :development
64
58
  prerelease: false
65
59
  version_requirements: !ruby/object:Gem::Requirement
66
- none: false
67
60
  requirements:
68
61
  - - ~>
69
62
  - !ruby/object:Gem::Version
@@ -84,39 +77,38 @@ executables: []
84
77
  extensions: []
85
78
  extra_rdoc_files: []
86
79
  files:
80
+ - LICENSE
87
81
  - README.md
88
82
  - Rakefile
89
- - LICENSE
90
- - lib/redis/namespace/version.rb
91
- - lib/redis/namespace.rb
92
83
  - lib/redis-namespace.rb
84
+ - lib/redis/namespace.rb
85
+ - lib/redis/namespace/version.rb
93
86
  - spec/deprecation_spec.rb
94
87
  - spec/redis_spec.rb
95
88
  - spec/spec_helper.rb
96
89
  homepage: http://github.com/resque/redis-namespace
97
90
  licenses:
98
91
  - MIT
92
+ metadata: {}
99
93
  post_install_message:
100
94
  rdoc_options: []
101
95
  require_paths:
102
96
  - lib
103
97
  required_ruby_version: !ruby/object:Gem::Requirement
104
- none: false
105
98
  requirements:
106
99
  - - ! '>='
107
100
  - !ruby/object:Gem::Version
108
101
  version: '0'
109
102
  required_rubygems_version: !ruby/object:Gem::Requirement
110
- none: false
111
103
  requirements:
112
104
  - - ! '>='
113
105
  - !ruby/object:Gem::Version
114
106
  version: '0'
115
107
  requirements: []
116
108
  rubyforge_project:
117
- rubygems_version: 1.8.23
109
+ rubygems_version: 2.2.2
118
110
  signing_key:
119
- specification_version: 3
111
+ specification_version: 4
120
112
  summary: Namespaces Redis commands.
121
113
  test_files: []
122
114
  has_rdoc: false