Module: ReportExtension
- Included in:
- CaseManager
- Defined in:
- lib/teuton/case_manager/ext/report.rb
Instance Method Summary collapse
- #close_main_report(start_time) ⇒ Object
-
#open_main_report(config_filepath) ⇒ Object
Open main report (resume report).
-
#trim(input) ⇒ Object
Trim string text when is too long.
Instance Method Details
#close_main_report(start_time) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/teuton/case_manager/ext/report.rb', line 19 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 duration = format("%3.3f", finish_time - start_time) verboseln Rainbow("\nFinished in #{duration} seconds").green verboseln Rainbow("-" * 36).green verboseln " " @cases.each do |c| line = {} if c.skip? line = { skip: true, id: "-", grade: 0.0, letter: Settings.letter(:skip), members: "-", conn_status: {}, moodle_id: "", moodle_feedback: "" } else line[:skip] = false line[:id] = format("%<id>02d", {id: c.id.to_i}) line[:letter] = Settings.letter[:cross] if c.grade.zero? line[:letter] = Settings.letter[:error] if c.grade < 50.0 line[:letter] = Settings.letter[:ok] if c.grade.to_i == 100 line[:grade] = c.grade.to_f line[:members] = c.members line[:conn_status] = c.conn_status line[:moodle_id] = c.get(:tt_moodle_id) line[:moodle_feedback] = "\"Filename: #{c.filename}. Date: #{Time.now}\"" end @report.lines << line end end |
#open_main_report(config_filepath) ⇒ Object
Open main report (resume report)
9 10 11 12 13 14 15 16 17 |
# File 'lib/teuton/case_manager/ext/report.rb', line 9 def open_main_report(config_filepath) @report.head[:tt_title] = "Teuton (#{Teuton::VERSION})" @report.head[:tt_scriptname] = trim(Project.value[:script_path]) @report.head[:tt_configfile] = trim(config_filepath) @report.head[:tt_pwd] = Project.value[:running_basedir] @report.head[:tt_debug] = true if Project.value[:debug] @report.head[:tt_uses] = Project.value[:uses].join(", ") @report.head.merge!(Project.value[:global]) end |
#trim(input) ⇒ Object
Trim string text when is too long
63 64 65 66 67 68 69 |
# File 'lib/teuton/case_manager/ext/report.rb', line 63 def trim(input) return input unless input.to_s.start_with? Dir.pwd.to_s return input if input == Dir.pwd.to_s offset = Dir.pwd.length + 1 input[offset, input.size].to_s end |