Class: Crowbar::Client::Config
- Inherits:
-
Object
- Object
- Crowbar::Client::Config
- Includes:
- Singleton
- Defined in:
- lib/crowbar/client/config.rb
Overview
General configuration for the Crowbar CLI
Instance Attribute Summary collapse
-
#config ⇒ Hashie::Mash
Define file config.
-
#options ⇒ Hashie::Mash
Define parameter config.
-
#values ⇒ Hashie::Mash
Define merged config.
Class Method Summary collapse
-
.config ⇒ Hashie::Mash
Define file config.
-
.configure(options) ⇒ Object
Define base configuration.
-
.defaults ⇒ Hashie::Mash
Define default config.
-
.method_missing(method, *arguments) { ... } ⇒ Object
Magic to catch missing method calls.
-
.options ⇒ Hashie::Mash
Define parameter config.
-
.respond_to?(method, include_private = false) ⇒ Bool
Magic to catch missing respond_to calls.
-
.values ⇒ Hashie::Mash
Define merged config.
Instance Method Summary collapse
-
#configure(options) ⇒ Object
Define base configuration.
-
#defaults ⇒ Hashie::Mash
Define default config.
Instance Attribute Details
#config ⇒ Hashie::Mash
Define file config
83 84 85 |
# File 'lib/crowbar/client/config.rb', line 83 def config @config ||= Hashie::Mash.new end |
#options ⇒ Hashie::Mash
Define parameter config
74 75 76 |
# File 'lib/crowbar/client/config.rb', line 74 def @options ||= defaults end |
#values ⇒ Hashie::Mash
Define merged config
92 93 94 |
# File 'lib/crowbar/client/config.rb', line 92 def values @values ||= Hashie::Mash.new end |
Class Method Details
.config ⇒ Hashie::Mash
Define file config
374 375 376 |
# File 'lib/crowbar/client/config.rb', line 374 def config instance.config end |
.configure(options) ⇒ Object
Define base configuration
344 345 346 |
# File 'lib/crowbar/client/config.rb', line 344 def configure() instance.configure() end |
.defaults ⇒ Hashie::Mash
Define default config
354 355 356 |
# File 'lib/crowbar/client/config.rb', line 354 def defaults instance.defaults end |
.method_missing(method, *arguments) { ... } ⇒ Object
Magic to catch missing method calls
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/crowbar/client/config.rb', line 395 def method_missing(method, *arguments, &block) case when method.to_s.ends_with?("=") key = method.to_s.gsub(/=\z/, "") if values.key?(key) values[key] = arguments.first else super end when values.key?(method) values[method] else super end end |
.options ⇒ Hashie::Mash
Define parameter config
364 365 366 |
# File 'lib/crowbar/client/config.rb', line 364 def instance. end |
.respond_to?(method, include_private = false) ⇒ Bool
Magic to catch missing respond_to calls
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/crowbar/client/config.rb', line 419 def respond_to?(method, include_private = false) case when method.to_s.ends_with?("=") key = method.to_s.gsub(/=\z/, "") if values.key?(key) true else super end when values.key?(method) true else super end end |
.values ⇒ Hashie::Mash
Define merged config
384 385 386 |
# File 'lib/crowbar/client/config.rb', line 384 def values instance.values end |
Instance Method Details
#configure(options) ⇒ Object
Define base configuration
38 39 40 41 42 43 44 45 |
# File 'lib/crowbar/client/config.rb', line 38 def configure() self. = Hashie::Mash.new( ) self.config = parser self.values = merge end |
#defaults ⇒ Hashie::Mash
Define default config
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/crowbar/client/config.rb', line 52 def defaults @defaults ||= Hashie::Mash.new( alias: default_alias, username: default_username, password: default_password, server: default_server, verify_ssl: default_verify_ssl, timeout: default_timeout, anonymous: default_anonymous, apiversion: default_apiversion, experimental: default_experimental, upgrade_versions: default_upgrade_versions, cloud_version: default_cloud_version, debug: default_debug ) end |