Sha256: 7ad368021c9de51e8ab188d6903557bf2a02a8ec51e6de369b404ced6f5b8cad

Contents?: true

Size: 1.18 KB

Versions: 68

Compression:

Stored size: 1.18 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 :client
    attr_accessor :protocol, :host, :port, :api_path, :api_version, :ip, :api_url
    attr_accessor :jobs

    def initialize(options={})
      config = Sauce::Config.new

      @protocol   = options[:protocol] || "http"
      @host       = options[:host] || "saucelabs.com"
      @port       = options[:port] || 80
      @api_path   = options[:api_path] || "rest"
      @api_version= options[:api_version] || 1

      raise MisconfiguredError if config.username.nil? or config.access_key.nil?
      @api_url = "#{@protocol}://#{config.username}:#{config.access_key}@#{@host}:#{@port}/#{@api_path}/v#{@api_version}/#{config.username}/"
      @client = RestClient::Resource.new @api_url

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

    def [](url)
      @client[url]
    end
  end
end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
sauce-3.7.2 lib/sauce/client.rb
sauce-3.7.1 lib/sauce/client.rb
sauce-3.7.0 lib/sauce/client.rb
sauce-3.5.11 lib/sauce/client.rb
sauce-3.5.10 lib/sauce/client.rb
sauce-3.5.9 lib/sauce/client.rb
sauce-3.5.8 lib/sauce/client.rb
sauce-3.5.7 lib/sauce/client.rb
sauce_ruby-3.5.11 lib/sauce/client.rb
sauce_ruby-3.5.10 lib/sauce/client.rb
sauce_ruby-3.5.9 lib/sauce/client.rb
sauce_ruby-3.5.8 lib/sauce/client.rb
sauce_ruby-3.5.7 lib/sauce/client.rb
sauce_ruby-3.5.6 lib/sauce/client.rb
sauce-3.5.6 lib/sauce/client.rb
sauce-3.5.5 lib/sauce/client.rb
sauce-3.5.4 lib/sauce/client.rb
sauce-3.5.3 lib/sauce/client.rb
sauce-3.5.2 lib/sauce/client.rb
sauce-3.5.1 lib/sauce/client.rb