lib/redis-browser/browser.rb in redis-browser-0.5.0 vs lib/redis-browser/browser.rb in redis-browser-0.5.1
- old
+ new
@@ -8,41 +8,50 @@
if key =~ /^(.+?)(:+|\/+|\.+).+$/
[$1, $2]
else
[key, nil]
end
+ rescue ArgumentError
+ [key, nil]
end
def keys(namespace = nil)
- if namespace.to_s.strip.empty?
- pattern = "*"
- namespace = ""
- else
- pattern = namespace + "*"
+ begin
+ if namespace.to_s.strip.empty?
+ pattern = "*"
+ namespace = ""
+ else
+ pattern = namespace + "*"
+ end
+ rescue ArgumentError
+ pattern, namespace = "*", ""
end
redis.keys(pattern).inject({}) do |acc, key|
key.slice!(namespace) if namespace
ns, sep = split_key(key)
- unless ns.strip.empty?
- acc[ns] ||= {
- :name => ns,
- :full => namespace + ns + sep.to_s,
- :count => 0
- }
- acc[ns][:count] += 1
+ begin
+ unless ns.strip.empty?
+ acc[ns] ||= {
+ :name => ns,
+ :full => namespace + ns + sep.to_s,
+ :count => 0
+ }
+ acc[ns][:count] += 1
+ end
+ rescue ArgumentError
end
acc
end.values.sort_by {|e| e[:name] }
end
def item_type(e)
begin
["json", MultiJson.decode(e)]
- rescue MultiJson::LoadError => ex
+ rescue MultiJson::LoadError
["string", e]
end
end
def get_list(key, opts = {})