lib/teuton/case_manager/report.rb in teuton-2.1.8 vs lib/teuton/case_manager/report.rb in teuton-2.1.9
- old
+ new
@@ -1,33 +1,40 @@
-
+require 'rainbow'
+##
+# Class CaseManager
+# Methods related with report
class CaseManager
private
- def open_main_report(p_config_filename)
+ ##
+ # Open main report (resume report)
+ # @param config_filepath (String)
+ def open_main_report(config_filepath)
app = Application.instance
@report.head[:tt_title] = "Executing [#{app.name}] (version #{Application::VERSION})"
- @report.head[:tt_scriptname] = app.script_path
- @report.head[:tt_configfile] = p_config_filename
+ @report.head[:tt_scriptname] = trim(app.script_path)
+ @report.head[:tt_configfile] = trim(config_filepath)
+ @report.head[:tt_pwd] = app.running_basedir
@report.head[:tt_debug] = true if @debug
- # @report.head[:tt_uses] = app.uses.join(', ')
+ # @report.head[:tt_uses] = app.uses.join(', ') # TO-REVISE
@report.head.merge!(app.global)
verboseln ' '
verboseln '=' * @report.head[:tt_title].length
- verboseln @report.head[:tt_title]
+ verboseln Rainbow(@report.head[:tt_title]).yellow.bright
end
def close_main_report(start_time)
finish_time = Time.now
@report.tail[:start_time] = start_time
@report.tail[:finish_time] = finish_time
@report.tail[:duration] = finish_time - start_time
- verbose "\n[INFO] Duration = #{format('%3.3f',(finish_time - start_time))}"
- verboseln " (#{finish_time})"
+ verbose Rainbow("\n[INFO] Duration = #{format('%3.3f',(finish_time - start_time))}").yellow.bright
+ verboseln Rainbow(" (#{finish_time})").yellow.bright
verboseln '=' * @report.head[:tt_title].length
verboseln ' '
app = Application.instance
@cases.each do |c|
@@ -46,7 +53,21 @@
line[:moodle_id] = c.get(:tt_moodle_id)
line[:moodle_feedback] = "\"Filename: #{c.filename}. Date: #{Time.now}\""
end
@report.lines << line
end
+ end
+
+ ##
+ # Trim string text when is too long
+ # @param input (String)
+ # @return String
+ def trim(input)
+ return input unless input.to_s.start_with? Dir.pwd.to_s
+ return input if input == Dir.pwd.to_s
+
+ output = input.to_s
+ offset = (Dir.pwd).length + 1
+ output = "#{input[offset, input.size]}"
+ output.to_s
end
end