module Bixby

Public Class Methods

client() click to toggle source

Get a Bixby::Client instance

# File lib/bixby-client.rb, line 25
def client
  @client ||= create_client()
end
client=(client) click to toggle source

Set the Bixby::Client to be used

# File lib/bixby-client.rb, line 20
def client=(client)
  @client = client
end

Private Class Methods

create_client() click to toggle source
# File lib/bixby-client.rb, line 32
def create_client
  raise "BIXBY_HOME not set" if not root

  config_file = Bixby.path("etc", "bixby.yml")
  raise "#{config_file} not found" if not File.exists? config_file

  config = YAML.load_file(config_file)
  if not config.kind_of? Hash or
    !(config.include? "access_key" and config.include? "secret_key") then

    raise "invalid config file #{config_file}"
  end

  Bixby.manager_uri = config["manager_uri"]
  return Bixby::Client.new(config["access_key"], config["secret_key"])
end