Class: Vagrant::Smartos::Zones::Util::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/smartos/zones/util/downloader.rb

Constant Summary collapse

GET_PARAMS =
{
  'wget' => '-qO',
  'curl' => '--silent -o'
}
READ_PARAMS =
{
  'wget' => '-qO-',
  'curl' => '--silent'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Downloader

Returns a new instance of Downloader.



18
19
20
21
# File 'lib/vagrant/smartos/zones/util/downloader.rb', line 18

def initialize(url)
  @url = url
  @utility = download_utility
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/vagrant/smartos/zones/util/downloader.rb', line 6

def url
  @url
end

#utilityObject (readonly)

Returns the value of attribute utility.



6
7
8
# File 'lib/vagrant/smartos/zones/util/downloader.rb', line 6

def utility
  @utility
end

Class Method Details

.get(url, path) ⇒ Object



23
24
25
# File 'lib/vagrant/smartos/zones/util/downloader.rb', line 23

def self.get(url, path)
  new(url).get(path)
end

Instance Method Details

#get(path) ⇒ Object



27
28
29
# File 'lib/vagrant/smartos/zones/util/downloader.rb', line 27

def get(path)
  `#{utility} #{url} #{GET_PARAMS[utility]} #{path}`
end

#readObject



31
32
33
# File 'lib/vagrant/smartos/zones/util/downloader.rb', line 31

def read
  `#{utility} #{url} #{READ_PARAMS[utility]}`
end