Class: CaseManager
- Inherits:
-
Object
- Object
- CaseManager
- Includes:
- Singleton, Utils
- Defined in:
- lib/teuton/case_manager/show.rb,
lib/teuton/case_manager/report.rb,
lib/teuton/case_manager/check_cases.rb,
lib/teuton/case_manager/case_manager.rb,
lib/teuton/case_manager/hall_of_fame.rb
Overview
This class does all the job Organize the hole job, sending orders to others classes
-
initialize
-
play
Split into several files:
-
case_manager/check_cases
-
case_manager/export
-
case_manager/hall_of_fame
-
case_manager/report
-
case_manager/show
Instance Method Summary collapse
- #export(args = {}) ⇒ Object
-
#initialize ⇒ CaseManager
constructor
A new instance of CaseManager.
- #play(&block) ⇒ Object
- #preserve_files ⇒ Object
- #send(args = {}) ⇒ Object
- #show(mode = :resume) ⇒ Object
Methods included from Utils
#encode_and_split, #ensure_dir, #my_execute, #verbose, #verboseln
Constructor Details
#initialize ⇒ CaseManager
Returns a new instance of CaseManager.
26 27 28 29 30 |
# File 'lib/teuton/case_manager/case_manager.rb', line 26 def initialize @cases = [] @report = Report.new(0) @report.filename = 'resume' end |
Instance Method Details
#export(args = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/teuton/case_manager/case_manager.rb', line 43 def export(args = {}) if args.class != Hash puts "[ERROR] CaseManager#export: Argument = <#{args}>, " \ "class = #{args.class}" puts ' Usage: export :format => :colored_text' raise '[ERROR] CaseManager#export: Argument error!' end ExportManager.run(@report, @cases, args) preserve_files if args[:preserve] == true end |
#play(&block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/teuton/case_manager/case_manager.rb', line 32 def play(&block) check_cases! instance_eval(&block) # Run export if user pass option command "--export=json" i = Application.instance.['export'] export(format: i.to_sym) unless i.nil? # Accept "configfile" param REVISE There exists? i = Application.instance.['configfile'] export(format: i.to_sym) unless i.nil? end |
#preserve_files ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/teuton/case_manager/case_manager.rb', line 54 def preserve_files app = Application.instance t = Time.now subdir = "#{t.year}#{format('%02d',t.month)}#{format('%02d',t.day)}-" \ "#{format('%02d',t.hour)}#{format('%02d',t.min)}" \ "#{format('%02d',t.sec)}" 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('var/learn-08-preserve/**.*').each do |file| FileUtils.cp(file, logdir) end end |
#send(args = {}) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/teuton/case_manager/case_manager.rb', line 69 def send(args = {}) threads = [] puts '' puts "[INFO] Sending files...#{args.to_s}" @cases.each { |c| threads << Thread.new { c.send(args) } } threads.each(&:join) end |
#show(mode = :resume) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/teuton/case_manager/show.rb', line 6 def show(mode = :resume) return if Application.instance.quiet? @report.show if i[resume all].include? mode return unless i[details all].include? mode @cases.each do |c| puts '____' c.show end puts '.' end |