redis_support 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,6 +6,15 @@ common actions for the Redis key-value store. It is not an
6
6
  object-relational mapper, does not attempt to comprehensively solve
7
7
  all of your storage problems, and does not make julienne fries.
8
8
 
9
+ Redis Addition
10
+ --------------
11
+
12
+ Provides a connection to redis which is the same across all classes
13
+ which use RedisSupport as a mixin. This connection can be set by calling,
14
+ for example:
15
+
16
+ RedisSupport.redis = "localhost:6379"
17
+
9
18
  Key Support
10
19
  -----------
11
20
 
data/lib/redis_support.rb CHANGED
@@ -1,3 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
1
5
  require 'redis'
2
6
 
3
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "/"))
@@ -5,7 +9,6 @@ require 'redis_support/class_extensions'
5
9
  require 'redis_support/locks'
6
10
 
7
11
  module RedisSupport
8
-
9
12
  # Inspired/take from the redis= in Resque
10
13
  #
11
14
  # Accepts:
@@ -22,9 +25,7 @@ module RedisSupport
22
25
  end
23
26
 
24
27
  def redis
25
- return @@redis if @@redis
26
- self.redis = @@redis || 'localhost:6379'
27
- self.redis
28
+ @@redis
28
29
  end
29
30
 
30
31
  def keys
@@ -36,6 +37,8 @@ module RedisSupport
36
37
  def self.included(model)
37
38
  model.extend ClassMethods
38
39
  model.extend RedisSupport
40
+ model.redis = @redis
39
41
  end
40
42
 
43
+ extend self
41
44
  end
data/test/helper.rb CHANGED
@@ -47,7 +47,9 @@ class TestClass
47
47
  redis_key :test_vars, "test:redis:VAR_ONE:VAR_TWO:append"
48
48
  end
49
49
 
50
- TestClass.redis = "localhost:9736"
50
+ class SecondTest
51
+ include RedisSupport
52
+ end
51
53
 
52
54
  ##
53
55
  # test/spec/mini 3
@@ -1,7 +1,25 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
+ context "Redis Support setup" do
4
+ setup do
5
+ RedisSupport.redis = "localhost:9736"
6
+ end
7
+
8
+ test "redis is loaded correctly" do
9
+ assert RedisSupport.redis
10
+ assert TestClass.redis
11
+ assert SecondTest.redis
12
+ assert_equal 9736, RedisSupport.redis.client.port
13
+ assert_equal 9736, TestClass.redis.client.port
14
+ assert_equal 9736, SecondTest.redis.client.port
15
+ assert_equal "localhost", TestClass.redis.client.host
16
+ assert_equal RedisSupport.redis, TestClass.redis
17
+ end
18
+ end
19
+
3
20
  context "Redis Support" do
4
21
  setup do
22
+ RedisSupport.redis = "localhost:9736"
5
23
  TestClass.redis.flushall
6
24
  @test_class = TestClass.new
7
25
  end
metadata CHANGED
@@ -1,21 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_support
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
- - dolores
13
+ - Brian P O'Rourke
14
+ - John Le
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-06-18 00:00:00 -07:00
19
+ date: 2010-06-21 00:00:00 -07:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency