Sha256: 416211a6a2db2e378db997a469e29a9f43aa8bdf8bcf2eceb7f47e1c6ad1c095
Contents?: true
Size: 509 Bytes
Versions: 9
Compression:
Stored size: 509 Bytes
Contents
require 'pathname' def save_page(page) return nil unless File.directory?(directory = save_pages_dir) filename = "#{directory}/mechanize-#{Time.now.to_i}.html" page.save_as(filename) filename end def open_in_browser(path) # :nodoc require "launchy" Launchy::Browser.run(path) rescue LoadError warn "Sorry, you need to install launchy to open pages: `gem install launchy`" end private def save_pages_dir tmp_dir = Pathname.new(Dir.pwd).join("tmp") tmp_dir.exist? ? tmp_dir : Dir.pwd end
Version data entries
9 entries across 9 versions & 1 rubygems