teuton 2.3.5 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/bin/teuton +1 -1
- data/docs/CHANGELOG.md +8 -0
- data/docs/changelog/v2.4.md +16 -0
- data/docs/dsl/definition/expect.md +11 -7
- data/docs/dsl/definition/result.md +7 -6
- data/docs/dsl/definition/run_local.md +0 -1
- data/docs/dsl/definition/target.md +1 -1
- data/docs/dsl/execution/export.md +14 -16
- data/docs/dsl/execution/send.md +12 -12
- data/docs/dsl/setting/get.md +5 -5
- data/docs/es/exit_code.md +59 -0
- data/docs/es/guess_os.md +28 -0
- data/docs/{Challenge-Server-Project.md → ideas/Challenge-Server-Project.md} +0 -0
- data/docs/{changelog → ideas}/contributions.md +0 -0
- data/docs/{changelog → ideas}/ideas.md +0 -0
- data/docs/{changelog → ideas}/servidor-de-retos.md +0 -0
- data/docs/learn/{example-01-target.md → 01-target.md} +1 -3
- data/docs/learn/{example-02-config.md → 02-config.md} +1 -3
- data/docs/learn/{example-03-remote-hosts.md → 03-remote_hosts.md} +10 -10
- data/docs/learn/{example-04-new-test.md → 04-new_test.md} +8 -16
- data/docs/learn/{example-05-use.md → 05-use.md} +1 -3
- data/docs/learn/{example-06-debug.md → 06-debug.md} +1 -3
- data/docs/learn/{example-07-log.md → 07-log.md} +1 -3
- data/docs/learn/{example-08-readme.md → 08-readme.md} +1 -3
- data/docs/learn/{example-09-preserve.md → 09-preserve.md} +7 -4
- data/docs/learn/10-result.md +36 -0
- data/docs/learn/11-moodle_id.md +19 -0
- data/docs/learn/12-get_vars.md +37 -0
- data/docs/learn/13-include.md +59 -0
- data/docs/learn/16-exit_codes.md +24 -0
- data/docs/learn/README.md +19 -17
- data/lib/teuton/application.rb +24 -17
- data/lib/teuton/case_manager/case/builtin/main.rb +2 -3
- data/lib/teuton/case_manager/case/builtin/package.rb +2 -3
- data/lib/teuton/case_manager/case/builtin/service.rb +4 -5
- data/lib/teuton/case_manager/case/builtin/teuton_file.rb +3 -4
- data/lib/teuton/case_manager/case/builtin/teuton_host.rb +5 -6
- data/lib/teuton/case_manager/case/builtin/user.rb +1 -2
- data/lib/teuton/case_manager/case/case.rb +27 -27
- data/lib/teuton/case_manager/case/close.rb +2 -2
- data/lib/teuton/case_manager/case/config.rb +14 -14
- data/lib/teuton/case_manager/case/dsl/expect.rb +46 -39
- data/lib/teuton/case_manager/case/dsl/goto.rb +2 -2
- data/lib/teuton/case_manager/case/dsl/log.rb +5 -6
- data/lib/teuton/case_manager/case/dsl/macro.rb +11 -7
- data/lib/teuton/case_manager/case/dsl/main.rb +8 -8
- data/lib/teuton/case_manager/case/dsl/send.rb +12 -14
- data/lib/teuton/case_manager/case/dsl/unique.rb +1 -3
- data/lib/teuton/case_manager/case/main.rb +5 -5
- data/lib/teuton/case_manager/case/play.rb +1 -1
- data/lib/teuton/case_manager/case/result/ext_array.rb +9 -9
- data/lib/teuton/case_manager/case/result/ext_compare.rb +44 -58
- data/lib/teuton/case_manager/case/result/ext_filter.rb +20 -8
- data/lib/teuton/case_manager/case/result/result.rb +19 -18
- data/lib/teuton/case_manager/case/runner.rb +53 -60
- data/lib/teuton/case_manager/case_manager.rb +15 -15
- data/lib/teuton/case_manager/check_cases.rb +1 -4
- data/lib/teuton/case_manager/dsl.rb +5 -5
- data/lib/teuton/case_manager/export_manager.rb +8 -19
- data/lib/teuton/case_manager/hall_of_fame.rb +4 -6
- data/lib/teuton/case_manager/main.rb +4 -5
- data/lib/teuton/case_manager/report.rb +21 -16
- data/lib/teuton/case_manager/show.rb +2 -2
- data/lib/teuton/case_manager/utils.rb +13 -14
- data/lib/teuton/check/builtin.rb +5 -1
- data/lib/teuton/check/dsl.rb +10 -11
- data/lib/teuton/check/laboratory.rb +13 -15
- data/lib/teuton/check/show.rb +33 -35
- data/lib/teuton/cli.rb +31 -35
- data/lib/teuton/files/start.rb +3 -6
- data/lib/teuton/readme/dsl.rb +12 -6
- data/lib/teuton/readme/lang.rb +20 -21
- data/lib/teuton/readme/readme.rb +40 -42
- data/lib/teuton/report/close.rb +1 -8
- data/lib/teuton/report/formatter/array_formatter.rb +28 -39
- data/lib/teuton/report/formatter/base_formatter.rb +2 -13
- data/lib/teuton/report/formatter/csv_formatter.rb +12 -18
- data/lib/teuton/report/formatter/formatter_factory.rb +31 -29
- data/lib/teuton/report/formatter/html_formatter.rb +37 -21
- data/lib/teuton/report/formatter/json_formatter.rb +2 -8
- data/lib/teuton/report/formatter/list_formatter.rb +6 -12
- data/lib/teuton/report/formatter/moodle_csv_formatter.rb +3 -6
- data/lib/teuton/report/formatter/resume_array_formatter.rb +1 -1
- data/lib/teuton/report/formatter/resume_html_formatter.rb +29 -19
- data/lib/teuton/report/formatter/resume_json_formatter.rb +2 -3
- data/lib/teuton/report/formatter/resume_list_formatter.rb +4 -4
- data/lib/teuton/report/formatter/resume_txt_formatter.rb +14 -18
- data/lib/teuton/report/formatter/resume_yaml_formatter.rb +1 -9
- data/lib/teuton/report/formatter/txt_formatter.rb +19 -22
- data/lib/teuton/report/formatter/xml_formatter.rb +29 -37
- data/lib/teuton/report/formatter/yaml_formatter.rb +2 -12
- data/lib/teuton/report/report.rb +10 -10
- data/lib/teuton/report/show.rb +14 -33
- data/lib/teuton/skeleton.rb +6 -14
- data/lib/teuton/utils/configfile_reader.rb +22 -21
- data/lib/teuton/utils/name_file_finder.rb +21 -26
- data/lib/teuton/utils/verbose.rb +1 -2
- data/lib/teuton/version.rb +3 -4
- data/lib/teuton.rb +5 -6
- metadata +60 -86
- data/bin/check_teuton +0 -41
@@ -1,20 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "base_formatter"
|
4
4
|
|
5
|
-
##
|
6
|
-
# ArrayFormatter class: format report data into an array
|
7
5
|
class ArrayFormatter < BaseFormatter
|
8
|
-
##
|
9
|
-
# Initialize class
|
10
|
-
# @param report (Report) Format report data into Array
|
11
6
|
def initialize(report)
|
12
7
|
super(report)
|
13
8
|
@data = {}
|
14
9
|
end
|
15
10
|
|
16
|
-
##
|
17
|
-
# Execute format action
|
18
11
|
def process
|
19
12
|
build_data
|
20
13
|
w @data.to_s # Write data into ouput file
|
@@ -34,49 +27,45 @@ class ArrayFormatter < BaseFormatter
|
|
34
27
|
@data[:config] = head
|
35
28
|
end
|
36
29
|
|
37
|
-
# rubocop:disable Metrics/AbcSize
|
38
|
-
# rubocop:disable Metrics/MethodLength
|
39
30
|
def build_history_data
|
40
31
|
@data[:logs] = []
|
41
32
|
groups = []
|
42
33
|
title = nil
|
43
34
|
targets = []
|
44
35
|
@lines.each do |i|
|
45
|
-
|
46
|
-
value = 0.0
|
47
|
-
value = i[:weight] if i[:check]
|
48
|
-
if i[:groupname] != title
|
49
|
-
# Add currentgroup
|
50
|
-
groups << { title: title, targets: targets } unless title.nil?
|
51
|
-
# Create new group
|
52
|
-
title = i[:groupname]
|
53
|
-
targets = []
|
54
|
-
end
|
55
|
-
|
56
|
-
target = {}
|
57
|
-
# target[:target_id] = format('%02d', i[:id])
|
58
|
-
target[:target_id] = format('%<id>02d', id: i[:id])
|
59
|
-
target[:check] = i[:check]
|
60
|
-
target[:score] = value
|
61
|
-
target[:weight] = i[:weight]
|
62
|
-
target[:description] = i[:description]
|
63
|
-
target[:command] = i[:command]
|
64
|
-
target[:conn_type] = i[:conn_type]
|
65
|
-
target[:duration] = i[:duration]
|
66
|
-
target[:alterations] = i[:alterations]
|
67
|
-
target[:expected] = i[:expected]
|
68
|
-
target[:result] = i[:result]
|
69
|
-
targets << target
|
70
|
-
else
|
36
|
+
unless i.instance_of? Hash
|
71
37
|
@data[:logs] << i.to_s # Add log line
|
38
|
+
next
|
39
|
+
end
|
40
|
+
|
41
|
+
value = 0.0
|
42
|
+
value = i[:weight] if i[:check]
|
43
|
+
if i[:groupname] != title
|
44
|
+
# Add currentgroup
|
45
|
+
groups << {title: title, targets: targets} unless title.nil?
|
46
|
+
# Create new group
|
47
|
+
title = i[:groupname]
|
48
|
+
targets = []
|
72
49
|
end
|
50
|
+
|
51
|
+
target = {}
|
52
|
+
target[:target_id] = format("%<id>02d", id: i[:id])
|
53
|
+
target[:check] = i[:check]
|
54
|
+
target[:score] = value
|
55
|
+
target[:weight] = i[:weight]
|
56
|
+
target[:description] = i[:description]
|
57
|
+
target[:command] = i[:command]
|
58
|
+
target[:conn_type] = i[:conn_type]
|
59
|
+
target[:duration] = i[:duration]
|
60
|
+
target[:alterations] = i[:alterations]
|
61
|
+
target[:expected] = i[:expected]
|
62
|
+
target[:result] = i[:result]
|
63
|
+
targets << target
|
73
64
|
end
|
74
65
|
|
75
|
-
groups << {
|
66
|
+
groups << {title: title, targets: targets} unless title.nil?
|
76
67
|
@data[:groups] = groups
|
77
68
|
end
|
78
|
-
# rubocop:enable Metrics/AbcSize
|
79
|
-
# rubocop:enable Metrics/MethodLength
|
80
69
|
|
81
70
|
def build_final_data
|
82
71
|
tail = {}
|
@@ -1,28 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# BaseFormatter class
|
4
3
|
class BaseFormatter
|
5
|
-
##
|
6
|
-
# Initialize class
|
7
|
-
# @param report (Report) Format report data
|
8
4
|
def initialize(report)
|
9
5
|
@head = report.head
|
10
6
|
@lines = report.lines
|
11
7
|
@tail = report.tail
|
12
8
|
end
|
13
9
|
|
14
|
-
##
|
15
|
-
# Execute format action
|
16
10
|
def process
|
17
|
-
raise
|
11
|
+
raise "Empty method!"
|
18
12
|
end
|
19
13
|
|
20
|
-
##
|
21
|
-
# Creates new output file
|
22
|
-
# @param filename (String) Path to output file
|
23
14
|
def init(filename)
|
24
15
|
@filename = filename
|
25
|
-
@file = File.open(@filename,
|
16
|
+
@file = File.open(@filename, "w")
|
26
17
|
end
|
27
18
|
|
28
19
|
##
|
@@ -32,8 +23,6 @@ class BaseFormatter
|
|
32
23
|
@file.write text.to_s
|
33
24
|
end
|
34
25
|
|
35
|
-
##
|
36
|
-
# Close open output file
|
37
26
|
def deinit
|
38
27
|
@file.close
|
39
28
|
end
|
@@ -1,31 +1,25 @@
|
|
1
|
-
|
2
|
-
require_relative 'base_formatter'
|
1
|
+
require_relative "base_formatter"
|
3
2
|
|
4
3
|
class CSVFormatter < BaseFormatter
|
5
|
-
def initialize(report)
|
6
|
-
super(report)
|
7
|
-
end
|
8
|
-
|
9
4
|
def process
|
10
|
-
d =
|
11
|
-
@head.each { |key,value| w "HEAD#{d}#{key}#{d}#{value}\n" }
|
5
|
+
d = ";"
|
6
|
+
@head.each { |key, value| w "HEAD#{d}#{key}#{d}#{value}\n" }
|
12
7
|
@datagroups.each { |item| process_datagroup(item,d) }
|
13
|
-
@tail.each { |key,value| w "TAIL#{d}#{key}#{d}#{value}\n" }
|
8
|
+
@tail.each { |key, value| w "TAIL#{d}#{key}#{d}#{value}\n" }
|
14
9
|
deinit
|
15
10
|
end
|
16
11
|
|
17
|
-
def process_datagroup(
|
12
|
+
def process_datagroup(group, delimiter = ";")
|
18
13
|
d = delimiter
|
19
|
-
a = "DATAGROUP
|
20
|
-
|
21
|
-
|
22
|
-
if i.
|
23
|
-
w a
|
24
|
-
"#{i[:description]}\n"
|
14
|
+
a = "DATAGROUP#{group.order}#{d}"
|
15
|
+
group.head.each { |key, value| w "#{a}HEAD#{d}#{key}#{d}#{value}\n" }
|
16
|
+
group.lines.each do |i|
|
17
|
+
if i.instance_of? Hash
|
18
|
+
w "#{a}LINES#{d}ACTION#{d}#{i[:id]}#{d}#{i[:weight]}#{d}#{i[:description]}\n"
|
25
19
|
else
|
26
|
-
|
20
|
+
w "#{a}LINES#{d}LOG#{d}#{i}\n"
|
27
21
|
end
|
28
22
|
end
|
29
|
-
|
23
|
+
group.tail.each { |key, value| w "#{a}TAIL#{d}#{key}#{d}#{value}\n" }
|
30
24
|
end
|
31
25
|
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
12
|
-
require_relative
|
13
|
-
require_relative
|
14
|
-
require_relative
|
15
|
-
require_relative
|
16
|
-
require_relative
|
3
|
+
require "rainbow"
|
4
|
+
require_relative "json_formatter"
|
5
|
+
require_relative "html_formatter"
|
6
|
+
require_relative "list_formatter"
|
7
|
+
require_relative "txt_formatter"
|
8
|
+
require_relative "yaml_formatter"
|
9
|
+
require_relative "resume_json_formatter"
|
10
|
+
require_relative "resume_html_formatter"
|
11
|
+
require_relative "resume_list_formatter"
|
12
|
+
require_relative "resume_yaml_formatter"
|
13
|
+
require_relative "resume_txt_formatter"
|
14
|
+
require_relative "moodle_csv_formatter"
|
15
|
+
require_relative "csv_formatter"
|
16
|
+
require_relative "xml_formatter"
|
17
17
|
|
18
18
|
# FormaterFactory module
|
19
19
|
module FormatterFactory
|
20
20
|
def self.get(report, format, filename)
|
21
21
|
case format
|
22
22
|
when :colored_text
|
23
|
-
f = TXTFormatter.new(report,true)
|
23
|
+
f = TXTFormatter.new(report, true)
|
24
24
|
when :csv
|
25
25
|
f = CSVFormatter.new(report)
|
26
26
|
when :html
|
@@ -30,7 +30,7 @@ module FormatterFactory
|
|
30
30
|
when :list
|
31
31
|
f = ListFormatter.new(report)
|
32
32
|
when :txt
|
33
|
-
f = TXTFormatter.new(report,false)
|
33
|
+
f = TXTFormatter.new(report, false)
|
34
34
|
when :xml
|
35
35
|
f = XMLFormatter.new(report)
|
36
36
|
when :yaml
|
@@ -57,19 +57,21 @@ module FormatterFactory
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.ext(format)
|
60
|
-
data = {
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
data = {
|
61
|
+
cvs: "csv",
|
62
|
+
colored_text: "txt",
|
63
|
+
json: "json",
|
64
|
+
list: "txt",
|
65
|
+
txt: "txt",
|
66
|
+
yaml: "yaml",
|
67
|
+
resume_colored_text: "txt",
|
68
|
+
resume_csv: "csv",
|
69
|
+
resume_json: "json",
|
70
|
+
resume_html: "html",
|
71
|
+
resume_list: "txt",
|
72
|
+
resume_txt: "txt",
|
73
|
+
resume_yaml: "yaml"
|
74
|
+
}
|
73
75
|
return format.to_s if data[format].nil?
|
74
76
|
|
75
77
|
data[format]
|
@@ -1,15 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require "erb"
|
4
|
+
require_relative "yaml_formatter"
|
5
|
+
require_relative "../../application"
|
6
6
|
|
7
|
-
##
|
8
|
-
# HTMLFormatter class receive a [Report] and generates HAML output.
|
9
7
|
class HTMLFormatter < YAMLFormatter
|
10
|
-
##
|
11
|
-
# Class constructor
|
12
|
-
# @param report [Report] Parent object that contains data to be exported.
|
13
8
|
def initialize(report)
|
14
9
|
super(report)
|
15
10
|
@data = {}
|
@@ -17,25 +12,46 @@ class HTMLFormatter < YAMLFormatter
|
|
17
12
|
@template = File.read(filepath)
|
18
13
|
end
|
19
14
|
|
20
|
-
##
|
21
|
-
# Process data from parent object and export it into YAML format.
|
22
15
|
def process
|
23
16
|
build_data
|
24
17
|
build_page
|
25
18
|
deinit
|
26
19
|
end
|
27
20
|
|
28
|
-
##
|
29
|
-
# Build html case page
|
30
21
|
def build_page
|
31
|
-
config = @data[:config]
|
32
|
-
results = @data[:results]
|
33
|
-
logs = @data[:logs]
|
34
|
-
groups = @data[:groups]
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
# config = @data[:config]
|
23
|
+
# results = @data[:results]
|
24
|
+
# logs = @data[:logs]
|
25
|
+
# groups = @data[:groups]
|
26
|
+
# hall_of_fame = @data[:hall_of_fame]
|
27
|
+
# version = Application::VERSION
|
28
|
+
render = ERB.new(@template)
|
29
|
+
w render.result(binding)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def config
|
35
|
+
@data[:config]
|
36
|
+
end
|
37
|
+
|
38
|
+
def results
|
39
|
+
@data[:results]
|
40
|
+
end
|
41
|
+
|
42
|
+
def logs
|
43
|
+
@data[:logs]
|
44
|
+
end
|
45
|
+
|
46
|
+
def groups
|
47
|
+
@data[:groups]
|
48
|
+
end
|
49
|
+
|
50
|
+
def hall_of_fame
|
51
|
+
@data[:hall_of_fame]
|
52
|
+
end
|
53
|
+
|
54
|
+
def version
|
55
|
+
Application::VERSION
|
40
56
|
end
|
41
57
|
end
|
@@ -1,15 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "json/pure"
|
4
|
+
require_relative "array_formatter"
|
5
5
|
|
6
|
-
# JSONFormatter class
|
7
6
|
class JSONFormatter < ArrayFormatter
|
8
|
-
def initialize(report)
|
9
|
-
super(report)
|
10
|
-
@data = {}
|
11
|
-
end
|
12
|
-
|
13
7
|
def process
|
14
8
|
build_data
|
15
9
|
w @data.to_json # Write data into ouput file
|
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "array_formatter"
|
4
4
|
|
5
|
-
# ListFormatter class
|
6
5
|
class ListFormatter < ArrayFormatter
|
7
|
-
def initialize(report)
|
8
|
-
super(report)
|
9
|
-
@data = {}
|
10
|
-
end
|
11
|
-
|
12
6
|
def process
|
13
7
|
build_data
|
14
8
|
process_config
|
@@ -23,7 +17,7 @@ class ListFormatter < ArrayFormatter
|
|
23
17
|
|
24
18
|
def process_config
|
25
19
|
w "CONFIGURATION\n"
|
26
|
-
@data[:config].sort.each { |key,value| w " * #{key} : #{value}\n" }
|
20
|
+
@data[:config].sort.each { |key, value| w " * #{key} : #{value}\n" }
|
27
21
|
w "\n\n"
|
28
22
|
end
|
29
23
|
|
@@ -43,8 +37,8 @@ class ListFormatter < ArrayFormatter
|
|
43
37
|
|
44
38
|
def process_results
|
45
39
|
w "\nRESULTS\n"
|
46
|
-
@data[:results].each do |key,value|
|
47
|
-
w " * #{key
|
40
|
+
@data[:results].each do |key, value|
|
41
|
+
w " * #{key} : #{value}\n"
|
48
42
|
end
|
49
43
|
end
|
50
44
|
|
@@ -60,10 +54,10 @@ class ListFormatter < ArrayFormatter
|
|
60
54
|
private
|
61
55
|
|
62
56
|
def process_group(group)
|
63
|
-
tab =
|
57
|
+
tab = " "
|
64
58
|
w "- #{group[:title]}\n"
|
65
59
|
group[:targets].each do |i|
|
66
|
-
w tab*2
|
60
|
+
w "#{tab * 2}#{format("%02d", i[:target_id].to_i)}"
|
67
61
|
w " (#{i[:score]}/#{i[:weight]}) "
|
68
62
|
w "#{i[:description]}\n"
|
69
63
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "resume_array_formatter"
|
4
4
|
|
5
|
-
##
|
6
|
-
# Format data to Moodle CSV
|
7
5
|
class MoodleCSVFormatter < ResumeArrayFormatter
|
8
6
|
##
|
9
7
|
# initialize instance
|
@@ -28,10 +26,9 @@ class MoodleCSVFormatter < ResumeArrayFormatter
|
|
28
26
|
w "MoodleID, TeutonGrade, TeutonFeedback\n"
|
29
27
|
@data[:cases].each do |line|
|
30
28
|
moodle_id = line[:moodle_id]
|
31
|
-
moodle_id = line[:moodle_id].split(
|
29
|
+
moodle_id = line[:moodle_id].split(",") if moodle_id.instance_of? String
|
32
30
|
moodle_id.each do |id|
|
33
|
-
w "#{id.strip},#{line[:grade]}
|
34
|
-
"#{line[:moodle_feedback]}\n" unless line[:skip]
|
31
|
+
w "#{id.strip},#{line[:grade]},#{line[:moodle_feedback]}\n" unless line[:skip]
|
35
32
|
end
|
36
33
|
end
|
37
34
|
end
|
@@ -1,39 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require "erb"
|
4
|
+
require_relative "resume_yaml_formatter"
|
5
|
+
require_relative "../../application"
|
6
6
|
|
7
7
|
##
|
8
|
-
# HTMLFormatter class receive a [Report] and generates
|
8
|
+
# HTMLFormatter class receive a [Report] and generates HTML output.
|
9
9
|
class ResumeHTMLFormatter < ResumeYAMLFormatter
|
10
|
-
##
|
11
|
-
# Class constructor
|
12
|
-
# @param report [Report] Parent object that contains data to be exported.
|
13
10
|
def initialize(report)
|
14
11
|
super(report)
|
15
12
|
@data = {}
|
16
|
-
filepath = File.join(File.dirname(__FILE__),
|
13
|
+
filepath = File.join(File.dirname(__FILE__), "..", "..", "files", "template", "resume.html")
|
17
14
|
@template = File.read(filepath)
|
18
15
|
end
|
19
16
|
|
20
|
-
##
|
21
|
-
# Process data from parent object and export it into YAML format.
|
22
17
|
def process
|
23
18
|
build_data
|
24
19
|
build_page
|
25
20
|
deinit
|
26
21
|
end
|
27
22
|
|
28
|
-
##
|
29
|
-
# Build html case page
|
30
23
|
def build_page
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
render = ERB.new(@template)
|
25
|
+
w render.result(binding)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def config
|
31
|
+
@data[:config]
|
32
|
+
end
|
33
|
+
|
34
|
+
def cases
|
35
|
+
@data[:cases]
|
36
|
+
end
|
37
|
+
|
38
|
+
def results
|
39
|
+
@data[:results]
|
40
|
+
end
|
41
|
+
|
42
|
+
def hall_of_fame
|
43
|
+
@data[:hall_of_fame]
|
44
|
+
end
|
45
|
+
|
46
|
+
def version
|
47
|
+
Application::VERSION
|
38
48
|
end
|
39
49
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "resume_array_formatter"
|
4
4
|
|
5
5
|
# ResumeListFormatter class
|
6
6
|
class ResumeListFormatter < ResumeArrayFormatter
|
@@ -23,7 +23,7 @@ class ResumeListFormatter < ResumeArrayFormatter
|
|
23
23
|
|
24
24
|
def process_config
|
25
25
|
w "CONFIGURATION\n"
|
26
|
-
@data[:config].each do |key,value|
|
26
|
+
@data[:config].each do |key, value|
|
27
27
|
w " * #{key}: #{trim(value)}\n"
|
28
28
|
end
|
29
29
|
end
|
@@ -31,7 +31,7 @@ class ResumeListFormatter < ResumeArrayFormatter
|
|
31
31
|
def process_cases
|
32
32
|
w "CASES\n"
|
33
33
|
@data[:cases].each do |line|
|
34
|
-
w " [#{line[:id]}] #{line[:members]} :#{format(
|
34
|
+
w " [#{line[:id]}] #{line[:members]} :#{format("%3d", line[:grade])}\n"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -46,7 +46,7 @@ class ResumeListFormatter < ResumeArrayFormatter
|
|
46
46
|
|
47
47
|
def process_results
|
48
48
|
w "\nRESULTS\n"
|
49
|
-
@data[:results].each do |key,value|
|
49
|
+
@data[:results].each do |key, value|
|
50
50
|
w " * #{key}: #{value}\n"
|
51
51
|
end
|
52
52
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require_relative
|
3
|
+
require "terminal-table"
|
4
|
+
require "rainbow"
|
5
|
+
require_relative "resume_array_formatter"
|
6
6
|
|
7
7
|
# TXTFormatter class
|
8
8
|
class ResumeTXTFormatter < ResumeArrayFormatter
|
@@ -30,7 +30,7 @@ class ResumeTXTFormatter < ResumeArrayFormatter
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def process_config
|
33
|
-
w "#{Rainbow(
|
33
|
+
w "#{Rainbow("CONFIGURATION").bg(:blue)}\n"
|
34
34
|
my_screen_table = Terminal::Table.new do |st|
|
35
35
|
@data[:config].each do |key, value|
|
36
36
|
st.add_row [key.to_s, trim(value)]
|
@@ -39,21 +39,21 @@ class ResumeTXTFormatter < ResumeArrayFormatter
|
|
39
39
|
w "#{my_screen_table}\n\n"
|
40
40
|
end
|
41
41
|
|
42
|
-
# rubocop:disable Metrics/MethodLength
|
43
42
|
def process_cases
|
44
|
-
w "#{Rainbow(
|
43
|
+
w "#{Rainbow("CASES").bg(:blue)}\n"
|
45
44
|
my_screen_table = Terminal::Table.new do |st|
|
46
45
|
st.add_row %w[CASE MEMBERS GRADE STATE]
|
47
46
|
@data[:cases].each do |line|
|
48
|
-
st.add_row [
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
st.add_row [
|
48
|
+
line[:id],
|
49
|
+
line[:members],
|
50
|
+
format(" %<grade>3d", {grade: line[:grade]}),
|
51
|
+
line[:letter]
|
52
|
+
]
|
52
53
|
end
|
53
54
|
end
|
54
55
|
w "#{my_screen_table}\n\n"
|
55
56
|
end
|
56
|
-
# rubocop:enable Metrics/MethodLength
|
57
57
|
|
58
58
|
def process_conn_errors
|
59
59
|
my_screen_table = Terminal::Table.new do |st|
|
@@ -66,11 +66,11 @@ class ResumeTXTFormatter < ResumeArrayFormatter
|
|
66
66
|
end
|
67
67
|
return unless my_screen_table.rows.size > 1
|
68
68
|
|
69
|
-
w "#{Rainbow(
|
69
|
+
w "#{Rainbow("CONN ERRORS").bg(:red)}\n#{my_screen_table}\n"
|
70
70
|
end
|
71
71
|
|
72
72
|
def process_results
|
73
|
-
w "\n#{Rainbow(
|
73
|
+
w "\n#{Rainbow("RESULTS").bg(:blue)}\n"
|
74
74
|
my_screen_table = Terminal::Table.new do |st|
|
75
75
|
@data[:results].each do |key, value|
|
76
76
|
st.add_row [key.to_s, value.to_s]
|
@@ -79,12 +79,10 @@ class ResumeTXTFormatter < ResumeArrayFormatter
|
|
79
79
|
w "#{my_screen_table}\n"
|
80
80
|
end
|
81
81
|
|
82
|
-
# rubocop:disable Metrics/MethodLength
|
83
|
-
# rubocop:disable Metrics/AbcSize
|
84
82
|
def process_hof
|
85
83
|
return if @data[:hall_of_fame].size < 3
|
86
84
|
|
87
|
-
w "\n#{Rainbow(
|
85
|
+
w "\n#{Rainbow("HALL OF FAME").bg(:blue)}\n"
|
88
86
|
my_screen_table = Terminal::Table.new do |st|
|
89
87
|
@data[:hall_of_fame].each do |line|
|
90
88
|
mycolor = :green
|
@@ -100,6 +98,4 @@ class ResumeTXTFormatter < ResumeArrayFormatter
|
|
100
98
|
end
|
101
99
|
w "#{my_screen_table}\n"
|
102
100
|
end
|
103
|
-
# rubocop:enable Metrics/MethodLength
|
104
|
-
# rubocop:enable Metrics/AbcSize
|
105
101
|
end
|
@@ -1,19 +1,11 @@
|
|
1
|
+
require_relative "resume_array_formatter"
|
1
2
|
|
2
|
-
require_relative 'resume_array_formatter'
|
3
|
-
|
4
|
-
##
|
5
|
-
# ResumeHTMLFormatter class
|
6
3
|
class ResumeYAMLFormatter < ResumeArrayFormatter
|
7
|
-
##
|
8
|
-
# Initialize class
|
9
|
-
# @param report (Report)
|
10
4
|
def initialize(report)
|
11
5
|
super(report)
|
12
6
|
@data = {}
|
13
7
|
end
|
14
8
|
|
15
|
-
##
|
16
|
-
# Process resume report
|
17
9
|
def process
|
18
10
|
build_data
|
19
11
|
w @data.to_yaml # Write data into ouput file
|