Skip to content

Instantly share code, notes, and snippets.

@farleyknight
Created November 22, 2008 02:15
Show Gist options
  • Save farleyknight/27726 to your computer and use it in GitHub Desktop.
Save farleyknight/27726 to your computer and use it in GitHub Desktop.
require 'tempfile'
class Firefox
def self.debug(page)
if page.is_a? File
page = page.read
elsif page.respond_to?(:body) and page.body.is_a? String
page = page.body
end
Tempfile.open("temp_file") do |f|
f.write(page)
path = f.path
path = windozify_path(f.path) if f.path =~ /cygdrive/
`firefox #{path} &`
end
end
def self.windozify_path(path)
path.gsub!('/cygdrive/c', 'C:')
"file:///#{path}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment