Class: SauceWhisk::Assets

Inherits:
Object
  • Object
show all
Extended by:
RestRequestBuilder
Defined in:
lib/sauce_whisk/assets.rb

Class Method Summary collapse

Methods included from RestRequestBuilder

auth_details, delete, fully_qualified_resource, get, make_request, post, put, request_from_rest_client

Class Method Details

.delete(job_id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/sauce_whisk/assets.rb', line 28

def self.delete(job_id)
retries ||= SauceWhisk.asset_fetch_retries
attempts ||= 1

data = rest_delete "#{job_id}/assets/"
Asset.new({:data => data,:job_id => job_id})
    rescue RestClient::ResourceNotFound => e
if attempts <= retries
  attempts += 1
  sleep(5)
retry
else
  raise e
end
    
    # Return nil as all of the assets we're already deleted.
    rescue RestClient::BadRequest => e
nil
end

.fetch(job_id, asset, type = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sauce_whisk/assets.rb', line 12

def self.fetch(job_id, asset, type=nil)
  retries ||= SauceWhisk.asset_fetch_retries
  attempts ||= 1

  data = get "#{job_id}/assets/#{asset}"
  Asset.new({:name => asset, :data => data, :job_id => job_id, :type => type})
rescue RestClient::ResourceNotFound => e
  if attempts <= retries
    attempts += 1
    sleep(5)
  retry
  else
    raise e
  end
end

.resourceObject



8
9
10
# File 'lib/sauce_whisk/assets.rb', line 8

def self.resource
  "#{SauceWhisk.username}/jobs"
end

.rest_deleteObject



5
# File 'lib/sauce_whisk/assets.rb', line 5

alias_method :rest_delete, :delete