Module: HtmlUnit

Defined in:
lib/akephalos/htmlunit.rb,
lib/akephalos/htmlunit_downloader.rb,
lib/akephalos/htmlunit/ext/http_method.rb,
lib/akephalos/htmlunit/ext/confirm_handler.rb

Overview

Reopen com.gargoylesoftware.htmlunit.ConfirmHandler to provide an interface to confirm a dialog and capture its message

Defined Under Namespace

Modules: ConfirmHandler, Util Classes: HttpMethod

Class Method Summary collapse

Class Method Details

.download(version) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/akephalos/htmlunit_downloader.rb', line 24

def self.download(version)
  if version == "2.10"
    %x[curl -L -o htmlunit-2.10.zip  http://build.canoo.com/htmlunit/artifacts/htmlunit-2.10-SNAPSHOT-with-dependencies.zip]
  elsif version == '2.9'
    %x[curl -L -o htmlunit-2.9.zip  http://sourceforge.net/projects/htmlunit/files/htmlunit/2.9/htmlunit-2.9-bin.zip]
  else
    %x[curl -L -O http://sourceforge.net/projects/htmlunit/files/htmlunit/#{version}/htmlunit-#{version}.zip]
  end
end

.download_htmlunit(version) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/akephalos/htmlunit_downloader.rb', line 2

def self.download_htmlunit(version)
  version ||= "2.9"
  if not version_exist?(version)
    puts "Installing HTMLUnit #{version} at .akephalos/#{version}/"
    Dir.mkdir(".akephalos") unless File.exists?(".akephalos")
    Dir.mkdir(".akephalos/#{version}") unless File.exists?(".akephalos/#{version}")
    download(version)
    unzip(version)
    remove_cache(version)
  else
    puts "Using HTMLUnit #{version}"
  end
end

.remove_cache(version) ⇒ Object



34
35
36
# File 'lib/akephalos/htmlunit_downloader.rb', line 34

def self.remove_cache(version)
  `rm -rf htmlunit-#{version} htmlunit-#{version}.zip`
end

.unzip(version) ⇒ Object



20
21
22
# File 'lib/akephalos/htmlunit_downloader.rb', line 20

def self.unzip(version)
  `unzip -o -j -d .akephalos/#{version} htmlunit-#{version}.zip`
end

.version_exist?(version) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/akephalos/htmlunit_downloader.rb', line 16

def self.version_exist?(version)
  File.exist?(".akephalos/#{version}/htmlunit-#{version}.jar")
end