more bug fixes

This commit is contained in:
Sami Samhuri 2013-08-24 18:20:56 -07:00
parent ecd8249271
commit 847d133594
3 changed files with 14 additions and 3 deletions

View file

@ -38,6 +38,10 @@ module Kwikemon
redis.sadd(key('monitors'), name) redis.sadd(key('monitors'), name)
end end
Monitor.on(:remove) do |name|
redis.srem(key('monitors'), name)
end
# Set `name` to `value`. # Set `name` to `value`.
# #
@ -95,7 +99,7 @@ module Kwikemon
# Remove the monitor named `name`. # Remove the monitor named `name`.
def remove(name) def remove(name)
Monitor.new(name).delete Monitor.new(name).remove
end end
# Clear all monitors. # Clear all monitors.
@ -112,6 +116,7 @@ module Kwikemon
end end
end end
private private
def config def config

View file

@ -53,6 +53,12 @@ module Kwikemon
self self
end end
def remove
redis.del(key)
self.class.emit(:remove, name)
self
end
def key def key
Kwikemon.key("monitor:#{name}") Kwikemon.key("monitor:#{name}")
end end
@ -70,7 +76,7 @@ module Kwikemon
end end
def text def text
@text ||= exists? ? redis.hget(key, 'name') : nil @text ||= exists? ? redis.hget(key, 'text') : nil
end end

View file

@ -1,3 +1,3 @@
module Kwikemon module Kwikemon
VERSION = '0.0.5' VERSION = '0.0.6'
end end