class Aaet::Redis
Attributes
process[RW]
redis[RW]
Public Class Methods
new(process)
click to toggle source
# File lib/aaet/common/redis.rb, line 6 def initialize process self.redis = Redic.new self.process = process update_list("crashed", false) end
Public Instance Methods
activities()
click to toggle source
# File lib/aaet/common/redis.rb, line 32 def activities redis.call("LRANGE", "activities", 0, -1) end
activity_exists?(act)
click to toggle source
# File lib/aaet/common/redis.rb, line 24 def activity_exists? act activities.any? { |a| a.include? act } end
add_found_activity(act)
click to toggle source
# File lib/aaet/common/redis.rb, line 44 def add_found_activity act redis.call "LPUSH", "found_activities-#{process}", act end
app_crashed(boolean)
click to toggle source
# File lib/aaet/common/redis.rb, line 88 def app_crashed boolean redis.call "LPUSH", "crashed-#{process}", boolean end
del_list(list)
click to toggle source
# File lib/aaet/common/redis.rb, line 12 def del_list list redis.call "DEL", "#{list}-#{process}" rescue nil end
found_activities()
click to toggle source
# File lib/aaet/common/redis.rb, line 36 def found_activities redis.call("LRANGE", "found_activities-#{process}", 0, -1) end
found_activity_exists?(act)
click to toggle source
# File lib/aaet/common/redis.rb, line 40 def found_activity_exists? act found_activities.any? { |a| a.include? act } end
get_list(list)
click to toggle source
# File lib/aaet/common/redis.rb, line 60 def get_list list redis_list = redis.call("LRANGE", "#{list}-#{process}", 0, -1).map { |x| JSON.parse(x) }.uniq.flatten rescue [] unless redis_list.empty? redis_list = symbolize(redis_list) end redis_list end
hget(key, field)
click to toggle source
# File lib/aaet/common/redis.rb, line 104 def hget(key, field) redis.call("HGET", "#{key}-#{process}", field) end
hincr(key, field)
click to toggle source
# File lib/aaet/common/redis.rb, line 96 def hincr(key, field) redis.call("HINCRBY", "#{key}-#{process}", field, 1) end
hset(key, field, value)
click to toggle source
# File lib/aaet/common/redis.rb, line 100 def hset(key, field, value) redis.call("HSET", "#{key}-#{process}", field, value) end
list_includes_applitools_value(list, value)
click to toggle source
# File lib/aaet/common/redis.rb, line 84 def list_includes_applitools_value list, value redis.call("LRANGE", list, 0, -1).any? { |a| a.include? value } end
list_includes_value(list, value)
click to toggle source
# File lib/aaet/common/redis.rb, line 80 def list_includes_value list, value redis.call("LRANGE", "#{list}-#{process}", 0, -1).any? { |a| a.include? value } end
lpop(list)
click to toggle source
# File lib/aaet/common/redis.rb, line 92 def lpop list redis.call "LPOP", "#{list}-#{process}" end
remove_activity(activity)
click to toggle source
# File lib/aaet/common/redis.rb, line 28 def remove_activity activity redis.call "LREM", "activities", -1, activity end
symbolize(obj)
click to toggle source
# File lib/aaet/common/redis.rb, line 68 def symbolize(obj) return obj.reduce({}) do |memo, (k, v)| memo.tap { |m| m[k.to_sym] = symbolize(v) } end if obj.is_a? Hash return obj.reduce([]) do |memo, v| memo << symbolize(v); memo end if obj.is_a? Array obj end
update_activity_count(act)
click to toggle source
# File lib/aaet/common/redis.rb, line 48 def update_activity_count act unless found_activity_exists? act checkmark = "\u2713" puts "" puts "\nNew Activity Found! #{checkmark}".green add_found_activity act remaining = (activities.count - found_activities.count) puts "Remaining Activities: #{remaining}\n" puts "" end end
update_applitools(list, body)
click to toggle source
# File lib/aaet/common/redis.rb, line 16 def update_applitools list, body redis.call "LPUSH", list, JSON.generate(body) end
update_list(list, body)
click to toggle source
# File lib/aaet/common/redis.rb, line 20 def update_list list, body redis.call "LPUSH", "#{list}-#{process}", JSON.generate(body) end