teuton 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/teuton +4 -0
- data/lib/teuton/application.rb +53 -0
- data/lib/teuton/case_manager/case/builtin/main.rb +24 -0
- data/lib/teuton/case_manager/case/builtin/package.rb +20 -0
- data/lib/teuton/case_manager/case/builtin/service.rb +32 -0
- data/lib/teuton/case_manager/case/builtin/user.rb +20 -0
- data/lib/teuton/case_manager/case/case.rb +114 -0
- data/lib/teuton/case_manager/case/close.rb +29 -0
- data/lib/teuton/case_manager/case/config.rb +76 -0
- data/lib/teuton/case_manager/case/dsl/check.rb +24 -0
- data/lib/teuton/case_manager/case/dsl/deprecated.rb +14 -0
- data/lib/teuton/case_manager/case/dsl/expect.rb +78 -0
- data/lib/teuton/case_manager/case/dsl/getset.rb +22 -0
- data/lib/teuton/case_manager/case/dsl/goto.rb +35 -0
- data/lib/teuton/case_manager/case/dsl/log.rb +14 -0
- data/lib/teuton/case_manager/case/dsl/main.rb +11 -0
- data/lib/teuton/case_manager/case/dsl/missing.rb +12 -0
- data/lib/teuton/case_manager/case/dsl/send.rb +69 -0
- data/lib/teuton/case_manager/case/dsl/target.rb +16 -0
- data/lib/teuton/case_manager/case/dsl/unique.rb +11 -0
- data/lib/teuton/case_manager/case/main.rb +7 -0
- data/lib/teuton/case_manager/case/play.rb +59 -0
- data/lib/teuton/case_manager/case/result/ext_array.rb +43 -0
- data/lib/teuton/case_manager/case/result/ext_compare.rb +147 -0
- data/lib/teuton/case_manager/case/result/ext_filter.rb +68 -0
- data/lib/teuton/case_manager/case/result/result.rb +73 -0
- data/lib/teuton/case_manager/case/runner.rb +134 -0
- data/lib/teuton/case_manager/case_manager.rb +76 -0
- data/lib/teuton/case_manager/check_cases.rb +73 -0
- data/lib/teuton/case_manager/dsl.rb +31 -0
- data/lib/teuton/case_manager/export_manager.rb +20 -0
- data/lib/teuton/case_manager/hall_of_fame.rb +28 -0
- data/lib/teuton/case_manager/main.rb +6 -0
- data/lib/teuton/case_manager/report.rb +52 -0
- data/lib/teuton/case_manager/show.rb +19 -0
- data/lib/teuton/case_manager/utils.rb +57 -0
- data/lib/teuton/command/create.rb +20 -0
- data/lib/teuton/command/download.rb +26 -0
- data/lib/teuton/command/main.rb +9 -0
- data/lib/teuton/command/play.rb +34 -0
- data/lib/teuton/command/readme.rb +23 -0
- data/lib/teuton/command/test.rb +35 -0
- data/lib/teuton/command/update.rb +27 -0
- data/lib/teuton/command/version.rb +13 -0
- data/lib/teuton/files/start.rb +13 -0
- data/lib/teuton/project/configfile_reader.rb +49 -0
- data/lib/teuton/project/laboratory/builtin.rb +23 -0
- data/lib/teuton/project/laboratory/dsl.rb +117 -0
- data/lib/teuton/project/laboratory/laboratory.rb +55 -0
- data/lib/teuton/project/laboratory/show.rb +161 -0
- data/lib/teuton/project/name_file_finder.rb +129 -0
- data/lib/teuton/project/project.rb +62 -0
- data/lib/teuton/project/project_creator.rb +79 -0
- data/lib/teuton/project/readme/dsl.rb +109 -0
- data/lib/teuton/project/readme/lang.rb +30 -0
- data/lib/teuton/project/readme/readme.rb +156 -0
- data/lib/teuton/rake_function/check.rb +39 -0
- data/lib/teuton/rake_function/install.rb +36 -0
- data/lib/teuton/report/close.rb +34 -0
- data/lib/teuton/report/formatter/array_formatter.rb +84 -0
- data/lib/teuton/report/formatter/base_formatter.rb +33 -0
- data/lib/teuton/report/formatter/csv_formatter.rb +31 -0
- data/lib/teuton/report/formatter/formatter_factory.rb +73 -0
- data/lib/teuton/report/formatter/html_formatter.rb +81 -0
- data/lib/teuton/report/formatter/json_formatter.rb +17 -0
- data/lib/teuton/report/formatter/list_formatter.rb +71 -0
- data/lib/teuton/report/formatter/moodle_csv_formatter.rb +28 -0
- data/lib/teuton/report/formatter/resume_array_formatter.rb +49 -0
- data/lib/teuton/report/formatter/resume_json_formatter.rb +16 -0
- data/lib/teuton/report/formatter/resume_list_formatter.rb +62 -0
- data/lib/teuton/report/formatter/resume_txt_formatter.rb +102 -0
- data/lib/teuton/report/formatter/resume_yaml_formatter.rb +16 -0
- data/lib/teuton/report/formatter/txt_formatter.rb +102 -0
- data/lib/teuton/report/formatter/xml_formatter.rb +42 -0
- data/lib/teuton/report/formatter/yaml_formatter.rb +18 -0
- data/lib/teuton/report/report.rb +55 -0
- data/lib/teuton/report/show.rb +111 -0
- data/lib/teuton/utils/verbose.rb +15 -0
- data/lib/teuton.rb +17 -0
- metadata +263 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_formatter'
|
4
|
+
|
5
|
+
# ArrayFormatter class: format report data into an array
|
6
|
+
class ResumeArrayFormatter < BaseFormatter
|
7
|
+
def initialize(report)
|
8
|
+
super(report)
|
9
|
+
@data = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def process
|
13
|
+
build_data
|
14
|
+
w @data.to_s # Write data into ouput file
|
15
|
+
deinit
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_data
|
19
|
+
build_initial_data
|
20
|
+
build_cases_data
|
21
|
+
build_final_data
|
22
|
+
build_hof_data
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_initial_data
|
26
|
+
head = {}
|
27
|
+
@head.each { |key, value| head[key] = value }
|
28
|
+
@data[:config] = head
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_cases_data
|
32
|
+
@data[:cases] = @lines
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_final_data
|
36
|
+
tail = {}
|
37
|
+
@tail.each { |key, value| tail[key] = value }
|
38
|
+
@data[:results] = tail
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_hof_data
|
42
|
+
app = Application.instance
|
43
|
+
fame = {}
|
44
|
+
if app.options[:case_number] > 2
|
45
|
+
app.hall_of_fame.each { |line| fame[line[0]] = line[1] }
|
46
|
+
end
|
47
|
+
@data[:hall_of_fame] = fame
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
require_relative 'resume_array_formatter'
|
3
|
+
|
4
|
+
# JSONFormatter class
|
5
|
+
class ResumeJSONFormatter < ResumeArrayFormatter
|
6
|
+
def initialize(report)
|
7
|
+
super(report)
|
8
|
+
@data = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def process
|
12
|
+
build_data
|
13
|
+
w @data.to_json # Write data into ouput file
|
14
|
+
deinit
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'resume_array_formatter'
|
4
|
+
|
5
|
+
# ResumeListFormatter class
|
6
|
+
class ResumeListFormatter < ResumeArrayFormatter
|
7
|
+
def initialize(report)
|
8
|
+
super(report)
|
9
|
+
@data = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def process
|
13
|
+
build_data
|
14
|
+
process_config
|
15
|
+
process_cases
|
16
|
+
process_conn_errors
|
17
|
+
process_results
|
18
|
+
process_hof
|
19
|
+
deinit
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def process_config
|
25
|
+
w "CONFIGURATION\n"
|
26
|
+
@data[:config].each do |key,value|
|
27
|
+
w " * #{key}: #{trim(value)}\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def process_cases
|
32
|
+
w "CASES\n"
|
33
|
+
@data[:cases].each do |line|
|
34
|
+
w " [#{line[:id]}] #{line[:members]} :#{format('%3d', line[:grade])}\n"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def process_conn_errors
|
39
|
+
w "CONN ERRORS\n"
|
40
|
+
@data[:cases].each do |line|
|
41
|
+
line[:conn_status].each_pair do |h, e|
|
42
|
+
w " * #{line[:id]} #{line[:members]} #{h} #{e}\n"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def process_results
|
48
|
+
w "\nRESULTS\n"
|
49
|
+
@data[:results].each do |key,value|
|
50
|
+
w " * #{key}: #{value}\n"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def process_hof
|
55
|
+
return if @data[:hall_of_fame].size < 3
|
56
|
+
|
57
|
+
w "\nHALL OF FAME\n"
|
58
|
+
@data[:hall_of_fame].each do |line|
|
59
|
+
w " #{line[0]} : #{line[1]}\n"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'terminal-table'
|
4
|
+
require 'rainbow'
|
5
|
+
require_relative 'resume_array_formatter'
|
6
|
+
|
7
|
+
# TXTFormatter class
|
8
|
+
class ResumeTXTFormatter < ResumeArrayFormatter
|
9
|
+
def initialize(report, color=false)
|
10
|
+
@color = color
|
11
|
+
super(report)
|
12
|
+
@data = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def process
|
16
|
+
rainbow_state = Rainbow.enabled
|
17
|
+
Rainbow.enabled = @color
|
18
|
+
|
19
|
+
build_data
|
20
|
+
process_config
|
21
|
+
process_cases
|
22
|
+
process_conn_errors
|
23
|
+
process_results
|
24
|
+
process_hof
|
25
|
+
deinit
|
26
|
+
|
27
|
+
Rainbow.enabled = rainbow_state
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def process_config
|
33
|
+
w "#{Rainbow("CONFIGURATION").bg(:blue)}\n"
|
34
|
+
my_screen_table = Terminal::Table.new do |st|
|
35
|
+
@data[:config].each do |key,value|
|
36
|
+
st.add_row [ key.to_s, trim(value)]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
w my_screen_table.to_s+"\n\n"
|
40
|
+
end
|
41
|
+
|
42
|
+
def process_cases
|
43
|
+
w "#{Rainbow('CASES').bg(:blue)}\n"
|
44
|
+
|
45
|
+
my_screen_table = Terminal::Table.new do |st|
|
46
|
+
st.add_row [ 'CASE ID', 'MEMBERS', 'GRADE', 'STATE' ]
|
47
|
+
@data[:cases].each do |line|
|
48
|
+
st.add_row [ line[:id],
|
49
|
+
line[:members],
|
50
|
+
format(' %3d', line[:grade]),
|
51
|
+
line[:letter] ]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
w my_screen_table.to_s+"\n\n"
|
55
|
+
end
|
56
|
+
|
57
|
+
def process_conn_errors
|
58
|
+
w "#{Rainbow('CONN ERRORS').bg(:red)}\n"
|
59
|
+
|
60
|
+
my_screen_table = Terminal::Table.new do |st|
|
61
|
+
st.add_row [ 'CASE ID', 'MEMBERS', 'HOST', 'ERROR' ]
|
62
|
+
@data[:cases].each do |line|
|
63
|
+
line[:conn_status].each_pair do |h, e|
|
64
|
+
st.add_row [ line[:id],
|
65
|
+
line[:members],
|
66
|
+
h, e ]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
w my_screen_table.to_s+"\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
def process_results
|
74
|
+
w "\n#{Rainbow("RESULTS").bg(:blue)}\n"
|
75
|
+
my_screen_table = Terminal::Table.new do |st|
|
76
|
+
@data[:results].each do |key,value|
|
77
|
+
st.add_row [ key.to_s, value.to_s]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
w my_screen_table.to_s+"\n"
|
81
|
+
end
|
82
|
+
|
83
|
+
def process_hof
|
84
|
+
return if @data[:hall_of_fame].size < 3
|
85
|
+
|
86
|
+
w "\n#{Rainbow("HALL OF FAME").bg(:blue)}\n"
|
87
|
+
my_screen_table = Terminal::Table.new do |st|
|
88
|
+
@data[:hall_of_fame].each do |line|
|
89
|
+
mycolor = :green
|
90
|
+
mycolor = :red if line[0] < 50
|
91
|
+
text1 = Rainbow(line[0]).color(mycolor)
|
92
|
+
text2 = Rainbow(line[1]).color(mycolor)
|
93
|
+
if line[0] == @data[:results][:grade]
|
94
|
+
text1 = text1.bright
|
95
|
+
text2 = text2.bright
|
96
|
+
end
|
97
|
+
st.add_row [text1, text2]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
w my_screen_table.to_s + "\n"
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
require_relative 'resume_array_formatter'
|
3
|
+
|
4
|
+
# JSONFormatter class
|
5
|
+
class ResumeYAMLFormatter < ResumeArrayFormatter
|
6
|
+
def initialize(report)
|
7
|
+
super(report)
|
8
|
+
@data = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def process
|
12
|
+
build_data
|
13
|
+
w @data.to_yaml # Write data into ouput file
|
14
|
+
deinit
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'terminal-table'
|
4
|
+
require 'rainbow'
|
5
|
+
require_relative 'array_formatter'
|
6
|
+
|
7
|
+
# TXTFormatter class
|
8
|
+
class TXTFormatter < ArrayFormatter
|
9
|
+
def initialize(report, color=false)
|
10
|
+
@color = color
|
11
|
+
super(report)
|
12
|
+
@data = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def process
|
16
|
+
rainbow_state = Rainbow.enabled
|
17
|
+
Rainbow.enabled = @color
|
18
|
+
|
19
|
+
build_data
|
20
|
+
process_config
|
21
|
+
process_logs
|
22
|
+
process_groups
|
23
|
+
process_results
|
24
|
+
process_hof
|
25
|
+
deinit
|
26
|
+
|
27
|
+
Rainbow.enabled = rainbow_state
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def process_config
|
33
|
+
w "#{Rainbow("CONFIGURATION").bg(:blue)}\n"
|
34
|
+
my_screen_table = Terminal::Table.new do |st|
|
35
|
+
@data[:config].sort.each { |key,value| st.add_row [ key.to_s, value.to_s] }
|
36
|
+
end
|
37
|
+
w my_screen_table.to_s+"\n\n"
|
38
|
+
end
|
39
|
+
|
40
|
+
def process_logs
|
41
|
+
return if @data[:logs].size == 0
|
42
|
+
|
43
|
+
w "#{Rainbow("LOGS").bg(:blue)}\n"
|
44
|
+
@data[:logs].each { |line| w " #{line}\n" }
|
45
|
+
end
|
46
|
+
|
47
|
+
def process_groups
|
48
|
+
return if @data[:groups].size == 0
|
49
|
+
|
50
|
+
w "\n#{Rainbow("GROUPS").bg(:blue)}\n"
|
51
|
+
@data[:groups].each { |g| process_group g }
|
52
|
+
end
|
53
|
+
|
54
|
+
def process_results
|
55
|
+
w "\n#{Rainbow("RESULTS").bg(:blue)}\n"
|
56
|
+
my_screen_table = Terminal::Table.new do |st|
|
57
|
+
@data[:results].each do |key,value|
|
58
|
+
st.add_row [ key.to_s, value.to_s]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
w my_screen_table.to_s+"\n"
|
62
|
+
end
|
63
|
+
|
64
|
+
def process_hof
|
65
|
+
return if @data[:hall_of_fame].size < 3
|
66
|
+
|
67
|
+
w "\n#{Rainbow("HALL OF FAME").bg(:blue)}\n"
|
68
|
+
my_screen_table = Terminal::Table.new do |st|
|
69
|
+
@data[:hall_of_fame].each do |line|
|
70
|
+
mycolor = :green
|
71
|
+
mycolor = :red if line[0] < 50
|
72
|
+
text1 = Rainbow(line[0]).color(mycolor)
|
73
|
+
text2 = Rainbow(line[1]).color(mycolor)
|
74
|
+
if line[0] == @data[:results][:grade]
|
75
|
+
text1 = text1.bright
|
76
|
+
text2 = text2.bright
|
77
|
+
end
|
78
|
+
st.add_row [text1, text2]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
w my_screen_table.to_s + "\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def process_group(group)
|
87
|
+
tab = ' '
|
88
|
+
w "- #{Rainbow(group[:title]).blue.bright}\n"
|
89
|
+
group[:targets].each do |i|
|
90
|
+
color = :red
|
91
|
+
color = :green if i[:check]
|
92
|
+
w tab*2 + format("%02d", i[:target_id].to_i)
|
93
|
+
w " (#{Rainbow(i[:score].to_s+"/"+i[:weight].to_s).color(color)})\n"
|
94
|
+
w tab*4+"Description : #{i[:description].to_s}\n"
|
95
|
+
w tab*4+"Command : #{i[:command].to_s}\n"
|
96
|
+
w tab*4+"Duration : #{i[:duration].to_s} (#{i[:conn_type].to_s})\n"
|
97
|
+
w tab*4+"Alterations : #{i[:alterations].to_s}\n"
|
98
|
+
w tab*4+"Expected : #{i[:expected].to_s} (#{i[:expected].class.to_s})\n"
|
99
|
+
w tab*4+"Result : #{i[:result].to_s} (#{i[:result].class.to_s})\n"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
require_relative 'base_formatter'
|
3
|
+
|
4
|
+
class XMLFormatter < BaseFormatter
|
5
|
+
|
6
|
+
def initialize(pReport)
|
7
|
+
super(pReport)
|
8
|
+
end
|
9
|
+
|
10
|
+
def process
|
11
|
+
tab=" "
|
12
|
+
w "<tt-checker version='0.2'>\n"
|
13
|
+
w tab+"<head>\n"
|
14
|
+
@head.each { |key,value| w tab*2+"<"+key.to_s+">"+value.to_s+"</"+key.to_s+">\n" }
|
15
|
+
w tab+"</head>\n"
|
16
|
+
|
17
|
+
w tab+"<lines>\n"
|
18
|
+
@lines.each do |i|
|
19
|
+
if i.class.to_s=='Hash' then
|
20
|
+
w tab*2+"<line>\n"
|
21
|
+
w tab*3+"<id>"+i[:id].to_s+"</id>\n"
|
22
|
+
w tab*3+"<description>"+i[:description].to_s+"</description>\n"
|
23
|
+
w tab*3+"<command"
|
24
|
+
w " tempfile='"+i[:tempfile]+"'" if i[:tempfile]
|
25
|
+
w ">"+i[:command].to_s+"</command>\n"
|
26
|
+
w tab*3+"<check>"+i[:check].to_s+"</check>\n"
|
27
|
+
w tab*3+"<weigth>"+i[:weight].to_s+"</weigth>\n"
|
28
|
+
w tab*2+"</line>\n"
|
29
|
+
else
|
30
|
+
w tab*2+"<line type='log'>"+i.to_s+"</line>\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
w tab+"</lines>\n"
|
34
|
+
|
35
|
+
w tab+"<tail>\n"
|
36
|
+
@tail.each { |key,value| w tab*2+"<"+key.to_s+">"+value.to_s+"</"+key.to_s+">\n" }
|
37
|
+
w tab+"</tail>\n"
|
38
|
+
w "</tt-checker>\n"
|
39
|
+
|
40
|
+
deinit
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require_relative 'array_formatter'
|
5
|
+
|
6
|
+
# YAMLFormatter class
|
7
|
+
class YAMLFormatter < ArrayFormatter
|
8
|
+
def initialize(report)
|
9
|
+
super(report)
|
10
|
+
@data = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def process
|
14
|
+
build_data
|
15
|
+
w @data.to_yaml # Write data into ouput file
|
16
|
+
deinit
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
require 'terminal-table'
|
3
|
+
require_relative '../application'
|
4
|
+
require_relative 'formatter/formatter_factory'
|
5
|
+
require_relative 'show'
|
6
|
+
require_relative 'close'
|
7
|
+
|
8
|
+
=begin
|
9
|
+
This class maintain the results of every case, in a structured way.
|
10
|
+
* report/show.rb
|
11
|
+
* report/close.rb
|
12
|
+
=end
|
13
|
+
|
14
|
+
class Report
|
15
|
+
attr_accessor :id, :filename, :output_dir
|
16
|
+
attr_accessor :head, :lines, :tail
|
17
|
+
attr_reader :history
|
18
|
+
attr_reader :format
|
19
|
+
|
20
|
+
def initialize(id=0)
|
21
|
+
@id = id
|
22
|
+
number = '0' + @id.to_s
|
23
|
+
number = @id.to_s if @id > 9
|
24
|
+
@filename = "case-#{number}"
|
25
|
+
@output_dir = Application.instance.output_basedir
|
26
|
+
@head = {}
|
27
|
+
@lines = []
|
28
|
+
@tail = {}
|
29
|
+
# @history save 1 letter for every target.
|
30
|
+
# For example: "..F." means: good, good, fail and good
|
31
|
+
# I will use this in the future stats manager.
|
32
|
+
@history = ''
|
33
|
+
end
|
34
|
+
|
35
|
+
def export(format = :txt)
|
36
|
+
@format = format
|
37
|
+
filepath = File.join(@output_dir, @filename + '.' \
|
38
|
+
+ FormatterFactory.ext(@format))
|
39
|
+
|
40
|
+
formatter = FormatterFactory.get(self, @format, filepath)
|
41
|
+
formatter.process
|
42
|
+
end
|
43
|
+
|
44
|
+
def export_resume(format = :txt)
|
45
|
+
@format = "resume_#{format.to_s}".to_sym
|
46
|
+
filepath = File.join(@output_dir, @filename + '.' \
|
47
|
+
+ FormatterFactory.ext(@format))
|
48
|
+
formatter = FormatterFactory.get(self, @format, filepath)
|
49
|
+
formatter.process
|
50
|
+
|
51
|
+
filepath = File.join(@output_dir, 'moodle.csv')
|
52
|
+
formatter = FormatterFactory.get(self, :moodle_csv, filepath)
|
53
|
+
formatter.process
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Show methods for Report class.
|
4
|
+
class Report
|
5
|
+
def show
|
6
|
+
show_initial_configurations
|
7
|
+
if @filename.to_s.include? 'resume'
|
8
|
+
show_resume
|
9
|
+
else
|
10
|
+
show_targets_history
|
11
|
+
end
|
12
|
+
show_final_values
|
13
|
+
show_hall_of_fame
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def show_initial_configurations
|
19
|
+
puts 'INITIAL CONFIGURATIONS'
|
20
|
+
my_screen_table = Terminal::Table.new do |st|
|
21
|
+
@head.each do |key, value|
|
22
|
+
st.add_row [key.to_s, trim(value)]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
puts my_screen_table.to_s + "\n\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_resume
|
29
|
+
show_case_list
|
30
|
+
show_conn_status
|
31
|
+
end
|
32
|
+
|
33
|
+
def show_case_list
|
34
|
+
puts 'CASE RESULTS'
|
35
|
+
my_screen_table = Terminal::Table.new do |st|
|
36
|
+
st.add_row ['CASE ID', 'MEMBERS', 'GRADE', 'STATE' ]
|
37
|
+
@lines.each do |line|
|
38
|
+
st.add_row [line[:id], line[:members], line[:grade], line[:letter]]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
puts my_screen_table.to_s + "\n\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def show_conn_status
|
45
|
+
e = 0
|
46
|
+
@lines.each { |line| e += line[:conn_status].size }
|
47
|
+
return if e == 0
|
48
|
+
|
49
|
+
puts 'CONN ERRORS'
|
50
|
+
my_screen_table = Terminal::Table.new do |st|
|
51
|
+
st.add_row ['CASE ID', 'MEMBERS', 'HOST', 'ERROR']
|
52
|
+
@lines.each do |line|
|
53
|
+
line[:conn_status].each_pair do |h,e|
|
54
|
+
st.add_row [line[:id], line[:members], h, e]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
puts my_screen_table.to_s + "\n\n"
|
59
|
+
end
|
60
|
+
|
61
|
+
def show_targets_history
|
62
|
+
tab = ' '
|
63
|
+
puts 'CASE RESULTS'
|
64
|
+
if @lines.size == 1
|
65
|
+
puts @lines[0]
|
66
|
+
else
|
67
|
+
@lines.each do |i|
|
68
|
+
if i.class.to_s == 'Hash'
|
69
|
+
value = 0.0
|
70
|
+
value = i[:weight] if i[:check]
|
71
|
+
print tab + "%03d" % i[:id].to_i
|
72
|
+
print ' (' + '%2d.2f' % value.to_f + '/'
|
73
|
+
puts '%2d.2f' % i[:weight].to_f + ') ' + i[:description].to_s
|
74
|
+
else
|
75
|
+
puts tab + '- ' + i.to_s
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
puts "\n\n"
|
80
|
+
end
|
81
|
+
|
82
|
+
def show_final_values
|
83
|
+
puts 'FINAL VALUES'
|
84
|
+
my_screen_table = Terminal::Table.new do |st|
|
85
|
+
@tail.each do |key, value|
|
86
|
+
st.add_row [key.to_s, value.to_s]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
puts my_screen_table.to_s + "\n\n"
|
90
|
+
end
|
91
|
+
|
92
|
+
def show_hall_of_fame
|
93
|
+
app = Application.instance
|
94
|
+
return if app.hall_of_fame.size < 3
|
95
|
+
|
96
|
+
puts 'HALL OF FAME'
|
97
|
+
my_screen_table = Terminal::Table.new do |st|
|
98
|
+
app.hall_of_fame.each do |line|
|
99
|
+
st.add_row [line[0], line[1]]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
puts my_screen_table.to_s + "\n"
|
103
|
+
end
|
104
|
+
|
105
|
+
def trim(input)
|
106
|
+
output = input.to_s
|
107
|
+
return output if output.size<65
|
108
|
+
output = "...#{input[input.size-50, input.size]}"
|
109
|
+
output.to_s
|
110
|
+
end
|
111
|
+
end
|
data/lib/teuton.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'teuton/application'
|
3
|
+
require_relative 'teuton/project/project'
|
4
|
+
require_relative 'teuton/command/main'
|
5
|
+
|
6
|
+
# Command Line User Interface
|
7
|
+
class Teuton < Thor
|
8
|
+
map ['h', '-h', '--help'] => 'help'
|
9
|
+
|
10
|
+
def method_missing(method, *_args, &_block)
|
11
|
+
play(method.to_s)
|
12
|
+
end
|
13
|
+
|
14
|
+
def respond_to_missing?(method_name, include_private = false)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|