teuton 2.3.10 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -13
- data/docs/CHANGELOG.md +0 -13
- data/docs/changelog/todo.md +18 -0
- data/docs/changelog/v2.3.md +4 -0
- data/docs/changelog/v2.4.md +6 -2
- data/docs/dsl/execution/export.md +9 -15
- data/docs/dsl/execution/show.md +22 -7
- data/docs/ideas/{ideas.md → todo.md} +8 -16
- data/docs/learn/01-target.md +14 -43
- data/docs/learn/02-config.md +20 -37
- data/docs/learn/03-remote_hosts.md +20 -1
- data/docs/learn/04-new_test.md +4 -4
- data/docs/learn/05-use.md +3 -4
- data/docs/learn/06-debug.md +6 -9
- data/docs/learn/07-log.md +14 -14
- data/docs/learn/08-readme.md +4 -4
- data/docs/learn/13-include.md +13 -6
- data/docs/learn/14-alias.md +14 -8
- data/docs/learn/README.md +7 -7
- data/lib/teuton/case_manager/case/case.rb +1 -5
- data/lib/teuton/case_manager/case/dsl/expect.rb +2 -4
- data/lib/teuton/case_manager/case/dsl/log.rb +1 -2
- data/lib/teuton/case_manager/case/dsl/send.rb +4 -2
- data/lib/teuton/case_manager/case/play.rb +1 -2
- data/lib/teuton/case_manager/case/runner.rb +6 -7
- data/lib/teuton/case_manager/case_manager.rb +15 -11
- data/lib/teuton/case_manager/check_cases.rb +5 -7
- data/lib/teuton/case_manager/dsl.rb +9 -3
- data/lib/teuton/case_manager/export_manager.rb +13 -15
- data/lib/teuton/case_manager/hall_of_fame.rb +20 -16
- data/lib/teuton/case_manager/main.rb +1 -2
- data/lib/teuton/case_manager/report.rb +3 -3
- data/lib/teuton/report/formatter/base_formatter.rb +6 -7
- data/lib/teuton/report/formatter/{array_formatter.rb → default/array.rb} +44 -9
- data/lib/teuton/report/formatter/default/colored_text.rb +7 -0
- data/lib/teuton/report/formatter/default/html.rb +24 -0
- data/lib/teuton/report/formatter/default/json.rb +15 -0
- data/lib/teuton/report/formatter/{txt_formatter.rb → default/txt.rb} +4 -3
- data/lib/teuton/report/formatter/{xml_formatter.rb → default/xml.rb} +10 -4
- data/lib/teuton/report/formatter/default/yaml.rb +15 -0
- data/lib/teuton/report/formatter/formatter.rb +54 -0
- data/lib/teuton/report/formatter/moodle_csv_formatter.rb +4 -10
- data/lib/teuton/report/formatter/{resume_array_formatter.rb → resume/array.rb} +4 -7
- data/lib/teuton/report/formatter/resume/colored_text.rb +7 -0
- data/lib/teuton/report/formatter/{resume_html_formatter.rb → resume/html.rb} +7 -9
- data/lib/teuton/report/formatter/{resume_json_formatter.rb → resume/json.rb} +4 -4
- data/lib/teuton/report/formatter/{resume_txt_formatter.rb → resume/txt.rb} +4 -6
- data/lib/teuton/report/formatter/{resume_yaml_formatter.rb → resume/yaml.rb} +4 -3
- data/lib/teuton/report/report.rb +60 -43
- data/lib/teuton/report/show.rb +38 -24
- data/lib/teuton/version.rb +1 -1
- metadata +33 -34
- data/lib/teuton/case_manager/show.rb +0 -24
- data/lib/teuton/report/close.rb +0 -38
- data/lib/teuton/report/formatter/csv_formatter.rb +0 -25
- data/lib/teuton/report/formatter/formatter_factory.rb +0 -79
- data/lib/teuton/report/formatter/html_formatter.rb +0 -57
- data/lib/teuton/report/formatter/json_formatter.rb +0 -12
- data/lib/teuton/report/formatter/list_formatter.rb +0 -65
- data/lib/teuton/report/formatter/resume_list_formatter.rb +0 -62
- data/lib/teuton/report/formatter/yaml_formatter.rb +0 -15
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require_relative "base_formatter"
|
1
|
+
require_relative "../base_formatter"
|
2
|
+
require_relative "../../../application"
|
4
3
|
|
5
4
|
class ArrayFormatter < BaseFormatter
|
6
5
|
def initialize(report)
|
@@ -8,26 +7,28 @@ class ArrayFormatter < BaseFormatter
|
|
8
7
|
@data = {}
|
9
8
|
end
|
10
9
|
|
11
|
-
def process
|
12
|
-
build_data
|
10
|
+
def process(options = {})
|
11
|
+
build_data(options)
|
13
12
|
w @data.to_s # Write data into ouput file
|
14
13
|
deinit
|
15
14
|
end
|
16
15
|
|
17
|
-
def build_data
|
16
|
+
def build_data(options)
|
18
17
|
build_initial_data
|
19
|
-
build_history_data
|
18
|
+
build_history_data(options)
|
20
19
|
build_final_data
|
21
20
|
build_hof_data
|
22
21
|
end
|
23
22
|
|
23
|
+
private
|
24
|
+
|
24
25
|
def build_initial_data
|
25
26
|
head = {}
|
26
27
|
@head.each { |key, value| head[key] = value }
|
27
28
|
@data[:config] = head
|
28
29
|
end
|
29
30
|
|
30
|
-
def build_history_data
|
31
|
+
def build_history_data(options)
|
31
32
|
@data[:logs] = []
|
32
33
|
groups = []
|
33
34
|
title = nil
|
@@ -54,12 +55,22 @@ class ArrayFormatter < BaseFormatter
|
|
54
55
|
target[:score] = value
|
55
56
|
target[:weight] = i[:weight]
|
56
57
|
target[:description] = i[:description]
|
57
|
-
|
58
|
+
|
58
59
|
target[:conn_type] = i[:conn_type]
|
59
60
|
target[:duration] = i[:duration]
|
61
|
+
|
62
|
+
target[:command] = i[:command]
|
60
63
|
target[:alterations] = i[:alterations]
|
61
64
|
target[:expected] = i[:expected]
|
62
65
|
target[:result] = i[:result]
|
66
|
+
|
67
|
+
if options[:feedback] == false
|
68
|
+
target[:command] = "*" * i[:command].size
|
69
|
+
target[:alterations] = "*" * i[:alterations].size
|
70
|
+
target[:expected] = "*" * i[:expected].size
|
71
|
+
target[:result] = "*" * i[:result].size
|
72
|
+
end
|
73
|
+
|
63
74
|
targets << target
|
64
75
|
end
|
65
76
|
|
@@ -82,4 +93,28 @@ class ArrayFormatter < BaseFormatter
|
|
82
93
|
app.hall_of_fame.each { |line| fame[line[0]] = line[1] }
|
83
94
|
@data[:hall_of_fame] = fame
|
84
95
|
end
|
96
|
+
|
97
|
+
def config
|
98
|
+
@data[:config]
|
99
|
+
end
|
100
|
+
|
101
|
+
def results
|
102
|
+
@data[:results]
|
103
|
+
end
|
104
|
+
|
105
|
+
def logs
|
106
|
+
@data[:logs]
|
107
|
+
end
|
108
|
+
|
109
|
+
def groups
|
110
|
+
@data[:groups]
|
111
|
+
end
|
112
|
+
|
113
|
+
def hall_of_fame
|
114
|
+
@data[:hall_of_fame]
|
115
|
+
end
|
116
|
+
|
117
|
+
def version
|
118
|
+
Application::VERSION
|
119
|
+
end
|
85
120
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "erb"
|
2
|
+
require_relative "yaml"
|
3
|
+
|
4
|
+
class HTMLFormatter < YAMLFormatter
|
5
|
+
def initialize(report)
|
6
|
+
super(report)
|
7
|
+
@ext = "html"
|
8
|
+
@data = {}
|
9
|
+
basedir = File.join(File.dirname(__FILE__), "..", "..", "..")
|
10
|
+
filepath = File.join(basedir, "files", "template", "case.html")
|
11
|
+
@template = File.read(filepath)
|
12
|
+
end
|
13
|
+
|
14
|
+
def process(options = {})
|
15
|
+
build_data(options)
|
16
|
+
build_page
|
17
|
+
deinit
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_page
|
21
|
+
render = ERB.new(@template)
|
22
|
+
w render.result(binding)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "json/pure"
|
2
|
+
require_relative "array"
|
3
|
+
|
4
|
+
class JSONFormatter < ArrayFormatter
|
5
|
+
def initialize(report)
|
6
|
+
super(report)
|
7
|
+
@ext = "json"
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(options = {})
|
11
|
+
build_data(options)
|
12
|
+
w @data.to_json # Write data into ouput file
|
13
|
+
deinit
|
14
|
+
end
|
15
|
+
end
|
@@ -1,19 +1,20 @@
|
|
1
1
|
require "terminal-table"
|
2
2
|
require "rainbow"
|
3
|
-
require_relative "
|
3
|
+
require_relative "array"
|
4
4
|
|
5
5
|
class TXTFormatter < ArrayFormatter
|
6
6
|
def initialize(report, color = false)
|
7
7
|
@color = color
|
8
8
|
super(report)
|
9
|
+
@ext = "txt"
|
9
10
|
@data = {}
|
10
11
|
end
|
11
12
|
|
12
|
-
def process
|
13
|
+
def process(options = {})
|
13
14
|
rainbow_state = Rainbow.enabled
|
14
15
|
Rainbow.enabled = @color
|
15
16
|
|
16
|
-
build_data
|
17
|
+
build_data(options)
|
17
18
|
process_config
|
18
19
|
process_logs
|
19
20
|
process_groups
|
@@ -1,9 +1,15 @@
|
|
1
|
-
require_relative "base_formatter"
|
1
|
+
require_relative "../base_formatter"
|
2
|
+
require_relative "../../../version"
|
2
3
|
|
3
4
|
class XMLFormatter < BaseFormatter
|
4
|
-
def
|
5
|
+
def initialize(report)
|
6
|
+
super(report)
|
7
|
+
@ext = "xml"
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(options = {})
|
5
11
|
tab = " "
|
6
|
-
w "<teuton version='
|
12
|
+
w "<teuton version='#{Teuton::VERSION}'>\n"
|
7
13
|
w "#{tab}<head>\n"
|
8
14
|
@head.each { |key, value| w "#{tab * 2}<#{key}>#{value}</#{key}>\n" }
|
9
15
|
w "#{tab}</head>\n"
|
@@ -22,7 +28,7 @@ class XMLFormatter < BaseFormatter
|
|
22
28
|
w "#{tab * 3}<check>#{i[:check]}</check>\n"
|
23
29
|
w "#{tab * 3}<weigth>#{i[:weight]}</weigth>\n"
|
24
30
|
w "#{tab * 2}</line>\n"
|
25
|
-
|
31
|
+
end
|
26
32
|
w "#{tab}</lines>\n"
|
27
33
|
w "#{tab}<tail>\n"
|
28
34
|
@tail.each { |key, value| w "#{tab * 2}<#{key}>#{value}</#{key}>\n" }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require_relative "array"
|
3
|
+
|
4
|
+
class YAMLFormatter < ArrayFormatter
|
5
|
+
def initialize(report)
|
6
|
+
super(report)
|
7
|
+
@ext = "yaml"
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(options = {})
|
11
|
+
build_data(options)
|
12
|
+
w @data.to_yaml # Write data into ouput file
|
13
|
+
deinit
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "rainbow"
|
2
|
+
require_relative "default/colored_text"
|
3
|
+
require_relative "default/html"
|
4
|
+
require_relative "default/json"
|
5
|
+
require_relative "default/txt"
|
6
|
+
require_relative "default/xml"
|
7
|
+
require_relative "default/yaml"
|
8
|
+
require_relative "resume/colored_text"
|
9
|
+
require_relative "resume/html"
|
10
|
+
require_relative "resume/json"
|
11
|
+
require_relative "resume/txt"
|
12
|
+
require_relative "resume/yaml"
|
13
|
+
require_relative "moodle_csv_formatter"
|
14
|
+
|
15
|
+
module Formatter
|
16
|
+
def self.call(report, options, filename)
|
17
|
+
klass = get(options[:format])
|
18
|
+
if klass.nil?
|
19
|
+
puts Rainbow("[ERROR] Unkown format: #{options[:format]}").red
|
20
|
+
puts Rainbow(" export format: FORMAT").red
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
formatter = klass.new(report)
|
24
|
+
formatter.init(filename)
|
25
|
+
formatter.process(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get(format)
|
29
|
+
list = {
|
30
|
+
colored_text: ColoredTextFormatter,
|
31
|
+
html: HTMLFormatter,
|
32
|
+
json: JSONFormatter,
|
33
|
+
txt: TXTFormatter,
|
34
|
+
xml: XMLFormatter,
|
35
|
+
yaml: YAMLFormatter,
|
36
|
+
moodle_csv: MoodleCSVFormatter,
|
37
|
+
resume_html: ResumeHTMLFormatter,
|
38
|
+
resume_json: ResumeJSONFormatter,
|
39
|
+
resume_txt: ResumeTXTFormatter,
|
40
|
+
resume_xml: ResumeTXTFormatter, # TODO
|
41
|
+
resume_yaml: ResumeYAMLFormatter
|
42
|
+
}
|
43
|
+
list[format]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.hide_feedback(report)
|
47
|
+
report2 = report.clone
|
48
|
+
report2.groups.each do |group|
|
49
|
+
group.each do |item|
|
50
|
+
puts item.to_s
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,20 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require_relative "resume_array_formatter"
|
1
|
+
require_relative "resume/array"
|
4
2
|
|
5
3
|
class MoodleCSVFormatter < ResumeArrayFormatter
|
6
|
-
##
|
7
|
-
# initialize instance
|
8
|
-
# @param report (Report)
|
9
4
|
def initialize(report)
|
10
5
|
super(report)
|
6
|
+
@ext = "csv"
|
11
7
|
@data = {}
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
def process
|
17
|
-
build_data
|
10
|
+
def process(options = {})
|
11
|
+
build_data(options)
|
18
12
|
process_cases
|
19
13
|
deinit
|
20
14
|
end
|
@@ -1,21 +1,18 @@
|
|
1
|
-
|
1
|
+
require_relative "../base_formatter"
|
2
2
|
|
3
|
-
require_relative "base_formatter"
|
4
|
-
|
5
|
-
# ArrayFormatter class: format report data into an array
|
6
3
|
class ResumeArrayFormatter < BaseFormatter
|
7
4
|
def initialize(report)
|
8
5
|
super(report)
|
9
6
|
@data = {}
|
10
7
|
end
|
11
8
|
|
12
|
-
def process
|
13
|
-
build_data
|
9
|
+
def process(options = {})
|
10
|
+
build_data(options)
|
14
11
|
w @data.to_s # Write data into ouput file
|
15
12
|
deinit
|
16
13
|
end
|
17
14
|
|
18
|
-
def build_data
|
15
|
+
def build_data(options)
|
19
16
|
build_initial_data
|
20
17
|
build_cases_data
|
21
18
|
build_final_data
|
@@ -1,21 +1,19 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "erb"
|
4
|
-
require_relative "
|
5
|
-
require_relative "
|
2
|
+
require_relative "yaml"
|
3
|
+
require_relative "../../../application"
|
6
4
|
|
7
|
-
##
|
8
|
-
# HTMLFormatter class receive a [Report] and generates HTML output.
|
9
5
|
class ResumeHTMLFormatter < ResumeYAMLFormatter
|
10
6
|
def initialize(report)
|
11
7
|
super(report)
|
8
|
+
@ext = "html"
|
12
9
|
@data = {}
|
13
|
-
|
10
|
+
basedir = File.join(File.dirname(__FILE__), "..", "..", "..")
|
11
|
+
filepath = File.join(basedir, "files", "template", "resume.html")
|
14
12
|
@template = File.read(filepath)
|
15
13
|
end
|
16
14
|
|
17
|
-
def process
|
18
|
-
build_data
|
15
|
+
def process(options = {})
|
16
|
+
build_data(options)
|
19
17
|
build_page
|
20
18
|
deinit
|
21
19
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require "json/pure"
|
2
|
-
require_relative "
|
2
|
+
require_relative "array"
|
3
3
|
|
4
|
-
# JSONFormatter class
|
5
4
|
class ResumeJSONFormatter < ResumeArrayFormatter
|
6
5
|
def initialize(report)
|
7
6
|
super(report)
|
7
|
+
@ext = "json"
|
8
8
|
@data = {}
|
9
9
|
end
|
10
10
|
|
11
|
-
def process
|
12
|
-
build_data
|
11
|
+
def process(options = {})
|
12
|
+
build_data(options)
|
13
13
|
w @data.to_json # Write data into ouput file
|
14
14
|
deinit
|
15
15
|
end
|
@@ -1,22 +1,20 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "terminal-table"
|
4
2
|
require "rainbow"
|
5
|
-
require_relative "
|
3
|
+
require_relative "array"
|
6
4
|
|
7
|
-
# TXTFormatter class
|
8
5
|
class ResumeTXTFormatter < ResumeArrayFormatter
|
9
6
|
def initialize(report, color = false)
|
10
7
|
@color = color
|
11
8
|
super(report)
|
9
|
+
@ext = "txt"
|
12
10
|
@data = {}
|
13
11
|
end
|
14
12
|
|
15
|
-
def process
|
13
|
+
def process(options = {})
|
16
14
|
rainbow_state = Rainbow.enabled
|
17
15
|
Rainbow.enabled = @color
|
18
16
|
|
19
|
-
build_data
|
17
|
+
build_data(options)
|
20
18
|
process_config
|
21
19
|
process_cases
|
22
20
|
process_conn_errors
|
@@ -1,13 +1,14 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "array"
|
2
2
|
|
3
3
|
class ResumeYAMLFormatter < ResumeArrayFormatter
|
4
4
|
def initialize(report)
|
5
5
|
super(report)
|
6
|
+
@ext = "yaml"
|
6
7
|
@data = {}
|
7
8
|
end
|
8
9
|
|
9
|
-
def process
|
10
|
-
build_data
|
10
|
+
def process(options = {})
|
11
|
+
build_data(options)
|
11
12
|
w @data.to_yaml # Write data into ouput file
|
12
13
|
deinit
|
13
14
|
end
|
data/lib/teuton/report/report.rb
CHANGED
@@ -1,34 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "terminal-table"
|
4
1
|
require_relative "../application"
|
5
|
-
require_relative "formatter/
|
6
|
-
require_relative "show"
|
7
|
-
require_relative "close"
|
2
|
+
require_relative "formatter/formatter"
|
8
3
|
|
9
|
-
##
|
10
|
-
# This class maintain the results of every case, in a structured way.
|
11
|
-
# * report/show.rb
|
12
|
-
# * report/close.rb
|
13
4
|
class Report
|
14
|
-
# @!attribute id
|
15
|
-
# @return [Integer] It is the [Case] number. Zero indicates Resume Report.
|
16
5
|
attr_accessor :id, :filename, :output_dir
|
17
|
-
# @!attribute head
|
18
|
-
# @return [Hash] Report head information.
|
19
6
|
attr_accessor :head
|
20
|
-
# @!attribute lines
|
21
|
-
# @return [Array] Report body information.
|
22
7
|
attr_accessor :lines
|
23
|
-
# @!attribute tail
|
24
|
-
# @return [Hash] Report tail information.
|
25
8
|
attr_accessor :tail
|
26
|
-
|
27
|
-
# @return [Symbol] Indicate export format.
|
28
|
-
attr_reader :format
|
9
|
+
attr_accessor :format
|
29
10
|
attr_reader :history
|
30
|
-
|
31
|
-
# Class constructor
|
11
|
+
|
32
12
|
def initialize(id = "00")
|
33
13
|
@id = id
|
34
14
|
@filename = "case-#{@id}"
|
@@ -42,30 +22,67 @@ class Report
|
|
42
22
|
@history = ""
|
43
23
|
end
|
44
24
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
25
|
+
def clone
|
26
|
+
report = Report.new
|
27
|
+
attrs = %i[id filename output_dir head lines tail format]
|
28
|
+
attrs.each do |attr|
|
29
|
+
attr_set = "#{attr}=".to_sym
|
30
|
+
report.send(attr_set, send(attr).clone)
|
31
|
+
end
|
52
32
|
|
53
|
-
|
54
|
-
formatter.process
|
33
|
+
report
|
55
34
|
end
|
56
35
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
36
|
+
def export(options)
|
37
|
+
filepath = File.join(@output_dir, @filename)
|
38
|
+
Formatter.call(self, options, filepath)
|
39
|
+
end
|
40
|
+
|
41
|
+
def export_resume(options)
|
42
|
+
format = options[:format]
|
61
43
|
@format = "resume_#{format}".to_sym
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
44
|
+
options[:format] = @format
|
45
|
+
filepath = File.join(@output_dir, @filename)
|
46
|
+
Formatter.call(self, options, filepath)
|
47
|
+
|
48
|
+
filepath = File.join(@output_dir, "moodle")
|
49
|
+
Formatter.call(self, {format: :moodle_csv}, filepath)
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Calculate final values:
|
54
|
+
# * grade
|
55
|
+
# * max_weight
|
56
|
+
# * good_weight,d
|
57
|
+
# * fail_weight
|
58
|
+
# * fail_counter
|
59
|
+
def close
|
60
|
+
app = Application.instance
|
61
|
+
max = 0.0
|
62
|
+
good = 0.0
|
63
|
+
fail = 0.0
|
64
|
+
fail_counter = 0
|
65
|
+
@lines.each do |i|
|
66
|
+
next unless i.instance_of? Hash
|
67
|
+
|
68
|
+
max += i[:weight] if i[:weight].positive?
|
69
|
+
if i[:check]
|
70
|
+
good += i[:weight]
|
71
|
+
@history += app.letter[:good]
|
72
|
+
else
|
73
|
+
fail += i[:weight]
|
74
|
+
fail_counter += 1
|
75
|
+
@history += app.letter[:bad]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
@tail[:max_weight] = max
|
79
|
+
@tail[:good_weight] = good
|
80
|
+
@tail[:fail_weight] = fail
|
81
|
+
@tail[:fail_counter] = fail_counter
|
66
82
|
|
67
|
-
|
68
|
-
|
69
|
-
|
83
|
+
i = good.to_f / max
|
84
|
+
i = 0 if i.nan?
|
85
|
+
@tail[:grade] = (100.0 * i).round
|
86
|
+
@tail[:grade] = 0 if @tail[:unique_fault].positive?
|
70
87
|
end
|
71
88
|
end
|
data/lib/teuton/report/show.rb
CHANGED
@@ -1,48 +1,62 @@
|
|
1
|
-
|
1
|
+
require "rainbow"
|
2
|
+
require_relative "../application"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
if
|
4
|
+
class ShowReport
|
5
|
+
def initialize(report)
|
6
|
+
@report = report
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(verbose)
|
10
|
+
return if Application.instance.quiet?
|
11
|
+
|
12
|
+
show_initial_configurations if verbose > 2
|
13
|
+
if filename.to_s.include? "resume"
|
10
14
|
show_resume
|
11
15
|
else
|
12
16
|
show_targets_history
|
13
17
|
end
|
14
|
-
show_final_values
|
15
|
-
show_hall_of_fame
|
18
|
+
show_final_values if verbose > 1
|
19
|
+
show_hall_of_fame if verbose > 0
|
16
20
|
end
|
17
21
|
|
18
22
|
private
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
def filename
|
25
|
+
@report.filename
|
26
|
+
end
|
27
|
+
|
28
|
+
def head
|
29
|
+
@report.head
|
30
|
+
end
|
31
|
+
|
32
|
+
def lines
|
33
|
+
@report.lines
|
34
|
+
end
|
35
|
+
|
36
|
+
def tail
|
37
|
+
@report.tail
|
38
|
+
end
|
39
|
+
|
22
40
|
def show_initial_configurations
|
23
41
|
puts Rainbow("INITIAL CONFIGURATIONS").bright
|
24
42
|
my_screen_table = Terminal::Table.new do |st|
|
25
|
-
|
43
|
+
head.each do |key, value|
|
26
44
|
st.add_row [key.to_s, trim(value)]
|
27
45
|
end
|
28
46
|
end
|
29
47
|
puts "#{my_screen_table}\n\n"
|
30
48
|
end
|
31
49
|
|
32
|
-
##
|
33
|
-
# Display resume
|
34
50
|
def show_resume
|
35
51
|
show_case_list
|
36
52
|
show_conn_status
|
37
53
|
end
|
38
54
|
|
39
|
-
##
|
40
|
-
# Display case list
|
41
55
|
def show_case_list
|
42
56
|
puts Rainbow("CASE RESULTS").bright
|
43
57
|
my_screen_table = Terminal::Table.new do |st|
|
44
58
|
st.add_row %w[CASE MEMBERS GRADE STATE]
|
45
|
-
|
59
|
+
lines.each do |line|
|
46
60
|
st.add_row [line[:id], line[:members], line[:grade], line[:letter]]
|
47
61
|
end
|
48
62
|
end
|
@@ -51,13 +65,13 @@ class Report
|
|
51
65
|
|
52
66
|
def show_conn_status
|
53
67
|
errors = 0
|
54
|
-
|
68
|
+
lines.each { |line| errors += line[:conn_status].size }
|
55
69
|
return if errors.zero?
|
56
70
|
|
57
71
|
puts Rainbow("CONN ERRORS").bright
|
58
72
|
my_screen_table = Terminal::Table.new do |st|
|
59
73
|
st.add_row %w[CASE MEMBERS HOST ERROR]
|
60
|
-
|
74
|
+
lines.each do |line|
|
61
75
|
line[:conn_status].each_pair do |host, error|
|
62
76
|
st.add_row [line[:id], line[:members], host, Rainbow(error).red.bright]
|
63
77
|
end
|
@@ -69,10 +83,10 @@ class Report
|
|
69
83
|
def show_targets_history
|
70
84
|
tab = " "
|
71
85
|
puts Rainbow("CASE RESULTS").bright
|
72
|
-
if
|
73
|
-
puts
|
86
|
+
if lines.size == 1
|
87
|
+
puts lines[0]
|
74
88
|
else
|
75
|
-
|
89
|
+
lines.each do |i|
|
76
90
|
if i.class.to_s == "Hash"
|
77
91
|
value = 0.0
|
78
92
|
value = i[:weight] if i[:check]
|
@@ -91,7 +105,7 @@ class Report
|
|
91
105
|
def show_final_values
|
92
106
|
puts Rainbow("FINAL VALUES").bright
|
93
107
|
my_screen_table = Terminal::Table.new do |st|
|
94
|
-
|
108
|
+
tail.each do |key, value|
|
95
109
|
st.add_row [key.to_s, value.to_s]
|
96
110
|
end
|
97
111
|
end
|
data/lib/teuton/version.rb
CHANGED