uri-redis 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +6 -0
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/lib/uri/redis.rb +36 -4
- metadata +4 -4
data/CHANGES.txt
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
URI-Redis, CHANGES
|
2
2
|
|
3
|
+
#### 0.4.2 (2010-12-23) ###############################
|
4
|
+
|
5
|
+
# CHANGE: URI#conf enforces symbols as keys
|
6
|
+
* ADDED: URI#conf parses query string
|
7
|
+
|
8
|
+
|
3
9
|
#### 0.4.1 (2010-11-16) ###############################
|
4
10
|
|
5
11
|
* FIXED: Nil error in URI::Redis#key
|
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/lib/uri/redis.rb
CHANGED
@@ -42,20 +42,52 @@ module URI
|
|
42
42
|
self.path
|
43
43
|
end
|
44
44
|
|
45
|
+
# Returns a hash suitable for sending to Redis.new.
|
46
|
+
# The hash is generated from the host, port, db and
|
47
|
+
# password from the URI as well as any query vars.
|
48
|
+
#
|
49
|
+
# e.g.
|
50
|
+
#
|
51
|
+
# uri = URI.parse "redis://127.0.0.1/6/?timeout=5"
|
52
|
+
# uri.conf
|
53
|
+
# # => {:db=>6, :timeout=>"5", :host=>"127.0.0.1", :port=>6379}
|
54
|
+
#
|
45
55
|
def conf
|
46
|
-
|
56
|
+
hsh = {
|
47
57
|
:host => host,
|
48
58
|
:port => port,
|
49
59
|
:db => db
|
50
|
-
}
|
51
|
-
|
52
|
-
|
60
|
+
}.merge parse_query(query)
|
61
|
+
hsh[:password] = password if password
|
62
|
+
hsh
|
53
63
|
end
|
54
64
|
|
55
65
|
def serverid
|
56
66
|
'redis://%s:%s/%s' % [host, port, db]
|
57
67
|
end
|
58
68
|
|
69
|
+
private
|
70
|
+
|
71
|
+
# Based on / stolen from: https://github.com/chneukirchen/rack/blob/master/lib/rack/utils.rb
|
72
|
+
# which was based on / stolen from Mongrel
|
73
|
+
def parse_query(qs, d = '&;')
|
74
|
+
params = {}
|
75
|
+
(qs || '').split(/[#{d}] */n).each do |p|
|
76
|
+
k, v = p.split('=', 2).map { |str| str } # NOTE: uri_unescape
|
77
|
+
k = k.to_sym
|
78
|
+
if cur = params[k]
|
79
|
+
if cur.class == Array
|
80
|
+
params[k] << v
|
81
|
+
else
|
82
|
+
params[k] = [cur, v]
|
83
|
+
end
|
84
|
+
else
|
85
|
+
params[k] = v
|
86
|
+
end
|
87
|
+
end
|
88
|
+
params
|
89
|
+
end
|
90
|
+
|
59
91
|
end
|
60
92
|
|
61
93
|
@@schemes['REDIS'] = Redis
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Delano Mandelbaum
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-23 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|