em-hiredis 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "em-spec", :git => "git://github.com/bcg/em-spec.git"
4
- gem "eventmachine"
5
- gem "hiredis"
6
- gem "rspec"
3
+ gemspec
data/LICENCE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Martyn Loughran
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -75,10 +75,10 @@ Hacking on em-hiredis is pretty simple, make sure you have Bundler installed:
75
75
 
76
76
  To run all the tests:
77
77
 
78
- rake
78
+ bundle exec rake
79
79
 
80
80
  To run an individual test:
81
81
 
82
82
  bundle exec rspec spec/redis_commands_spec.rb
83
83
 
84
- Much thanks to the em-redis gem for getting this gem bootstrapped with some tests.
84
+ Many thanks to the em-redis gem for getting this gem bootstrapped with some tests.
@@ -12,7 +12,11 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Eventmachine redis client}
13
13
  s.description = %q{Eventmachine redis client using hiredis native parser}
14
14
 
15
- s.add_dependency 'hiredis', '~> 0.3.0'
15
+ s.add_dependency 'hiredis', '~> 0.4.0'
16
+
17
+ s.add_development_dependency 'em-spec', '~> 0.2.5'
18
+ s.add_development_dependency 'rspec', '~> 2.6.0'
19
+ s.add_development_dependency 'rake'
16
20
 
17
21
  s.rubyforge_project = "em-hiredis"
18
22
 
@@ -14,6 +14,7 @@ module EventMachine::Hiredis
14
14
  def initialize(host, port, password = nil, db = nil)
15
15
  @host, @port, @password, @db = host, port, password, db
16
16
  @subs, @psubs, @defs = [], [], []
17
+ @closing_connection = false
17
18
  end
18
19
 
19
20
  def connect
@@ -25,18 +26,22 @@ module EventMachine::Hiredis
25
26
  @defs = []
26
27
  @deferred_status = nil
27
28
  @connected = false
28
- @reconnecting = true
29
- reconnect
29
+ unless @closing_connection
30
+ @reconnecting = true
31
+ reconnect
32
+ end
30
33
  else
31
- EM.add_timer(1) { reconnect }
34
+ unless @closing_connection
35
+ EM.add_timer(1) { reconnect }
36
+ end
32
37
  end
33
38
  end
34
39
 
35
40
  @connection.on(:connected) do
36
41
  @connected = true
37
42
 
38
- select(@db) if @db
39
43
  auth(@password) if @password
44
+ select(@db) if @db
40
45
 
41
46
  @subs.each { |s| method_missing(:subscribe, s) }
42
47
  @psubs.each { |s| method_missing(:psubscribe, s) }
@@ -94,6 +99,10 @@ module EventMachine::Hiredis
94
99
  @connected && @defs.size > 0
95
100
  end
96
101
 
102
+ def connected?
103
+ @connected
104
+ end
105
+
97
106
  def subscribe(channel)
98
107
  @subs << channel
99
108
  method_missing(:subscribe, channel)
@@ -141,6 +150,12 @@ module EventMachine::Hiredis
141
150
  method_missing(:info, &hash_processor)
142
151
  end
143
152
 
153
+ def close_connection
154
+ @closing_connection = true
155
+ @connection.close_connection_after_writing
156
+ @defs.each
157
+ end
158
+
144
159
  private
145
160
 
146
161
  def method_missing(sym, *args)
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  module Hiredis
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -510,3 +510,18 @@ describe EventMachine::Hiredis, "when reconnecting" do
510
510
  end
511
511
  end
512
512
  end
513
+
514
+ describe EventMachine::Hiredis, "when closing_connection" do
515
+ it "should fail deferred commands" do
516
+ errored = false
517
+ connect do |redis|
518
+ op = redis.blpop 'empty_list'
519
+ op.callback { fail }
520
+ op.errback { EM.stop }
521
+
522
+ redis.close_connection
523
+
524
+ EM.add_timer(1) { fail }
525
+ end
526
+ end
527
+ end
metadata CHANGED
@@ -1,42 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: em-hiredis
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Martyn Loughran
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-04 00:00:00 +01:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: hiredis
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70172074018560 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
18
+ requirements:
22
19
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: 0.3.0
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.0
25
22
  type: :runtime
26
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: *70172074018560
25
+ - !ruby/object:Gem::Dependency
26
+ name: em-spec
27
+ requirement: &70172074030920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.2.5
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70172074030920
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70172074026440 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.6.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70172074026440
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &70172074025080 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70172074025080
27
58
  description: Eventmachine redis client using hiredis native parser
28
- email:
59
+ email:
29
60
  - me@mloughran.com
30
61
  executables: []
31
-
32
62
  extensions: []
33
-
34
63
  extra_rdoc_files: []
35
-
36
- files:
64
+ files:
37
65
  - .gitignore
38
66
  - .rspec
39
67
  - Gemfile
68
+ - LICENCE
40
69
  - README.md
41
70
  - Rakefile
42
71
  - em-hiredis.gemspec
@@ -52,35 +81,31 @@ files:
52
81
  - spec/support/connection_helper.rb
53
82
  - spec/support/redis_mock.rb
54
83
  - spec/url_param_spec.rb
55
- has_rdoc: true
56
84
  homepage: http://github.com/mloughran/em-hiredis
57
85
  licenses: []
58
-
59
86
  post_install_message:
60
87
  rdoc_options: []
61
-
62
- require_paths:
88
+ require_paths:
63
89
  - lib
64
- required_ruby_version: !ruby/object:Gem::Requirement
90
+ required_ruby_version: !ruby/object:Gem::Requirement
65
91
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: "0"
70
- required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
97
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
76
102
  requirements: []
77
-
78
103
  rubyforge_project: em-hiredis
79
- rubygems_version: 1.6.2
104
+ rubygems_version: 1.8.10
80
105
  signing_key:
81
106
  specification_version: 3
82
107
  summary: Eventmachine redis client
83
- test_files:
108
+ test_files:
84
109
  - spec/connection_spec.rb
85
110
  - spec/live_redis_protocol_spec.rb
86
111
  - spec/redis_commands_spec.rb