Class: Cyoi::Cli::AutoDetection::UI
- Inherits:
-
Object
- Object
- Cyoi::Cli::AutoDetection::UI
- Defined in:
- lib/cyoi/cli/auto_detection.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#hl ⇒ Object
readonly
Returns the value of attribute hl.
Instance Method Summary collapse
- #aggregated_detector_choices ⇒ Object
- #detectors ⇒ Object
-
#export_attributes ⇒ Object
helper to export the complete nested attributes.
-
#initialize(attributes, highline) ⇒ UI
constructor
A new instance of UI.
- #perform ⇒ Object
Constructor Details
#initialize(attributes, highline) ⇒ UI
Returns a new instance of UI.
9 10 11 12 13 |
# 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 |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/cyoi/cli/auto_detection.rb', line 6 def attributes @attributes end |
#hl ⇒ Object (readonly)
Returns the value of attribute hl.
7 8 9 |
# File 'lib/cyoi/cli/auto_detection.rb', line 7 def hl @hl end |
Instance Method Details
#aggregated_detector_choices ⇒ Object
37 38 39 40 41 42 43 44 |
# 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 ⇒ Object
46 47 48 49 50 |
# File 'lib/cyoi/cli/auto_detection.rb', line 46 def detectors [ Cyoi::Cli::AutoDetection::AutoDetectionFog ] end |
#export_attributes ⇒ Object
helper to export the complete nested attributes.
33 34 35 |
# File 'lib/cyoi/cli/auto_detection.rb', line 33 def export_attributes attributes.to_nested_hash end |
#perform ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 || .prompt = "Choose an auto-detected infrastructure: " aggregated_detector_choices.each do |label, credentials| .choice(label) do attributes.set("name", credentials.delete("name")) attributes.set("credentials", credentials) end end .choice("Alternate credentials") { false } end end end |