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



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

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 http://sourceforge.net/projects/htmlunit/files/htmlunit/#{version}/htmlunit-#{version}.zip]
  else
    %x[curl -L -o htmlunit-#{version}.zip  http://sourceforge.net/projects/htmlunit/files/htmlunit/#{version}/htmlunit-#{version}-bin.zip]
  end
end

.download_htmlunit(version) ⇒ Object



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

def self.download_htmlunit(version)
  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



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

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

.unzip(version) ⇒ Object



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

def self.unzip(version)
  `tar xzf htmlunit-#{version}.zip`
  `mv -f htmlunit-2.10-SNAPSHOT htmlunit-2.10 > /dev/null 2>&1`
  `cp -r htmlunit-#{version}/lib/ .akephalos/#{version}/`
end

.version_exist?(version) ⇒ Boolean

Returns:

  • (Boolean)


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

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