Class: ExportManager

Inherits:
Object
  • Object
show all
Defined in:
lib/teuton/case_manager/export_manager.rb

Overview

Execute “export” order: Export every case report

Instance Method Summary collapse

Instance Method Details

#call(main_report, cases, args, default_format) ⇒ Object

Run export function



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/teuton/case_manager/export_manager.rb', line 14

def call(main_report, cases, args, default_format)
  if args.class != Hash
    puts Rainbow("[ERROR] Export argument error!").red
    puts Rainbow("  Revise: export #{args}").red
    puts Rainbow("  Use   : export format: 'txt'").red
    puts ""
    exit 1
  end

  options = strings2symbols(args)
  if options[:format].nil?
    options[:format] = default_format
  end

  # Step 1: Export case reports
  threads = []
  cases.each { |c| threads << Thread.new { c.export(options) } }
  threads.each(&:join)

  # Step 2: Export resume report
  main_report.export_resume(options)

  # Step 3: Preserve files if required
  preserve_files if options[:preserve] == true
end