Class: Cyoi::Cli::Address
- Inherits:
-
Object
- Object
- Cyoi::Cli::Address
- Includes:
- Helpers
- Defined in:
- lib/cyoi/cli/address.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#address_cli ⇒ Object
Continue the interactive session with the user specific to the address/infrastructure they have chosen.
-
#execute! ⇒ Object
TODO run Cyoi::Cli::Provider first if settings.provider.name missing.
-
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Address
constructor
A new instance of Address.
Methods included from Helpers::Settings
#migrate_old_settings, #reload_settings!, #save_settings!, #settings, #settings_dir, #settings_path, #settings_ssh_dir, #show_settings
Methods included from Helpers::Provider
#fog_compute, #provider_client
Methods included from Helpers::Interactions
#bold, #clear, #cyan, #green, #hl, #red, #yellow
Constructor Details
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Address
Returns a new instance of Address.
7 8 9 10 11 |
# File 'lib/cyoi/cli/address.rb', line 7 def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel) @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel @settings_dir = @argv.shift || "/tmp/provider_settings" @settings_dir = File.(@settings_dir) end |
Class Method Details
.address_cli(name) ⇒ Object
50 51 52 |
# File 'lib/cyoi/cli/address.rb', line 50 def self.address_cli(name) @address_clis[name] end |
.register_address_cli(name, klass) ⇒ Object
45 46 47 48 |
# File 'lib/cyoi/cli/address.rb', line 45 def self.register_address_cli(name, klass) @address_clis ||= {} @address_clis[name] = klass end |
Instance Method Details
#address_cli ⇒ Object
Continue the interactive session with the user specific to the address/infrastructure they have chosen.
The returned object is a class from cyoi/cli/addresss/provier_cli_NAME.rb The class loads itself into ‘@address_clis` via `register_address_cli`
Returns nil if settings.address.name not set
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cyoi/cli/address.rb', line 34 def address_cli @address_cli ||= begin provider_name = settings.exists?("provider.name") return nil unless provider_name require "cyoi/cli/provider_addresses/address_cli_#{settings.provider.name}" klass = self.class.address_cli(settings.provider.name) settings["address"] ||= {} klass.new(provider_client, settings.address, hl) end end |
#execute! ⇒ Object
TODO run Cyoi::Cli::Provider first if settings.provider.name missing
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cyoi/cli/address.rb', line 14 def execute! unless settings.exists?("provider.name") $stderr.puts("Please run 'cyoi provider' first") exit 1 end unless valid_address? settings["address"] = address_cli.perform_and_return_attributes save_settings! end address_cli.display_confirmation end |