Class: Boshify::UbuntuPackages

Inherits:
Object
  • Object
show all
Defined in:
lib/boshify/ubuntu_packages.rb

Overview

Ubuntu package source

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ UbuntuPackages

Returns a new instance of UbuntuPackages.



10
11
12
13
14
# File 'lib/boshify/ubuntu_packages.rb', line 10

def initialize(options = {})
  @downloader = options[:downloader]
  @cmd_runner = options[:cmd_runner]
  self.mirror_url = options[:mirror_url] || 'http://us.archive.ubuntu.com/ubuntu'
end

Instance Attribute Details

#mirror_urlObject

Returns the value of attribute mirror_url.



8
9
10
# File 'lib/boshify/ubuntu_packages.rb', line 8

def mirror_url
  @mirror_url
end

Instance Method Details

#parse(input) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/boshify/ubuntu_packages.rb', line 33

def parse(input)
  group_package_values(
    as_a_hash(
      parse_multiline_values(
        group_by_whether_pairs(
          split_key_value_pairs(input)))))
end

#refreshObject



20
21
22
23
# File 'lib/boshify/ubuntu_packages.rb', line 20

def refresh
  @all_packages = packages_hash(
    parse(decompress()))
end

#source_tarball_url(package_name) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/boshify/ubuntu_packages.rb', line 25

def source_tarball_url(package_name)
  unless @all_packages[package_name]
    fail PackageNotFoundError, "Package #{package_name} was not found"
  end
  pkg = @all_packages[package_name]
  mirror_url + "#{pkg['Directory']}/#{original_tarball(pkg)}"
end