Class: Sauce::SauceFacade
- Inherits:
-
Object
- Object
- Sauce::SauceFacade
- Defined in:
- lib/sauce/sauce_facade.rb
Overview
wrapps the sauce whick api accessor with sane error handling
Instance Attribute Summary collapse
-
#job_id ⇒ Object
Returns the value of attribute job_id.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #fail_job ⇒ Object
- #fetch_job_data ⇒ Object
- #fetch_last_screenshot ⇒ Object
- #fetch_server_log ⇒ Object
-
#initialize(timeout = 10) ⇒ SauceFacade
constructor
A new instance of SauceFacade.
- #pass_job ⇒ Object
Constructor Details
#initialize(timeout = 10) ⇒ SauceFacade
Returns a new instance of SauceFacade.
14 15 16 |
# File 'lib/sauce/sauce_facade.rb', line 14 def initialize(timeout = 10) @timeout = timeout ||= 10 end |
Instance Attribute Details
#job_id ⇒ Object
Returns the value of attribute job_id.
12 13 14 |
# File 'lib/sauce/sauce_facade.rb', line 12 def job_id @job_id end |
#timeout ⇒ Object
Returns the value of attribute timeout.
12 13 14 |
# File 'lib/sauce/sauce_facade.rb', line 12 def timeout @timeout end |
Instance Method Details
#fail_job ⇒ Object
18 19 20 21 |
# File 'lib/sauce/sauce_facade.rb', line 18 def fail_job requires_job_id SauceWhisk::Jobs.fail_job @job_id end |
#fetch_job_data ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sauce/sauce_facade.rb', line 42 def fetch_job_data requires_job_id # TODO: let's switch this over to use whisk as well # This is used because it's easy to get all the data out of the job begin job = Sauce::Job.find @job_id JSON.parse job.to_json rescue StandardError => exception puts "An error occured while fetching the job data: #{exception.}" end end |
#fetch_last_screenshot ⇒ Object
28 29 30 31 32 33 |
# File 'lib/sauce/sauce_facade.rb', line 28 def fetch_last_screenshot requires_job_id polling_api_request @timeout do SauceWhisk::Jobs.fetch_asset @job_id, 'final_screenshot.png' end end |
#fetch_server_log ⇒ Object
35 36 37 38 39 40 |
# File 'lib/sauce/sauce_facade.rb', line 35 def fetch_server_log requires_job_id polling_api_request @timeout do SauceWhisk::Jobs.fetch_asset @job_id, 'selenium-server.log' end end |
#pass_job ⇒ Object
23 24 25 26 |
# File 'lib/sauce/sauce_facade.rb', line 23 def pass_job requires_job_id SauceWhisk::Jobs.pass_job @job_id end |