class Getme::Utilities
Public Instance Methods
cmd(badass, url)
click to toggle source
# File lib/getme/utilities.rb, line 3 def cmd(badass, url) if badass == :wget `wget #{Shellwords.escape url}` elsif badass == :curl `curl -O #{Shellwords.escape url}` end end
cmd?(cmd)
click to toggle source
check if cmd available from system
# File lib/getme/utilities.rb, line 22 def cmd?(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return true if File.executable? exe } end return false end
downloader()
click to toggle source
# File lib/getme/utilities.rb, line 11 def downloader if cmd?('wget') :wget elsif cmd?('curl') :curl else raise Getme::WgetOrCurlNotAvailableError, 'Wget or Curl not available for download files, install one? :D' end end