redis 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require 'socket'
2
2
 
3
3
  class Redis
4
- VERSION = "2.0.4"
4
+ VERSION = "2.0.5"
5
5
 
6
6
  class ProtocolError < RuntimeError
7
7
  def initialize(reply_type)
@@ -16,6 +16,8 @@ class Redis
16
16
  attr :client
17
17
 
18
18
  def self.connect(options = {})
19
+ options = options.dup
20
+
19
21
  require "uri"
20
22
 
21
23
  url = URI(options.delete(:url) || ENV["REDIS_URL"] || "redis://127.0.0.1:6379/0")
@@ -267,25 +267,20 @@ class Redis
267
267
  end
268
268
  end
269
269
 
270
- if RUBY_VERSION >= "1.9"
271
- require "timeout"
270
+ begin
271
+ require "system_timer"
272
272
 
273
273
  def with_timeout(seconds, &block)
274
- Timeout.timeout(seconds, &block)
274
+ SystemTimer.timeout_after(seconds, &block)
275
275
  end
276
- else
277
- begin
278
- require "system_timer"
279
276
 
280
- def with_timeout(seconds, &block)
281
- SystemTimer.timeout_after(seconds, &block)
282
- end
283
- rescue LoadError
284
- $stderr.puts "WARNING: Could not find a good alternative for performing time outs -- connecting to Redis will not time out. Try installing the SystemTimer gem."
277
+ rescue LoadError
278
+ warn "WARNING: using the built-in Timeout class which is known to have issues when used for opening connections. Install the SystemTimer gem if you want to make sure the Redis client will not hang." unless RUBY_VERSION >= "1.9" || RUBY_PLATFORM =~ /java/
285
279
 
286
- def with_timeout(*args)
287
- yield
288
- end
280
+ require "timeout"
281
+
282
+ def with_timeout(seconds, &block)
283
+ Timeout.timeout(seconds, &block)
289
284
  end
290
285
  end
291
286
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
4
  prerelease: false
6
5
  segments:
7
6
  - 2
8
7
  - 0
9
- - 4
10
- version: 2.0.4
8
+ - 5
9
+ version: 2.0.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - Ezra Zygmuntowicz
@@ -22,7 +21,7 @@ autorequire: redis
22
21
  bindir: bin
23
22
  cert_chain: []
24
23
 
25
- date: 2010-07-22 00:00:00 -03:00
24
+ date: 2010-07-30 00:00:00 -03:00
26
25
  default_executable:
27
26
  dependencies: []
28
27
 
@@ -44,7 +43,6 @@ files:
44
43
  - lib/redis/hash_ring.rb
45
44
  - lib/redis/pipeline.rb
46
45
  - lib/redis/subscribe.rb
47
- - lib/redis/url.rb
48
46
  - lib/redis.rb
49
47
  has_rdoc: true
50
48
  homepage: http://github.com/ezmobius/redis-rb
@@ -60,7 +58,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
58
  requirements:
61
59
  - - ">="
62
60
  - !ruby/object:Gem::Version
63
- hash: 3
64
61
  segments:
65
62
  - 0
66
63
  version: "0"
@@ -69,7 +66,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
66
  requirements:
70
67
  - - ">="
71
68
  - !ruby/object:Gem::Version
72
- hash: 3
73
69
  segments:
74
70
  - 0
75
71
  version: "0"
@@ -1,69 +0,0 @@
1
- require "uri/generic"
2
-
3
- module URI
4
- class Redis < Generic
5
- DEFAULT_PORT = 6379
6
-
7
- COMPONENT = [:scheme, :password, :host, :port, :db].freeze
8
-
9
- def db
10
- path[1..-1].to_i
11
- end
12
-
13
- alias password user
14
-
15
- protected
16
- def check_path(value)
17
- if super(value)
18
- end
19
- end
20
- end
21
-
22
- @@schemes["REDIS"] = Redis
23
- end
24
- require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
25
- require "redis/url"
26
-
27
- class RedisURLTest < Test::Unit::TestCase
28
- test "default values" do
29
- uri = URI.parse("redis://localhost")
30
-
31
- assert_equal "localhost", uri.host
32
- assert_equal 6379, uri.port
33
- assert_equal 0, uri.db
34
- assert_equal nil, uri.password
35
- end
36
-
37
- test "password" do
38
- uri = URI.parse("redis://secret@localhost")
39
-
40
- assert_equal "localhost", uri.host
41
- assert_equal 6379, uri.port
42
- assert_equal 0, uri.db
43
- assert_equal "secret", uri.password
44
- end
45
-
46
- test "db number" do
47
- uri = URI.parse("redis://secret@localhost/15")
48
-
49
- assert_equal "localhost", uri.host
50
- assert_equal 6379, uri.port
51
- assert_equal 15, uri.db
52
- assert_equal "secret", uri.password
53
- end
54
-
55
- test "port" do
56
- uri = URI.parse("redis://localhost:6380")
57
-
58
- assert_equal "localhost", uri.host
59
- assert_equal 6380, uri.port
60
- assert_equal 0, uri.db
61
- assert_equal nil, uri.password
62
- end
63
-
64
- test "to_s" do
65
- uri = URI.parse("redis://secret@localhost:6380/15")
66
-
67
- assert_equal "redis://secret@localhost:6380/15", uri.to_s
68
- end
69
- end