Class: Sauce::Client
- Inherits:
-
Object
- Object
- Sauce::Client
- 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
-
#api_path ⇒ Object
Returns the value of attribute api_path.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#client ⇒ Object
Returns the value of attribute client.
-
#host ⇒ Object
Returns the value of attribute host.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#jobs ⇒ Object
Returns the value of attribute jobs.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
Instance Method Summary collapse
- #[](url) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
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(={}) config = Sauce::Config.new @protocol = [:protocol] || "http" @host = [:host] || "saucelabs.com" @port = [:port] || 80 @api_path = [:api_path] || "rest" @api_version= [: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 |
Instance Attribute Details
#api_path ⇒ Object
Returns the value of attribute api_path.
11 12 13 |
# File 'lib/sauce/client.rb', line 11 def api_path @api_path end |
#api_url ⇒ Object
Returns the value of attribute api_url.
11 12 13 |
# File 'lib/sauce/client.rb', line 11 def api_url @api_url end |
#api_version ⇒ Object
Returns the value of attribute api_version.
11 12 13 |
# File 'lib/sauce/client.rb', line 11 def api_version @api_version end |
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/sauce/client.rb', line 10 def client @client end |
#host ⇒ Object
Returns the value of attribute host.
11 12 13 |
# File 'lib/sauce/client.rb', line 11 def host @host end |
#ip ⇒ Object
Returns the value of attribute ip.
11 12 13 |
# File 'lib/sauce/client.rb', line 11 def ip @ip end |
#jobs ⇒ Object
Returns the value of attribute jobs.
12 13 14 |
# File 'lib/sauce/client.rb', line 12 def jobs @jobs end |
#port ⇒ Object
Returns the value of attribute port.
11 12 13 |
# File 'lib/sauce/client.rb', line 11 def port @port end |
#protocol ⇒ Object
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 |