Sha256: 0965622c308c86030021c510df2952362bcbbac46e7cfb261bb9acba1411f9e7

Contents?: true

Size: 930 Bytes

Versions: 1

Compression:

Stored size: 930 Bytes

Contents

require "down_universe/version"
require "safe_shell"

module DownUniverse
  module Downloadable
    
    # Public: Downloads a given HTTP url with 'wget'.
    #
    # url - The url to be downloaded. That should respond to to_str.
    # output - Name and path of the output file.
    # user - set both ftp and http user(Optional).
    # password - set both ftp and http password(Optional).
    #
    # Returns boolean
    #
    # Examples
    #
    # http_download('http://test.com/som_file.iso', '/Users/test/file.iso')
    # # => true
    #
    # http_download('http://test.com/som_file.iso', '/Users/test/file.iso')
    # # => false
    def http_download(url, output, user=nil, password=nil)
      command = "wget -O #{output}"
      command += " --user=#{user}" unless user.nil?
      command += " --password=#{password}" unless password.nil?
      command += " #{url.to_str}"
      SafeShell.execute! command
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
down_universe-0.0.1 lib/down_universe.rb