Sha256: 9c7b9107a2a84fd4f6c17bd37197d2083566e5505e167feb3a59977bf334a1c8
Contents?: true
Size: 1.2 KB
Versions: 9
Compression:
Stored size: 1.2 KB
Contents
require 'open-uri' module CanvasSync module Jobs # ActiveJob class that wraps around a report processor. This job will # download the report, and then pass the file path and options into the # process method on the processor. class ReportProcessorJob < CanvasSync::Job # @param job_chain [Hash] # @param report_name [Hash] e.g., 'provisioning_csv' # @param report_url [String] # @param processor [String] a stringified report processor class name # @param options [Hash] hash of options that will be passed to the job processor # @return [nil] def perform(job_chain, report_name, report_url, processor, options) @job_log.update_attributes(job_class: processor) download(report_name, report_url) do |file_path| options = job_chain[:global_options].merge(options) processor.constantize.process(file_path, options) end CanvasSync.invoke_next(job_chain) end private def download(report_name, report_url) Dir.mktmpdir do |dir| file_path = "#{dir}/#{report_name}" IO.copy_stream(open(report_url), file_path) yield file_path end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems