Sha256: 2326cc3e8a62fc5bd7285e45f27f8b121aa35510fdd3573d2e9bd24dfa732943

Contents?: true

Size: 1.51 KB

Versions: 22

Compression:

Stored size: 1.51 KB

Contents

require 'rho_connect_install_constants'

module DownloadAndDocompress
  # download_and_decompress
  # Delegates the download and decompression duties
  def download_and_decompress(prefix, tarballs)
    tarballs.each do |url|
      if !File.exists?("#{ get_tarball_name url }") || !File.exists?("#{ get_version url }")
        puts "Downloading #{url} ..."
        wget_download prefix, url
        decompress prefix, url
      end
    end
  end

  # wget_download
  # Takes a URL and the name of a tarball and issues a wget command on said 
  # URL  unless the tarball or directory already exists
  def wget_download(prefix, url)
    if !File.exists?("#{ prefix }/#{ get_tarball_name url }") &&
       !File.directory?("#{ prefix }/#{ get_version url }")
       cmd "wget -P #{prefix} #{url} -o /dev/null"
    end
  end

  # decompress
  # Decompress downloaded files unless already decompressed directory
  # exists
  def decompress(prefix, url)
    tarball = get_tarball_name(url)
    dir = get_version(url)
    cmd "tar -xzf #{prefix}/#{tarball} -C #{prefix} > /dev/null 2>&1" unless File.directory? "#{prefix}/#{dir}"
  end #decompress
  
  # get_version
  # This method extracts the untarballed name of files retrieved via wget
  # from their URL
  def get_version(url)
    url =~ /.*\/(.*)\.t.*\Z/
    $1
  end #get_version

  # get_tarball_name
  # This method extracts the name of files retrieved via wget from their URL
  def get_tarball_name(url)
    url =~ /.*\/(.*\.t.*)/
    $1
  end #get_tarball_name
end #DownloadAndDocompress

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rhoconnect-4.0.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-4.0.0 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-4.0.0.beta.24 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.4.5 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-4.0.0.beta.10 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-4.0.0.beta.12 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.4.4 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.4.3 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.4.2 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.6 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.5 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.4 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.3 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.2 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.1.beta4 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.1.beta3 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.3.1.beta2 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.2.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.2.0 installer/unix-like/rho_connect_install_dnd.rb