em-hiredis 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1 (2013-04-22)
4
+
5
+ [NEW] Support for connecting to redis on a unix socket.
6
+
7
+ [CHANGED] Redis error reply message now used as message for RedisError.
8
+
3
9
  ## 0.2.0 (2013-04-05)
4
10
 
5
11
  [NEW] Richer interface for pubsub (accessible via `client.pubsub`). See example in `examples/pubsub.rb`.
data/lib/em-hiredis.rb CHANGED
@@ -5,8 +5,8 @@ module EventMachine
5
5
  # All em-hiredis errors should descend from EM::Hiredis::Error
6
6
  class Error < RuntimeError; end
7
7
 
8
- # In the case of error responses from Redis, the RuntimeError returned
9
- # by ::Hiredis will be wrapped
8
+ # An error reply from Redis. The actual error retuned by ::Hiredis will be
9
+ # wrapped in the redis_error accessor.
10
10
  class RedisError < Error
11
11
  attr_accessor :redis_error
12
12
  end
@@ -23,6 +23,17 @@ module EventMachine
23
23
  client
24
24
  end
25
25
 
26
+ # Connects to redis and returns a client instance
27
+ #
28
+ # Will connect in preference order to the provided uri, the REDIS_URL
29
+ # environment variable, or localhost:6379
30
+ #
31
+ # TCP connections are supported via redis://:password@host:port/db (only
32
+ # host and port components are required)
33
+ #
34
+ # Unix socket uris are supported, e.g. unix:///tmp/redis.sock, however
35
+ # it's not possible to set the db or password - use initialize instead in
36
+ # this case
26
37
  def self.connect(uri = nil)
27
38
  client = setup(uri)
28
39
  client.connect
@@ -16,7 +16,7 @@ module EventMachine::Hiredis
16
16
 
17
17
  attr_reader :host, :port, :password, :db
18
18
 
19
- def initialize(host='localhost', port='6379', password=nil, db=nil)
19
+ def initialize(host = 'localhost', port = 6379, password = nil, db = nil)
20
20
  @host, @port, @password, @db = host, port, password, db
21
21
  @defs = []
22
22
  @command_queue = []
@@ -42,11 +42,17 @@ module EventMachine::Hiredis
42
42
  #
43
43
  def configure(uri_string)
44
44
  uri = URI(uri_string)
45
- @host = uri.host
46
- @port = uri.port
47
- @password = uri.password
48
- path = uri.path[1..-1]
49
- @db = path.to_i # Empty path => 0
45
+
46
+ if uri.scheme == "unix"
47
+ @host = uri.path
48
+ @port = nil
49
+ else
50
+ @host = uri.host
51
+ @port = uri.port
52
+ @password = uri.password
53
+ path = uri.path[1..-1]
54
+ @db = path.to_i # Empty path => 0
55
+ end
50
56
  end
51
57
 
52
58
  def connect
@@ -110,7 +116,7 @@ module EventMachine::Hiredis
110
116
  if RuntimeError === reply
111
117
  raise "Replies out of sync: #{reply.inspect}" if @defs.empty?
112
118
  deferred = @defs.shift
113
- error = RedisError.new("Error reply from redis (wrapped in redis_error)")
119
+ error = RedisError.new(reply.message)
114
120
  error.redis_error = reply
115
121
  deferred.fail(error) if deferred
116
122
  else
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  module Hiredis
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -105,9 +105,11 @@ describe EM::Hiredis::BaseClient do
105
105
  df.errback { |e|
106
106
  e.class.should == EM::Hiredis::RedisError
107
107
  e.should be_kind_of(EM::Hiredis::Error)
108
- e.message.should == 'Error reply from redis (wrapped in redis_error)'
108
+ msg = "ERR Operation against a key holding the wrong kind of value"
109
+ e.message.should == msg
109
110
  # This is the wrapped error from redis:
110
- e.redis_error.message.should == 'ERR Operation against a key holding the wrong kind of value'
111
+ e.redis_error.class.should == RuntimeError
112
+ e.redis_error.message.should == msg
111
113
  done
112
114
  }
113
115
  }
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-hiredis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Martyn Loughran
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-05 00:00:00.000000000 Z
12
+ date: 2013-04-22 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: hiredis
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: em-spec
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,15 +62,17 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  description: Eventmachine redis client using hiredis native parser
@@ -105,26 +114,33 @@ files:
105
114
  - spec/url_param_spec.rb
106
115
  homepage: http://github.com/mloughran/em-hiredis
107
116
  licenses: []
108
- metadata: {}
109
117
  post_install_message:
110
118
  rdoc_options: []
111
119
  require_paths:
112
120
  - lib
113
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
114
123
  requirements:
115
- - - '>='
124
+ - - ! '>='
116
125
  - !ruby/object:Gem::Version
117
126
  version: '0'
127
+ segments:
128
+ - 0
129
+ hash: -3658727761083238148
118
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
119
132
  requirements:
120
- - - '>='
133
+ - - ! '>='
121
134
  - !ruby/object:Gem::Version
122
135
  version: '0'
136
+ segments:
137
+ - 0
138
+ hash: -3658727761083238148
123
139
  requirements: []
124
140
  rubyforge_project: em-hiredis
125
- rubygems_version: 2.0.0
141
+ rubygems_version: 1.8.24
126
142
  signing_key:
127
- specification_version: 4
143
+ specification_version: 3
128
144
  summary: Eventmachine redis client
129
145
  test_files:
130
146
  - spec/base_client_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e19e2546bb52eb3e8f9f4a969d5666cd04eb0f39
4
- data.tar.gz: 80435303e1cf652b489855c8e8f83228e614918e
5
- SHA512:
6
- metadata.gz: aeea4ec51cc1a5ca3f0cf1ccecc5f00513d7840f1af34460ee5c19768e14d832d3460ada718927ac92c467d95a68f9e5f170bb318ea2b19510ef9b9c01de8158
7
- data.tar.gz: 15d493eb81dfe7d044c8a55d25b3b269dd2af36d9d129fd5bfbd9d598f30d828a8ca7643a7a7f82a8f264b21d4ca8a2d5f5e43f25c48029792ff8024ba1a8062