Class: Sauce::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sauce/client.rb

Overview

The module that brokers most communication with Sauce Labs’ REST API

Defined Under Namespace

Classes: BadAccessError, MisconfiguredError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.

Raises:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sauce/client.rb', line 14

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. = {
    :username => config.username,
    :access_key => config.access_key,
    :ip => @ip
  }
end

Instance Attribute Details

#api_pathObject

Returns the value of attribute api_path.



11
12
13
# File 'lib/sauce/client.rb', line 11

def api_path
  @api_path
end

#api_urlObject

Returns the value of attribute api_url.



11
12
13
# File 'lib/sauce/client.rb', line 11

def api_url
  @api_url
end

#api_versionObject

Returns the value of attribute api_version.



11
12
13
# File 'lib/sauce/client.rb', line 11

def api_version
  @api_version
end

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/sauce/client.rb', line 10

def client
  @client
end

#hostObject

Returns the value of attribute host.



11
12
13
# File 'lib/sauce/client.rb', line 11

def host
  @host
end

#ipObject

Returns the value of attribute ip.



11
12
13
# File 'lib/sauce/client.rb', line 11

def ip
  @ip
end

#jobsObject

Returns the value of attribute jobs.



12
13
14
# File 'lib/sauce/client.rb', line 12

def jobs
  @jobs
end

#portObject

Returns the value of attribute port.



11
12
13
# File 'lib/sauce/client.rb', line 11

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



11
12
13
# File 'lib/sauce/client.rb', line 11

def protocol
  @protocol
end

Instance Method Details

#[](url) ⇒ Object



36
37
38
# File 'lib/sauce/client.rb', line 36

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