Sha256: 18082165998f4d2bb5f950e459387e7294e30d734d95393d9a79dcc92a8255be

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'rest_client'
require 'json'

module Sauce
  # The module that brokers most communication with Sauce Labs' REST API
  class Client
    class BadAccessError < StandardError; end #nodoc
    class MisconfiguredError < StandardError; end #nodoc

    attr_accessor :username, :access_key, :client, :ip, :api_url
    attr_accessor :tunnels, :jobs

    def initialize(options)
      @username   = options[:username]
      @access_key = options[:access_key]
      @ip         = options[:ip]

      raise MisconfiguredError if @username.nil? or @access_key.nil?
      @api_url = "https://#{@username}:#{@access_key}@saucelabs.com/rest/#{@username}/"
      @client = RestClient::Resource.new @api_url

      @tunnels = Sauce::Tunnel
      @tunnels.client = @client
      @tunnels.account = {:username => @username,
        :access_key => @access_key,
        :ip => @ip}

      @jobs = Sauce::Job
      @jobs.client = @client
      @jobs.account = {:username => @username,
        :access_key => @access_key,
        :ip => @ip}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sauce-0.3.0 lib/rest.rb