Class: Sprinkle::Package::Chooser

Inherits:
Object
  • Object
show all
Defined in:
lib/sprinkle/package/chooser.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.cloud_info(message) ⇒ Object


19
20
21
# File 'lib/sprinkle/package/chooser.rb', line 19

def self.cloud_info(message)
  logger.info(message) if Sprinkle::OPTIONS[:cloud] or logger.debug?
end

.select_package(name, packages) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sprinkle/package/chooser.rb', line 4

def self.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}"
      packages.each do |pkg|
        menu.choice(pkg.to_s) { pkg; }
      end
    end
  end
  cloud_info "Selecting #{package.to_s} for virtual package #{name}"
  package
end