lib/helpers/services.rb in gaptool-server-0.3.1 vs lib/helpers/services.rb in gaptool-server-0.3.2

- old
+ new

@@ -12,14 +12,25 @@ @inuse = $redis.lrange("apikey:inuse:#{service}", 0, -1) @available = $redis.lrange("apikey:available:#{service}", 0, -1) return { :inuse => @inuse, :available => @available } else @all = Hash.new - $redis.keys('apikey:inuse:*').each do |service| - @all[service.gsub('apikey:inuse:', '')][:inuse] = $redis.lrange("apikey:inuse:#{service}", 0, -1) - end - $redis.keys('apikey:available:*').each do |service| - @all[service][:available] = $redis.lrange("apikey:available:#{service}", 0, -1) + $redis.keys('apikey:*').each do |service| + if service =~ /:available:/ + begin + @all[service.gsub('apikey:available:', '')][:available] = $redis.lrange(service, 0, -1) + rescue + @all[service.gsub('apikey:available:', '')] = Hash.new + @all[service.gsub('apikey:available:', '')][:available] = $redis.lrange(service, 0, -1) + end + elsif service =~ /:inuse:/ + begin + @all[service.gsub('apikey:inuse:', '')][:inuse] = $redis.lrange(service, 0, -1) + rescue + @all[service.gsub('apikey:inuse:', '')] = Hash.new + @all[service.gsub('apikey:inuse:', '')][:inuse] = $redis.lrange(service, 0, -1) + end + end end return @all end end def svcapi_deletekey(service, key)