teuton 2.10.3 → 2.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa58869fb42732747d96bdf6cde59ce934c4d743532a64d67cac23c118829ffd
4
- data.tar.gz: c6c40a6dec9484c83958f61f0909f5d4eceac3930e4eac0287803ea5c7361a49
3
+ metadata.gz: f8472b4070402de45b81b61cf0462f1b031b9920d16c0ede38b65cdc5c37a1d7
4
+ data.tar.gz: b42822a9e3e9b62232164545837cc70bd24ceb7f0344965cf9867cc4dfdbafb7
5
5
  SHA512:
6
- metadata.gz: 9f4f778f1a56e3aedddb2039f853397814d108931745f9d114209fa30522e4c4093c2ecc39c25219ef10927d8b2d19b2ca0668a7bede5620f9d5e4ba683d83ac
7
- data.tar.gz: adf9b7229d08109b18ff3576237e66f94d45b0574aab08e4c18bb17c8a9e2c69d8f34e84ae3c08a1885bb4627727870c2c93158d5ace9abd11cf134735f03a31
6
+ metadata.gz: d8403fef53179bee22c195be35e936e5b10096523d2360dec333aa68ee3f2f497ba82d83e6d76dc46d62e0919680926bfa3018afae8f6f9facda91de1acce335
7
+ data.tar.gz: a4557600f54516959f97b5c819ed7f4e3ddaa2c63936e50c5088dbc0c6138c549b10f75a66e79b8d47dc5cff42f0eb74fcb43122a6de1c92b8aed9f3b472efb9
data/README.md CHANGED
@@ -21,8 +21,6 @@ Install Ruby and then:
21
21
  gem install teuton
22
22
  ```
23
23
 
24
- > Install Teuton as normal user: `gem install --user-install teuton`
25
-
26
24
  # Usage
27
25
 
28
26
  Use `teuton run TESTPATH` command to run test:
@@ -8,6 +8,11 @@ We call a device with Teuton installed as t-node. [T-NODE](t-node.md) host monit
8
8
  1. Install Ruby on your system.
9
9
  2. `gem install teuton`
10
10
 
11
+ > If you are using ed25519 for the SSH server, then you may need:
12
+ > * `gem install ed25519 -v 1.2`
13
+ > * `gem install bcrypt_pbkdf -v 1.0`
14
+ > This gems requires install `ruby-devel` OS package.
15
+
11
16
  **SSH server installation**
12
17
 
13
18
  We call e device with SSH/Telnet service as s-node. [S-NODE](s-node.md) hosts are monitorized by T-NODE host.
@@ -1,6 +1,5 @@
1
1
  class ExpectSequence
2
- attr_reader :result
3
- attr_reader :states
2
+ attr_reader :result, :states
4
3
 
5
4
  def initialize(lines)
6
5
  @lines = lines
@@ -38,9 +37,9 @@ class ExpectSequence
38
37
 
39
38
  def find_best_state
40
39
  @states.each do |state|
41
- state[:score] = state[:steps].select { it }.size
42
- state[:fails] = state[:steps].select { !it }.size
43
- state[:ok] = (state[:fails] == 0)
40
+ state[:score] = state[:steps].count { _1 }
41
+ state[:fails] = state[:steps].count { !it }
42
+ state[:ok] = state[:fails].zero?
44
43
  end
45
44
  best = @states[0]
46
45
  @states.each { |state| best = state if state[:score] > best[:score] }
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "rainbow"
4
4
  require_relative "../utils/project"
5
+ require_relative "../report/formatter/formatter"
5
6
 
6
7
  ##
7
8
  # Execute "export" order: Export every case report
@@ -14,25 +15,35 @@ class ExportManager
14
15
  # @param input (Hash) Selected export options
15
16
  def call(main_report, cases, args, default_format)
16
17
  if args.class != Hash
17
- puts Rainbow("[ERROR] Export argument error!").red
18
+ puts Rainbow("[ERROR] ExportManager:").red
19
+ puts Rainbow(" Export argument error!").red
18
20
  puts Rainbow(" Revise: export #{args}").red
19
21
  puts Rainbow(" Use : export format: 'txt'").red
20
22
  puts ""
21
23
  exit 1
22
24
  end
23
25
 
26
+ # Step 1: Validate options
24
27
  options = strings2symbols(args)
25
28
  options[:format] = default_format if options[:format].nil?
26
29
 
27
- # Step 1: Export case reports
30
+ unless Formatter.available_formats.include? options[:format]
31
+ puts Rainbow("[WARN] ExportManager:").yellow.bright
32
+ puts Rainbow(" Unkown format <#{options[:format]}>. Fix line <export format: FORMAT>.").yellow.bright
33
+ puts Rainbow(" Available formats: #{Formatter.available_formats.join(",")}.").yellow.bright
34
+ puts Rainbow("[INFO] Using default format <txt>.").yellow.bright
35
+ options[:format] = :txt
36
+ end
37
+
38
+ # Step 2: Export case reports
28
39
  threads = []
29
40
  cases.each { |c| threads << Thread.new { c.export(options) } }
30
41
  threads.each(&:join)
31
42
 
32
- # Step 2: Export resume report
43
+ # Step 3: Export resume report
33
44
  main_report.export_resume(options)
34
45
 
35
- # Step 3: Preserve files if required
46
+ # Step 4: Preserve files if required
36
47
  preserve_files if options[:preserve] == true
37
48
  end
38
49
 
@@ -11,22 +11,20 @@ class SendManager
11
11
  # @param args (Hash) Send options
12
12
  def call(cases, args)
13
13
  threads = []
14
- puts ""
15
- write("-" * 70, :green)
16
- write("Started at #{Time.new}", :green)
17
- write("Sending reports to reachable hosts. Options=#{args}", :green)
14
+ puts Rainbow("SEND REPORTS").bright
15
+ write("-" * 70)
16
+ write("Started at #{Time.new}")
18
17
 
19
18
  cases.each { |c| threads << Thread.new { c.send(@logfile, args) } }
20
19
  threads.each(&:join)
21
20
 
22
- write("Finished!", :green)
21
+ write("Finished!")
23
22
  puts "-" * 70
24
23
  end
25
24
 
26
25
  private
27
26
 
28
- def write(msg, color)
29
- # puts Rainbow(msg).color(color)
27
+ def write(msg)
30
28
  puts msg
31
29
  @logfile.write "#{msg}\n"
32
30
  @logfile.flush
@@ -98,10 +98,10 @@ class ShowReport
98
98
  if i.instance_of?(::Hash)
99
99
  value = 0.0
100
100
  value = i[:weight] if i[:check]
101
- print tab + "%03d" % i[:id].to_i
102
- print " (%2.1f" % value.to_f
103
- print "/%2.1f" % i[:weight].to_f
104
- puts ") %s" % i[:description].to_s
101
+ print tab + format("%03d", i[:id].to_i)
102
+ print format(" (%2.1f", value.to_f)
103
+ print format("/%2.1f", i[:weight].to_f)
104
+ puts format(") %s", i[:description].to_s)
105
105
  else
106
106
  puts "#{tab}=> #{i}"
107
107
  end
@@ -130,7 +130,7 @@ class ShowReport
130
130
  st.add_row [line[0], line[1]]
131
131
  end
132
132
  end
133
- puts "#{my_screen_table}\n"
133
+ puts "#{my_screen_table}\n\n"
134
134
  end
135
135
 
136
136
  def trim(input)
@@ -2,6 +2,8 @@ require_relative "../base_formatter"
2
2
  require_relative "../../../utils/project"
3
3
 
4
4
  class ArrayFormatter < BaseFormatter
5
+ MIN_HALL_OF_FAME = 3
6
+
5
7
  def initialize(report)
6
8
  super
7
9
  @data = {}
@@ -89,7 +91,7 @@ class ArrayFormatter < BaseFormatter
89
91
 
90
92
  def build_hof_data
91
93
  @data[:hall_of_fame] = {}
92
- return if Project.value[:options][:case_number] < 3
94
+ return if Project.value[:options][:case_number] < MIN_HALL_OF_FAME
93
95
 
94
96
  fame = {}
95
97
  Project.value[:hall_of_fame].each { |line| fame[line[0]] = line[1] }
@@ -112,7 +112,7 @@ class TXTFormatter < ArrayFormatter
112
112
  when :red
113
113
  Rainbow(text).color(:red)
114
114
  else
115
- puts option
115
+ puts "[ERROR] TXTFormatter#colorize option=#{option}"
116
116
  exit 1
117
117
  end
118
118
  end
@@ -13,11 +13,32 @@ require_relative "resume/yaml"
13
13
  require_relative "moodle_csv_formatter"
14
14
 
15
15
  module Formatter
16
+ LIST = {
17
+ colored_text: ColoredTextFormatter,
18
+ html: HTMLFormatter,
19
+ json: JSONFormatter,
20
+ txt: TXTFormatter,
21
+ xml: XMLFormatter,
22
+ yaml: YAMLFormatter,
23
+ moodle_csv: MoodleCSVFormatter,
24
+ resume_colored_text: ResumeColoredTextFormatter,
25
+ resume_html: ResumeHTMLFormatter,
26
+ resume_json: ResumeJSONFormatter,
27
+ resume_txt: ResumeTXTFormatter,
28
+ resume_xml: ResumeTXTFormatter, # TODO
29
+ resume_yaml: ResumeYAMLFormatter
30
+ }
31
+
32
+ def self.available_formats
33
+ LIST.keys.take(6)
34
+ end
35
+
16
36
  def self.call(report, options, filename)
17
37
  klass = get(options[:format])
18
38
  if klass.nil?
19
- puts "[ERROR] Unkown format <#{options[:format]}>. Fix line <export format: FORMAT>"
20
- puts " Available format values: colored_text, html, json, txt, or yaml"
39
+ puts "[ERROR] Formatter:"
40
+ puts " Unkown format <#{options[:format]}>. Fix line <export format: FORMAT>"
41
+ puts " Available formats: #{Formatter.available_formats.join(",")}."
21
42
  exit 1
22
43
  end
23
44
  formatter = klass.new(report)
@@ -27,30 +48,15 @@ module Formatter
27
48
  end
28
49
 
29
50
  def self.get(format)
30
- list = {
31
- colored_text: ColoredTextFormatter,
32
- html: HTMLFormatter,
33
- json: JSONFormatter,
34
- txt: TXTFormatter,
35
- xml: XMLFormatter,
36
- yaml: YAMLFormatter,
37
- moodle_csv: MoodleCSVFormatter,
38
- resume_colored_text: ResumeColoredTextFormatter,
39
- resume_html: ResumeHTMLFormatter,
40
- resume_json: ResumeJSONFormatter,
41
- resume_txt: ResumeTXTFormatter,
42
- resume_xml: ResumeTXTFormatter, # TODO
43
- resume_yaml: ResumeYAMLFormatter
44
- }
45
- list[format]
51
+ LIST[format]
46
52
  end
47
53
 
48
- def self.hide_feedback(report)
49
- report2 = report.clone
50
- report2.groups.each do |group|
51
- group.each do |item|
52
- puts item
53
- end
54
- end
55
- end
54
+ # def self.hide_feedback(report)
55
+ # report2 = report.clone
56
+ # report2.groups.each do |group|
57
+ # group.each do |item|
58
+ # puts item
59
+ # end
60
+ # end
61
+ # end
56
62
  end
@@ -3,17 +3,16 @@ require "rainbow"
3
3
  require_relative "array"
4
4
 
5
5
  class ResumeTXTFormatter < ResumeArrayFormatter
6
- def initialize(report, color = false)
7
- @color = color
6
+ MIN_HALL_OF_FAME = 3
7
+
8
+ def initialize(report, colorize = false)
9
+ @colorize = colorize
8
10
  super(report)
9
11
  @ext = "txt"
10
12
  @data = {}
11
13
  end
12
14
 
13
15
  def process(options = {})
14
- rainbow_state = Rainbow.enabled
15
- Rainbow.enabled = @color
16
-
17
16
  build_data(options)
18
17
  process_config
19
18
  process_cases
@@ -21,14 +20,12 @@ class ResumeTXTFormatter < ResumeArrayFormatter
21
20
  process_results
22
21
  process_hof
23
22
  deinit
24
-
25
- Rainbow.enabled = rainbow_state
26
23
  end
27
24
 
28
25
  private
29
26
 
30
27
  def process_config
31
- w "#{Rainbow("CONFIGURATION").bg(:blue)}\n"
28
+ w "#{colorize("CONFIGURATION", :bg_blue)}\n"
32
29
  my_screen_table = Terminal::Table.new do |st|
33
30
  @data[:config].each do |key, value|
34
31
  st.add_row [key.to_s, trim(value)]
@@ -38,7 +35,7 @@ class ResumeTXTFormatter < ResumeArrayFormatter
38
35
  end
39
36
 
40
37
  def process_cases
41
- w "#{Rainbow("CASES").bg(:blue)}\n"
38
+ w "#{colorize("CASES", :bg_blue)}\n"
42
39
  my_screen_table = Terminal::Table.new do |st|
43
40
  st.add_row %w[CASE MEMBERS GRADE STATE]
44
41
  @data[:cases].each do |line|
@@ -64,36 +61,56 @@ class ResumeTXTFormatter < ResumeArrayFormatter
64
61
  end
65
62
  return unless my_screen_table.rows.size > 1
66
63
 
67
- w "#{Rainbow("CONN ERRORS").bg(:red)}\n#{my_screen_table}\n"
64
+ w "#{colorize("CONN ERRORS", :bg_red)}\n#{my_screen_table}\n\n"
68
65
  end
69
66
 
70
67
  def process_results
71
- w "\n#{Rainbow("RESULTS").bg(:blue)}\n"
68
+ w "#{colorize("RESULTS", :bg_blue)}\n"
72
69
  my_screen_table = Terminal::Table.new do |st|
73
70
  @data[:results].each do |key, value|
74
71
  st.add_row [key.to_s, value.to_s]
75
72
  end
76
73
  end
77
- w "#{my_screen_table}\n"
74
+ w "#{my_screen_table}\n\n"
78
75
  end
79
76
 
80
77
  def process_hof
81
- return if @data[:hall_of_fame].size < 3
78
+ return if @data[:hall_of_fame].size < MIN_HALL_OF_FAME
82
79
 
83
- w "\n#{Rainbow("HALL OF FAME").bg(:blue)}\n"
80
+ w "#{colorize("HALL OF FAME", :bg_blue)}\n"
84
81
  my_screen_table = Terminal::Table.new do |st|
85
82
  @data[:hall_of_fame].each do |line|
86
- mycolor = :green
87
- mycolor = :red if line[0] < 50
88
- text1 = Rainbow(line[0]).color(mycolor)
89
- text2 = Rainbow(line[1]).color(mycolor)
83
+ color = :green
84
+ color = :red if line[0] < 50
85
+ text1 = colorize(line[0], color)
86
+ text2 = colorize(line[1], color)
90
87
  if line[0] == @data[:results][:grade]
91
- text1 = text1.bright
92
- text2 = text2.bright
88
+ text1 = colorize(text1, :bright)
89
+ text2 = colorize(text2, :bright)
93
90
  end
94
91
  st.add_row [text1, text2]
95
92
  end
96
93
  end
97
94
  w "#{my_screen_table}\n"
98
95
  end
96
+
97
+ def colorize(text, option)
98
+ return text unless @colorize
99
+
100
+ case option
101
+ when :bg_blue
102
+ Rainbow(text).bg(:blue)
103
+ when :blue_bright
104
+ Rainbow(text).blue.bright
105
+ when :bright
106
+ Rainbow(text).bright
107
+ when :green
108
+ Rainbow(text).color(:green)
109
+ when :red
110
+ Rainbow(text).color(:red)
111
+ else
112
+ puts "[ERROR] ResumeTXTFormatter#colorize option=#{option}"
113
+ exit 1
114
+ end
115
+ end
99
116
  end
@@ -1,5 +1,5 @@
1
1
  module Teuton
2
- VERSION = "2.10.3"
2
+ VERSION = "2.10.4"
3
3
  APPNAME = "teuton"
4
4
  GEMNAME = "teuton"
5
5
  DOCKERNAME = "dvarrui/#{GEMNAME}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.3
4
+ version: 2.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz