lib/sprinkle/package.rb in crafterm-sprinkle-0.2.1 vs lib/sprinkle/package.rb in crafterm-sprinkle-0.2.2

- old
+ new

@@ -235,10 +235,12 @@ packages << package.tree(depth + 1, &block) end @dependencies.each do |dep| package = PACKAGES[dep] + package = select_package(dep, package) if package.is_a? Array + raise "Package definition not found for key: #{dep}" unless package block.call(self, package, depth) if block packages << package.tree(depth + 1, &block) end @@ -246,9 +248,25 @@ end def to_s; @name; end private + + def select_package(name, packages) + if packages.size <= 1 + package = packages.first + else + package = choose do |menu| + menu.prompt = "Multiple choices exist for virtual package #{name}" + menu.choices *packages.collect(&:to_s) + end + package = Sprinkle::Package::PACKAGES[package] + end + + cloud_info "Selecting #{package.to_s} for virtual package #{name}" + + package + end def meta_package? @installer == nil end end