Sha256: e0c983904fef40637752128be0619be6f916936535042d1d8ffdf21206405aac
Contents?: true
Size: 1.31 KB
Versions: 21
Compression:
Stored size: 1.31 KB
Contents
require 'rubygems' require 'rest_client' require 'json' module SauceREST # A simple class for using the Sauce Labs REST API class Client @@roots = { :script => 'scripts', :job => 'jobs', :result => 'results', :tunnel => 'tunnels' } def initialize base_url @base_url = base_url @resource = RestClient::Resource.new @base_url end def create type, *args doc = args[-1] doc_json = doc.to_json resp_json = @resource[@@roots[type]].post(doc_json, :content_type => 'application/octet-stream') resp = JSON.parse resp_json return resp end def get type, docid resp_json = @resource[@@roots[type] + '/' + docid].get resp = JSON.parse resp_json return resp end def attach docid, name, data resp_json = @resource[@@roots[:script] + '/' + docid + '/' + name].put data resp = JSON.parse resp_json return resp end def delete type, docid resp_json = @resource[@@roots[type] + '/' + docid].delete resp = JSON.parse resp_json return resp end def list type resp_json = @resource[@@roots[type] + '/'].get resp = JSON.parse resp_json return resp end end end
Version data entries
21 entries across 21 versions & 1 rubygems