Permalink
Browse files

Clean up watcher deletes

  • Loading branch information...
1 parent 2460960 commit e5dd757c28ce1bbda99b61a7e54f8538d1ad251c @shayfrendt committed Oct 25, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 init.rb
View
@@ -106,7 +106,7 @@ def watchers
return
when "remove"
email = args.shift
- delete_watcher_from_email(email)
+ delete_watcher(email)
return
when "clear"
clear_all_watchers
@@ -132,7 +132,12 @@ def add_watcher
#
def remove_watcher
email = args.shift
- remove_watcher(email)
+
+ if delete_watcher_from_email(email)
+ puts "Removed #{email} as a watcher"
+ else
+ puts "No watchers with that email found in the watcher list"
+ end
end
# ranger:clear_watchers
@@ -228,7 +233,7 @@ def clear_all_watchers
watchers = get_watchers
watchers.each do |record|
- delete_watcher(record["watcher"]["id"])
+ delete_watcher_from_id(record["watcher"]["id"])
end
end
@@ -282,7 +287,7 @@ def create_watcher(email)
resource.post(params)
end
- def remove_watcher(email)
+ def delete_watcher(email)
if delete_watcher_from_email(email)
puts "Removed #{email} as a watcher"
else
@@ -304,7 +309,7 @@ def delete_watcher_from_email(email)
return true
end
- def delete_watcher(id)
+ def delete_watcher_from_id(id)
resource = authenticated_resource("/apps/#{@ranger_app_id}/watchers/#{id}.json?api_key=#{@ranger_api_key}")
begin

0 comments on commit e5dd757

Please sign in to comment.