Class: Scry::ExportGenerator

Inherits:
Object
  • Object
show all
Includes:
Helpers, Sidekiq::Worker
Defined in:
lib/scry/sidekiq/workers/export_generator.rb

Instance Method Summary collapse

Methods included from Helpers

#click_link, #write_log

Instance Method Details

#perform(cookie_crumbs, course_url) ⇒ Object

Instigates generating an export.

Creates a course from the cookies, then starts generating the export.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/scry/sidekiq/workers/export_generator.rb', line 25

def perform(cookie_crumbs, course_url)
  course = Course.from_cookies(cookie_crumbs, course_url)
  exports_page = course.create_export
  if exports_page.is_a? Mechanize::Page
    valid = course.validate_export(exports_page)
    if valid
      write_log(Scry.export_generation_good, course_url)
      download_url = course.download_url(exports_page)
      Scry::ExportDownloader.perform_async(
        cookie_crumbs,
        course_url,
        download_url,
      )
    else
      write_log(Scry.export_generation_bad, course_url)
      raise Scry::ExportFailed, "Something failed"
    end
  end
end