module ExportManager
ExportManager
is used by CaseManager
to export output reports
Public Class Methods
run(main_report, cases, input)
click to toggle source
Run export function @param main_report (Report
) @param cases (Array) @param input (Hash) Selected export options rubocop: disable Metrics/AbcSize
# File lib/teuton/case_manager/export_manager.rb, line 14 def self.run(main_report, cases, input) args = {} input.each_pair do |key, value| if value.class == String args[key] = value.to_sym else args[key] = value end end # default :mode=>:all, :format=>:txt format = args[:format] || Application.instance.default[:format] mode = args[:mode] || :all # Step 1: Export case reports if %i[details all].include? mode threads = [] cases.each { |c| threads << Thread.new { c.export format } } threads.each(&:join) end # Step 2: Export resume report main_report.export_resume format if %i[resume all].include? mode # Step 3: Preserve files if required preserve_files if args[:preserve] == true end
Private Class Methods
preserve_files()
click to toggle source
Preserve output files for current project rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Layout/LineLength
# File lib/teuton/case_manager/export_manager.rb, line 45 def self.preserve_files app = Application.instance t = Time.now data = { year: t.year, month: t.month, day: t.day, hour: t.hour, min: t.min, sec: t.sec } subdir = format('%<year>s%<month>02d%<day>02d-' \ '%<hour>02d%<min>02d%<sec>02d', data) logdir = File.join(app.output_basedir, app.global[:tt_testname], subdir) srcdir = File.join(app.output_basedir, app.global[:tt_testname]) puts "[INFO] Preserving files => #{logdir}" FileUtils.mkdir(logdir) Dir.glob(File.join(srcdir, '**.*')).each { |file| FileUtils.cp(file, logdir) } end