Class: Pot::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/pot/bundle.rb

Defined Under Namespace

Classes: UndefinedPackage

Instance Method Summary collapse

Constructor Details

#initialize(packages = []) ⇒ Bundle

Returns a new instance of Bundle.



10
11
12
# File 'lib/pot/bundle.rb', line 10

def initialize(packages = [])
  @packages = [packages].flatten
end

Instance Method Details

#add(package) ⇒ Object



34
35
36
# File 'lib/pot/bundle.rb', line 34

def add(package)
  @packages << package
end

#listObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pot/bundle.rb', line 14

def list
  all = []

  @packages.each do |package_name|
    cloud_info "Requires package #{package_name}\n"

    package = Pot::Package::REGISTER[package_name]
    raise UndefinedPackage, package_name unless package
    package = select_package(package_name, package) if package.is_a? Array # handle virtual package selection

    tree = package.tree do |parent, child, depth|
      indent = "\t" * depth; cloud_info "#{indent}Package #{parent.name} requires #{child.name}"
    end

    all << tree
  end

  normalize(all)
end