Module: PowerIQ::Configuration

Defined in:
lib/poweriq_client/configuration.rb

Constant Summary collapse

DEFAULT_YAML_CONFIG =
File.join(ENV['HOME'],".poweriq_client")

Class Method Summary collapse

Class Method Details

.configure(options = nil, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/poweriq_client/configuration.rb', line 11

def configure(options=nil,&block)
  unless(options.nil?)
    options.symbolize_keys!
    self.user = options[:user]
    self.password = options[:password]
    self.host = options[:host]
  end
  if(block_given?)
    yield self
  end
end

.host=(host) ⇒ Object



28
29
30
# File 'lib/poweriq_client/configuration.rb', line 28

def host=(host)
  PowerIQ::Resource::Base.host = host
end

.load_configuration(key, file = DEFAULT_YAML_CONFIG) ⇒ Object



5
6
7
8
9
10
# File 'lib/poweriq_client/configuration.rb', line 5

def load_configuration(key,file=DEFAULT_YAML_CONFIG)
  config = YAML.load(File.read(file))
  if(config && config.has_key?(key))
    PowerIQ::Configuration.configure(config[key])
  end
end

.password=(password) ⇒ Object



25
26
27
# File 'lib/poweriq_client/configuration.rb', line 25

def password=(password)
  PowerIQ::Resource::Base.password = password
end

.user=(user) ⇒ Object



22
23
24
# File 'lib/poweriq_client/configuration.rb', line 22

def user=(user)
  PowerIQ::Resource::Base.user = user
end