Skip to content

Instantly share code, notes, and snippets.

@ruckus
Created January 29, 2010 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruckus/290077 to your computer and use it in GitHub Desktop.
Save ruckus/290077 to your computer and use it in GitHub Desktop.
# If you DONT automatically resolve your errors on each deploy than they accumulate in HopToad
# Unfortunately HopToad doesnt offer a way to mass edit errors (mark them as resolved, specifically)
# This script to the rescue
require 'rubygems'
require 'mechanize'
a = WWW::Mechanize.new
a.get('https://yourdomain.hoptoadapp.com/login') do |page|
# Submit the login form
auth_token = page.search("//input[@type='hidden']").first.attributes['value']
puts "Auth token: #{auth_token}"
my_page = page.form_with(:action => 'https://yourdomain.hoptoadapp.com/session') do |f|
f['session[email]'] = 'email'
f['session[password]'] = 'password'
f.authenticity_token = auth_token
end.submit
error_ids = []
my_page.links.each do |link|
text = link.href.strip
next unless text.length > 0
if text =~ /^https\:\/\/yourdomain\.hoptoadapp\.com\/errors\/(\d+)/
error_ids << $1
end
end
error_ids.uniq.each do |error_id|
a.get("https://yourdomain.hoptoadapp.com/errors/#{error_id}") do |page|
# click the mark as resolved button
page.form_with(:action => "/errors/#{error_id}") do |form|
form.authenticity_token = auth_token
form['group[resolved]'] = 1
end.submit
puts "#{error_id}: Resolved!"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment