lib/teuton/case_manager/export_manager.rb in teuton-2.5.0 vs lib/teuton/case_manager/export_manager.rb in teuton-2.6.0

- old
+ new

@@ -1,16 +1,28 @@ # frozen_string_literal: true +require "rainbow" require_relative "../application" -module ExportManager +## +# Execute "export" order: Export every case report +# @param args (Hash) Export options +class ExportManager ## # Run export function # @param main_report (Report) # @param cases (Array) # @param input (Hash) Selected export options - def self.run(main_report, cases, args) + def call(main_report, cases, args) + 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] = Application.instance.default[:format] end @@ -24,14 +36,16 @@ # Step 3: Preserve files if required preserve_files if options[:preserve] == true end + private + ## # Convert Hash String values into Symbol values # @param input (Hash) - private_class_method def self.strings2symbols(input) + def strings2symbols(input) args = {} input.each_pair do |key, value| args[key] = if value.instance_of? String value.to_sym else @@ -41,10 +55,10 @@ args end ## # Preserve output files for current project execution - private_class_method def self.preserve_files + def 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)