Skip to content

Instantly share code, notes, and snippets.

@avdi
Created October 20, 2009 23:43
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 avdi/214722 to your computer and use it in GitHub Desktop.
Save avdi/214722 to your computer and use it in GitHub Desktop.
require 'tempfile'
def browse_string(body)
Tempfile.open('browse_string') do |f|
browser = ENV.fetch('BROWSER') { 'firefox' }
f.write(body)
f.close
puts "Starting browser #{browser} with response..."
unless system(browser, f.path)
warn "Error starting browser #{browser}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment