lib/redis-browser/browser.rb in redis-browser-0.3.0 vs lib/redis-browser/browser.rb in redis-browser-0.3.1
- old
+ new
@@ -1,10 +1,9 @@
module RedisBrowser
class Browser
- def initialize(conn = nil, db = 0)
+ def initialize(conn = {})
@conn = conn
- @db = db
end
def split_key(key)
if key =~ /^(.+?)(:+|\/+|\.+).+$/
[$1, $2]
@@ -86,10 +85,11 @@
{:value => value}
end
def get_keys(key)
+ key ||= ""
key << "*" unless key.end_with?("*")
values = redis.keys(key).map do |k|
{:name => k, :full => k}
end
@@ -132,21 +132,10 @@
{:error => ex.message}
end
def redis
@redis ||= begin
- conn = @conn || "127.0.0.1:6379"
- db = @db || 0
-
- opts = if conn.start_with?("/")
- {:path => conn}
- else
- host, port = conn.split(":", 2)
- {:host => host, :port => port}
- end
-
- r = Redis.new(opts)
- r.select(db)
+ r = Redis.new(@conn)
r
end
end
end
end