Sha256: 120e0e93476f436618326353bba0688f43eb368036b2f9cfea9af5047155aebd

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module HtmlUnit
  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

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

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

  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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
akephalos2-2.1.1.2-java lib/akephalos/htmlunit_downloader.rb
akephalos2-2.1.1.2 lib/akephalos/htmlunit_downloader.rb