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.
Files changed (5) hide show
  1. data/CHANGES.txt +6 -0
  2. data/Rakefile +1 -1
  3. data/VERSION.yml +1 -1
  4. data/lib/uri/redis.rb +36 -4
  5. metadata +4 -4
@@ -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
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  config = YAML.load_file("VERSION.yml")
13
13
  task :default => ["build"]
14
- CLEAN.include [ 'pkg', 'doc' ]
14
+ CLEAN.include [ 'pkg', 'doc', '*gemspec' ]
15
15
  name = "uri-redis"
16
16
 
17
17
  begin
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :MAJOR: 0
3
3
  :MINOR: 4
4
- :PATCH: 1
4
+ :PATCH: 2
5
5
  :BUILD: '001'
@@ -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
- tmp = {
56
+ hsh = {
47
57
  :host => host,
48
58
  :port => port,
49
59
  :db => db
50
- }
51
- tmp[:password] = password if password
52
- tmp
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: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
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-11-16 00:00:00 -05:00
18
+ date: 2010-12-23 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21