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
79 80 81 |
# File 'lib/crowbar/client/config.rb', line 79 def config @config ||= Hashie::Mash.new end |
#options ⇒ Hashie::Mash
Define parameter config
70 71 72 |
# File 'lib/crowbar/client/config.rb', line 70 def @options ||= defaults end |
#values ⇒ Hashie::Mash
Define merged config
88 89 90 |
# File 'lib/crowbar/client/config.rb', line 88 def values @values ||= Hashie::Mash.new end |
Class Method Details
.config ⇒ Hashie::Mash
Define file config
301 302 303 |
# File 'lib/crowbar/client/config.rb', line 301 def config instance.config end |
.configure(options) ⇒ Object
Define base configuration
271 272 273 |
# File 'lib/crowbar/client/config.rb', line 271 def configure() instance.configure() end |
.defaults ⇒ Hashie::Mash
Define default config
281 282 283 |
# File 'lib/crowbar/client/config.rb', line 281 def defaults instance.defaults end |
.method_missing(method, *arguments) { ... } ⇒ Object
Magic to catch missing method calls
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/crowbar/client/config.rb', line 322 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
291 292 293 |
# File 'lib/crowbar/client/config.rb', line 291 def instance. end |
.respond_to?(method, include_private = false) ⇒ Bool
Magic to catch missing respond_to calls
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/crowbar/client/config.rb', line 346 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
311 312 313 |
# File 'lib/crowbar/client/config.rb', line 311 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 |
# 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, timeout: default_timeout, anonymous: default_anonymous, apiversion: default_apiversion, debug: default_debug ) end |