Sha256: d8e87dce3613f2852c4014c8c0ee303bdfa4614c65389bdd2c5b63851cebff3a

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

require "bixby-common"
require "bixby-auth"

require "bixby-client/script_util"
require "bixby-client/model"
require "bixby-client/modules"
require "bixby-client/command"
require "bixby-client/client"

module Bixby

  class << self

    # Set the Bixby::Client to be used
    def client=(client)
      @client = client
    end

    # Get a Bixby::Client instance
    def client
      @client ||= create_client()
    end


    private

    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
  end

end # Bixby

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bixby-client-0.5.1 lib/bixby-client.rb