sinatra-redis 0.1.1 → 0.2.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/lib/sinatra/redis.rb +14 -8
- data/sinatra-redis.gemspec +3 -1
- metadata +11 -1
data/lib/sinatra/redis.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'uri'
|
|
2
|
-
require '
|
|
2
|
+
require 'redis'
|
|
3
3
|
|
|
4
4
|
module Sinatra
|
|
5
5
|
module RedisHelper
|
|
@@ -8,7 +8,7 @@ module Sinatra
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
module
|
|
11
|
+
module Redis
|
|
12
12
|
def redis=(url)
|
|
13
13
|
@redis = nil
|
|
14
14
|
set :redis_url, url
|
|
@@ -17,24 +17,30 @@ module Sinatra
|
|
|
17
17
|
|
|
18
18
|
def redis
|
|
19
19
|
url = URI(redis_url)
|
|
20
|
-
@redis ||=
|
|
21
|
-
|
|
20
|
+
@redis ||= (
|
|
21
|
+
base_options = {
|
|
22
22
|
:host => url.host,
|
|
23
23
|
:port => url.port,
|
|
24
24
|
:db => url.path[1..-1],
|
|
25
|
-
:
|
|
25
|
+
:password => url.password
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
::Redis.new(
|
|
29
|
+
base_options.merge(
|
|
30
|
+
options.redis_options
|
|
31
|
+
)
|
|
26
32
|
)
|
|
33
|
+
)
|
|
27
34
|
end
|
|
28
35
|
|
|
29
36
|
protected
|
|
30
37
|
|
|
31
38
|
def self.registered(app)
|
|
32
39
|
app.set :redis_url, ENV['REDIS_URL'] || "redis://127.0.0.1:6379/0"
|
|
40
|
+
app.set :redis_options, {}
|
|
33
41
|
app.helpers RedisHelper
|
|
34
42
|
end
|
|
35
43
|
end
|
|
36
44
|
|
|
37
|
-
Redis
|
|
38
|
-
|
|
39
|
-
register RedisExtension
|
|
45
|
+
register Redis
|
|
40
46
|
end
|
data/sinatra-redis.gemspec
CHANGED
|
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
4
4
|
|
|
5
5
|
s.name = 'sinatra-redis'
|
|
6
|
-
s.version = '0.
|
|
6
|
+
s.version = '0.2.0'
|
|
7
7
|
s.date = '2009-09-21'
|
|
8
8
|
|
|
9
9
|
s.description = "Extends Sinatra with redis helpers for instant redis use"
|
|
@@ -12,6 +12,8 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.authors = ["Blake Mizerany"]
|
|
13
13
|
s.email = "blake.mizerany@gmail.com"
|
|
14
14
|
|
|
15
|
+
s.add_dependency "redis"
|
|
16
|
+
|
|
15
17
|
# = MANIFEST =
|
|
16
18
|
s.files = %w[
|
|
17
19
|
README.md
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sinatra-redis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Blake Mizerany
|
|
@@ -12,6 +12,16 @@ cert_chain: []
|
|
|
12
12
|
date: 2009-09-21 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: redis
|
|
17
|
+
type: :runtime
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: "0"
|
|
24
|
+
version:
|
|
15
25
|
- !ruby/object:Gem::Dependency
|
|
16
26
|
name: sinatra
|
|
17
27
|
type: :runtime
|