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
78 79 80 |
# File 'lib/crowbar/client/config.rb', line 78 def config @config ||= Hashie::Mash.new end |
#options ⇒ Hashie::Mash
Define parameter config
69 70 71 |
# File 'lib/crowbar/client/config.rb', line 69 def @options ||= defaults end |
#values ⇒ Hashie::Mash
Define merged config
87 88 89 |
# File 'lib/crowbar/client/config.rb', line 87 def values @values ||= Hashie::Mash.new end |
Class Method Details
.config ⇒ Hashie::Mash
Define file config
285 286 287 |
# File 'lib/crowbar/client/config.rb', line 285 def config instance.config end |
.configure(options) ⇒ Object
Define base configuration
255 256 257 |
# File 'lib/crowbar/client/config.rb', line 255 def configure() instance.configure() end |
.defaults ⇒ Hashie::Mash
Define default config
265 266 267 |
# File 'lib/crowbar/client/config.rb', line 265 def defaults instance.defaults end |
.method_missing(method, *arguments) { ... } ⇒ Object
Magic to catch missing method calls
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/crowbar/client/config.rb', line 306 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
275 276 277 |
# File 'lib/crowbar/client/config.rb', line 275 def instance. end |
.respond_to?(method, include_private = false) ⇒ Bool
Magic to catch missing respond_to calls
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/crowbar/client/config.rb', line 330 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
295 296 297 |
# File 'lib/crowbar/client/config.rb', line 295 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 |
# 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, debug: default_debug ) end |