class Cyoi::Cli::AutoDetection::UI
Attributes
attributes[R]
hl[R]
Public Class Methods
new(attributes, highline)
click to toggle source
# File lib/cyoi/cli/auto_detection.rb, line 9 def initialize(attributes, highline) @hl = highline @attributes = attributes.is_a?(Hash) ? ReadWriteSettings.new(attributes) : attributes raise "@attributes must be ReadWriteSettings (or Hash)" unless @attributes.is_a?(ReadWriteSettings) end
Public Instance Methods
aggregated_detector_choices()
click to toggle source
# File lib/cyoi/cli/auto_detection.rb, line 37 def aggregated_detector_choices @aggregated_detector_choices ||= begin detectors.inject({}) do |choices, detector_class| detector = detector_class.new choices.merge!(detector.auto_detection_choices) end end end
detectors()
click to toggle source
# File lib/cyoi/cli/auto_detection.rb, line 46 def detectors [ Cyoi::Cli::AutoDetection::AutoDetectionFog ] end
export_attributes()
click to toggle source
helper to export the complete nested attributes.
# File lib/cyoi/cli/auto_detection.rb, line 33 def export_attributes attributes.to_nested_hash end
perform()
click to toggle source
# File lib/cyoi/cli/auto_detection.rb, line 15 def perform # Display menu of choices # Include "Alternate credentials" as the last option if aggregated_detector_choices.keys.size > 0 hl.choose do |menu| menu.prompt = "Choose an auto-detected infrastructure: " aggregated_detector_choices.each do |label, credentials| menu.choice(label) do attributes.set("name", credentials.delete("name")) attributes.set("credentials", credentials) end end menu.choice("Alternate credentials") { false } end end end