# -*- coding: utf-8 -*- module RedisUIHelpers def redis RedisUI.redis end def partial(template,locals=nil) locals = (locals.is_a?(Hash)) ? locals : {template.to_sym => locals} template = ('_' + template.to_s).to_sym erb template, {layout: false}, locals end def get_key(key, redis=self.redis) data = case redis.type(key) when "string" redis[key] when "list" redis.lrange(key, 0, -1) when "set" redis.smembers(key) when 'zset' redis.zrange(key, 0, -1) when 'hash' redis.hgetall(key) else '???' end {:key => key, :type => redis.type(key), :data => data} end def show(val) case val when String val when Array if val.empty? '[]' else str = "