class KPM::TomcatManager

def download

def download
  uri = URI.parse(DOWNLOAD_URL)
  path = nil
  Dir.mktmpdir do |dir|
    file = Pathname.new(dir).join('tomcat.tar.gz')
    @logger.info "Starting download of #{DOWNLOAD_URL} to #{file}"
    Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
      File.open(file, 'wb+') do |f|
        http.get(uri.path) do |body|
          f.write(body)
        end
      end
    end
    path = Utils.unpack_tgz(file.to_s, @tomcat_dir, true)
  end
  @logger.info "Successful installation of #{DOWNLOAD_URL} to #{path}"
  path
end