Skip to content

Instantly share code, notes, and snippets.

@lime
Forked from hakanensari/open_in_browser.rb
Created July 12, 2013 13:52
Show Gist options
  • Save lime/5984615 to your computer and use it in GitHub Desktop.
Save lime/5984615 to your computer and use it in GitHub Desktop.
begin
require 'launchy'
class Mechanize::Page
def open_in_browser
if body
file = File.new("/tmp/#{Time.now.to_i}.html", 'w')
file.write body
Launchy.open "file://#{file.path}"
system "sleep 2 && rm #{file.path} &"
end
end
end
rescue LoadError
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment