Top Level Namespace

Defined Under Namespace

Modules: MechanicalCuke

Instance Method Summary collapse

Instance Method Details

#open_in_browser(path) ⇒ Object

:nodoc



10
11
12
13
14
15
# File 'lib/mechanical-cuke/save_and_open.rb', line 10

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

#save_page(page) ⇒ Object



3
4
5
6
7
8
# File 'lib/mechanical-cuke/save_and_open.rb', line 3

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