hella-redis 0.0.1 → 0.1.0

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.
data/README.md CHANGED
@@ -4,7 +4,24 @@ It's-a hella-redis!
4
4
 
5
5
  ## Usage
6
6
 
7
- TODO: Write code samples and usage instructions here
7
+ ### RedisConnection
8
+
9
+ ```ruby
10
+ # config and create a connection
11
+ @config = OpenStruct.new({
12
+ :timeout => 1,
13
+ :size => 5,
14
+ :redis_ns => 'hella-redis-test',
15
+ :driver => 'ruby',
16
+ :url => 'redis://localhost:6379/0'
17
+ })
18
+ @conn = HellaRedis::RedisConnection.new(@config)
19
+
20
+ # it's actually a pool of connections
21
+ @conn.with do |conn|
22
+ # get a connection and do something with it
23
+ end
24
+ ```
8
25
 
9
26
  ## Installation
10
27
 
data/hella-redis.gemspec CHANGED
@@ -19,4 +19,8 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_development_dependency("assert")
21
21
 
22
+ gem.add_dependency("redis", ["~> 3.0"])
23
+ gem.add_dependency("redis-namespace", ["~> 1.0"])
24
+ gem.add_dependency("connection_pool", ["= 0.9.2"]) # temp, for 1.8.7 support
25
+
22
26
  end
data/lib/hella-redis.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "hella-redis/version"
2
+ require "hella-redis/redis_connection"
2
3
 
3
4
  module HellaRedis
4
- # TODO: your code goes here...
5
5
  end
@@ -0,0 +1,18 @@
1
+ require 'redis'
2
+ require 'redis-namespace'
3
+ require 'connection_pool'
4
+
5
+ module HellaRedis::RedisConnection
6
+
7
+ def self.new(config)
8
+ @pool = ::ConnectionPool.new(:timeout => config.timeout, :size => config.size) do
9
+ ::Redis::Namespace.new(config.redis_ns, {
10
+ :redis => ::Redis.connect({
11
+ :url => config.url,
12
+ :driver => config.driver
13
+ })
14
+ })
15
+ end
16
+ end
17
+
18
+ end
@@ -1,3 +1,3 @@
1
1
  module HellaRedis
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/test/helper.rb CHANGED
@@ -3,5 +3,3 @@
3
3
 
4
4
  # add the root dir to the load path
5
5
  $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
-
7
- # TODO: put test helpers here...
@@ -0,0 +1,36 @@
1
+ require 'assert'
2
+ require 'hella-redis/redis_connection'
3
+ require 'connection_pool'
4
+ require 'ostruct'
5
+
6
+ module HellaRedis::RedisConnection
7
+
8
+ class BaseTests < Assert::Context
9
+ desc "a RedisConnection"
10
+ setup do
11
+ @config = OpenStruct.new({
12
+ :timeout => 1,
13
+ :size => 5,
14
+ :redis_ns => 'hella-redis-test',
15
+ :driver => 'ruby',
16
+ :url => 'redis://localhost:6379/0'
17
+ })
18
+ @conn = HellaRedis::RedisConnection.new(@config)
19
+ end
20
+ subject{ @conn }
21
+
22
+ should "be a connection pool with the configured size and timeout" do
23
+ assert_kind_of ConnectionPool, subject
24
+ end
25
+
26
+ should "connect to the redis url" do
27
+ assert_nothing_raised do
28
+ subject.with do |conn|
29
+ assert_kind_of Redis::Namespace, conn
30
+ end
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hella-redis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -32,6 +32,52 @@ dependencies:
32
32
  version: "0"
33
33
  requirement: *id001
34
34
  prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :runtime
37
+ name: redis
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 7
44
+ segments:
45
+ - 3
46
+ - 0
47
+ version: "3.0"
48
+ requirement: *id002
49
+ prerelease: false
50
+ - !ruby/object:Gem::Dependency
51
+ type: :runtime
52
+ name: redis-namespace
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 0
62
+ version: "1.0"
63
+ requirement: *id003
64
+ prerelease: false
65
+ - !ruby/object:Gem::Dependency
66
+ type: :runtime
67
+ name: connection_pool
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - "="
72
+ - !ruby/object:Gem::Version
73
+ hash: 63
74
+ segments:
75
+ - 0
76
+ - 9
77
+ - 2
78
+ version: 0.9.2
79
+ requirement: *id004
80
+ prerelease: false
35
81
  description: It's-a hella-redis!
36
82
  email:
37
83
  - kelly@kellyredding.com
@@ -50,9 +96,11 @@ files:
50
96
  - Rakefile
51
97
  - hella-redis.gemspec
52
98
  - lib/hella-redis.rb
99
+ - lib/hella-redis/redis_connection.rb
53
100
  - lib/hella-redis/version.rb
54
101
  - log/.gitkeep
55
102
  - test/helper.rb
103
+ - test/unit/redis_connection_tests.rb
56
104
  - tmp/.gitkeep
57
105
  homepage: http://github.com/redding/hella-redis
58
106
  licenses: []
@@ -89,3 +137,4 @@ specification_version: 3
89
137
  summary: It's-a hella-redis!
90
138
  test_files:
91
139
  - test/helper.rb
140
+ - test/unit/redis_connection_tests.rb