Class: CanvasSync::Processors::ProvisioningReportProcessor

Inherits:
ReportProcessor
  • Object
show all
Defined in:
lib/canvas_sync/processors/provisioning_report_processor.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ReportProcessor

#do_bulk_import, #mapping, #mapping_for

Constructor Details

#initialize(report_file_path, options) ⇒ ProvisioningReportProcessor

rubocop:disable Metrics/AbcSize



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/canvas_sync/processors/provisioning_report_processor.rb', line 22

def initialize(report_file_path, options) # rubocop:disable Metrics/AbcSize
  @options = options
  if options[:models].length == 1
    run_import(options[:models][0], report_file_path)
  else
    unzipped_file_path = extract(report_file_path)
    Dir[unzipped_file_path + "/*.csv"].sort.each do |file_path|
      model_name = file_path.split("/").last.split(".").first
      run_import(model_name, file_path)
    end
  end
end

Class Method Details

.process(report_file_path, options, report_id) ⇒ Object

Processes a provisioning report using the bulk importer.

options must contain a models key. If there is only one model Canvas downloads the single report directly as a CSV. If it’s more than one model Canvas downloads a ZIP file, so we have to extract that and iterate through it for processing.

Parameters:

  • report_file_path (String)
  • options (Hash)


18
19
20
# File 'lib/canvas_sync/processors/provisioning_report_processor.rb', line 18

def self.process(report_file_path, options, report_id)
  new(report_file_path, options)
end