teuton 2.3.6 → 2.3.7
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 +4 -4
- data/README.md +3 -4
- 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 +1 -1
- 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 +11 -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 -3
- 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 -20
- 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,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
|
|
4
|
-
require_relative 'array_formatter'
|
|
1
|
+
require "terminal-table"
|
|
2
|
+
require "rainbow"
|
|
3
|
+
require_relative "array_formatter"
|
|
5
4
|
|
|
6
5
|
class TXTFormatter < ArrayFormatter
|
|
7
|
-
def initialize(report, color=false)
|
|
6
|
+
def initialize(report, color = false)
|
|
8
7
|
@color = color
|
|
9
8
|
super(report)
|
|
10
9
|
@data = {}
|
|
@@ -30,9 +29,9 @@ class TXTFormatter < ArrayFormatter
|
|
|
30
29
|
def process_config
|
|
31
30
|
w "#{Rainbow("CONFIGURATION").bg(:blue)}\n"
|
|
32
31
|
my_screen_table = Terminal::Table.new do |st|
|
|
33
|
-
@data[:config].sort.each { |key,value| st.add_row [
|
|
32
|
+
@data[:config].sort.each { |key, value| st.add_row [key.to_s, value.to_s] }
|
|
34
33
|
end
|
|
35
|
-
w my_screen_table
|
|
34
|
+
w "#{my_screen_table}\n\n"
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
def process_logs
|
|
@@ -52,11 +51,11 @@ class TXTFormatter < ArrayFormatter
|
|
|
52
51
|
def process_results
|
|
53
52
|
w "\n#{Rainbow("RESULTS").bg(:blue)}\n"
|
|
54
53
|
my_screen_table = Terminal::Table.new do |st|
|
|
55
|
-
@data[:results].each do |key,value|
|
|
56
|
-
st.add_row [
|
|
54
|
+
@data[:results].each do |key, value|
|
|
55
|
+
st.add_row [key.to_s, value.to_s]
|
|
57
56
|
end
|
|
58
57
|
end
|
|
59
|
-
w my_screen_table
|
|
58
|
+
w "#{my_screen_table}\n"
|
|
60
59
|
end
|
|
61
60
|
|
|
62
61
|
def process_hof
|
|
@@ -76,25 +75,25 @@ class TXTFormatter < ArrayFormatter
|
|
|
76
75
|
st.add_row [text1, text2]
|
|
77
76
|
end
|
|
78
77
|
end
|
|
79
|
-
w my_screen_table
|
|
78
|
+
w "#{my_screen_table}\n"
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
private
|
|
83
82
|
|
|
84
83
|
def process_group(group)
|
|
85
|
-
tab =
|
|
84
|
+
tab = " "
|
|
86
85
|
w "- #{Rainbow(group[:title]).blue.bright}\n"
|
|
87
86
|
group[:targets].each do |i|
|
|
88
87
|
color = :red
|
|
89
88
|
color = :green if i[:check]
|
|
90
|
-
w tab*2 + format("%02d", i[:target_id].to_i)
|
|
91
|
-
w " (
|
|
92
|
-
w tab*4
|
|
93
|
-
w tab*4
|
|
94
|
-
|
|
95
|
-
w tab*4
|
|
96
|
-
w tab*4
|
|
97
|
-
w tab*4
|
|
89
|
+
w tab * 2 + format("%02d", i[:target_id].to_i)
|
|
90
|
+
w " (" + Rainbow(i[:score].to_s + "/" + i[:weight].to_s).color(color) + ")\n"
|
|
91
|
+
w "#{tab * 4}Description : #{i[:description]}\n"
|
|
92
|
+
w "#{tab * 4}Command : #{i[:command]}\n"
|
|
93
|
+
w "#{tab * 4}Duration : #{i[:duration]} (#{i[:conn_type]})\n"
|
|
94
|
+
w "#{tab * 4}Alterations : #{i[:alterations]}\n"
|
|
95
|
+
w "#{tab * 4}Expected : #{i[:expected]} (#{i[:expected].class})\n"
|
|
96
|
+
w "#{tab * 4}Result : #{i[:result]} (#{i[:result].class})\n"
|
|
98
97
|
end
|
|
99
98
|
end
|
|
100
99
|
end
|
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
require_relative 'base_formatter'
|
|
1
|
+
require_relative "base_formatter"
|
|
3
2
|
|
|
4
3
|
class XMLFormatter < BaseFormatter
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
4
|
+
def process
|
|
5
|
+
tab = " "
|
|
6
|
+
w "<teuton version='0.2'>\n"
|
|
7
|
+
w "#{tab}<head>\n"
|
|
8
|
+
@head.each { |key, value| w "#{tab * 2}<#{key}>#{value}</#{key}>\n" }
|
|
9
|
+
w "#{tab}</head>\n"
|
|
10
|
+
w "#{tab}<lines>\n"
|
|
11
|
+
@lines.each do |i|
|
|
12
|
+
unless i.instance_of? Hash
|
|
13
|
+
w "#{tab * 2}<line type='log'>#{i}</line>\n"
|
|
14
|
+
next
|
|
15
|
+
end
|
|
16
|
+
w "#{tab * 2}<line>\n"
|
|
17
|
+
w "#{tab * 3}<id>#{i[:id]}</id>\n"
|
|
18
|
+
w "#{tab * 3}<description>#{i[:description]}</description>\n"
|
|
19
|
+
w "#{tab * 3}<command"
|
|
20
|
+
w " tempfile='#{i[:tempfile]}'" if i[:tempfile]
|
|
21
|
+
w ">#{i[:command]}</command>\n"
|
|
22
|
+
w "#{tab * 3}<check>#{i[:check]}</check>\n"
|
|
23
|
+
w "#{tab * 3}<weigth>#{i[:weight]}</weigth>\n"
|
|
24
|
+
w "#{tab * 2}</line>\n"
|
|
32
25
|
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
w "</tt-checker>\n"
|
|
26
|
+
w "#{tab}</lines>\n"
|
|
27
|
+
w "#{tab}<tail>\n"
|
|
28
|
+
@tail.each { |key, value| w "#{tab * 2}<#{key}>#{value}</#{key}>\n" }
|
|
29
|
+
w "#{tab}</tail>\n"
|
|
30
|
+
w "</teuton>\n"
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
deinit
|
|
33
|
+
end
|
|
42
34
|
end
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require_relative
|
|
3
|
+
require "yaml"
|
|
4
|
+
require_relative "array_formatter"
|
|
5
5
|
|
|
6
|
-
##
|
|
7
|
-
# YAMLFormatter class receive a [Report] and generates YAML output.
|
|
8
6
|
class YAMLFormatter < ArrayFormatter
|
|
9
|
-
##
|
|
10
|
-
# Class constructor
|
|
11
|
-
# @param report [Report] Parent object that contains data to be exported.
|
|
12
|
-
def initialize(report)
|
|
13
|
-
super(report)
|
|
14
|
-
@data = {}
|
|
15
|
-
end
|
|
16
|
-
|
|
17
7
|
##
|
|
18
8
|
# Process data from parent object and export it into YAML format.
|
|
19
9
|
# @return [nil]
|
data/lib/teuton/report/report.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
3
|
+
require "terminal-table"
|
|
4
|
+
require_relative "../application"
|
|
5
|
+
require_relative "formatter/formatter_factory"
|
|
6
|
+
require_relative "show"
|
|
7
|
+
require_relative "close"
|
|
8
8
|
|
|
9
9
|
##
|
|
10
10
|
# This class maintain the results of every case, in a structured way.
|
|
@@ -29,7 +29,7 @@ class Report
|
|
|
29
29
|
attr_reader :history
|
|
30
30
|
##
|
|
31
31
|
# Class constructor
|
|
32
|
-
def initialize(id =
|
|
32
|
+
def initialize(id = "00")
|
|
33
33
|
@id = id
|
|
34
34
|
@filename = "case-#{@id}"
|
|
35
35
|
@output_dir = Application.instance.output_basedir
|
|
@@ -39,7 +39,7 @@ class Report
|
|
|
39
39
|
# @history save 1 letter for every target.
|
|
40
40
|
# For example: "..F." means: good, good, fail and good
|
|
41
41
|
# I will use this in the future stats manager.
|
|
42
|
-
@history =
|
|
42
|
+
@history = ""
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
##
|
|
@@ -47,7 +47,7 @@ class Report
|
|
|
47
47
|
# @param format [Symbol] Select export format. Default value is :txt.
|
|
48
48
|
def export(format = :txt)
|
|
49
49
|
@format = format
|
|
50
|
-
filepath = File.join(@output_dir, @filename +
|
|
50
|
+
filepath = File.join(@output_dir, @filename + "." \
|
|
51
51
|
+ FormatterFactory.ext(@format))
|
|
52
52
|
|
|
53
53
|
formatter = FormatterFactory.get(self, @format, filepath)
|
|
@@ -59,12 +59,12 @@ class Report
|
|
|
59
59
|
# @param format [Symbol] Select export format. Default value is :txt.
|
|
60
60
|
def export_resume(format = :txt)
|
|
61
61
|
@format = "resume_#{format}".to_sym
|
|
62
|
-
filepath = File.join(@output_dir, @filename +
|
|
62
|
+
filepath = File.join(@output_dir, @filename + "." \
|
|
63
63
|
+ FormatterFactory.ext(@format))
|
|
64
64
|
formatter = FormatterFactory.get(self, @format, filepath)
|
|
65
65
|
formatter.process
|
|
66
66
|
|
|
67
|
-
filepath = File.join(@output_dir,
|
|
67
|
+
filepath = File.join(@output_dir, "moodle.csv")
|
|
68
68
|
formatter = FormatterFactory.get(self, :moodle_csv, filepath)
|
|
69
69
|
formatter.process
|
|
70
70
|
end
|
data/lib/teuton/report/show.rb
CHANGED
|
@@ -6,7 +6,7 @@ class Report
|
|
|
6
6
|
# Display [Report] information on screen
|
|
7
7
|
def show
|
|
8
8
|
show_initial_configurations
|
|
9
|
-
if @filename.to_s.include?
|
|
9
|
+
if @filename.to_s.include? "resume"
|
|
10
10
|
show_resume
|
|
11
11
|
else
|
|
12
12
|
show_targets_history
|
|
@@ -20,7 +20,7 @@ class Report
|
|
|
20
20
|
##
|
|
21
21
|
# Display initial configurations
|
|
22
22
|
def show_initial_configurations
|
|
23
|
-
puts Rainbow(
|
|
23
|
+
puts Rainbow("INITIAL CONFIGURATIONS").bright
|
|
24
24
|
my_screen_table = Terminal::Table.new do |st|
|
|
25
25
|
@head.each do |key, value|
|
|
26
26
|
st.add_row [key.to_s, trim(value)]
|
|
@@ -39,7 +39,7 @@ class Report
|
|
|
39
39
|
##
|
|
40
40
|
# Display case list
|
|
41
41
|
def show_case_list
|
|
42
|
-
puts Rainbow(
|
|
42
|
+
puts Rainbow("CASE RESULTS").bright
|
|
43
43
|
my_screen_table = Terminal::Table.new do |st|
|
|
44
44
|
st.add_row %w[CASE MEMBERS GRADE STATE]
|
|
45
45
|
@lines.each do |line|
|
|
@@ -49,48 +49,37 @@ class Report
|
|
|
49
49
|
puts "#{my_screen_table}\n\n"
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
##
|
|
53
|
-
# Display Connection status
|
|
54
|
-
# rubocop:disable Metrics/MethodLength
|
|
55
|
-
# rubocop:disable Metrics/AbcSize
|
|
56
52
|
def show_conn_status
|
|
57
53
|
errors = 0
|
|
58
54
|
@lines.each { |line| errors += line[:conn_status].size }
|
|
59
55
|
return if errors.zero?
|
|
60
56
|
|
|
61
|
-
puts Rainbow(
|
|
57
|
+
puts Rainbow("CONN ERRORS").bright
|
|
62
58
|
my_screen_table = Terminal::Table.new do |st|
|
|
63
59
|
st.add_row %w[CASE MEMBERS HOST ERROR]
|
|
64
60
|
@lines.each do |line|
|
|
65
61
|
line[:conn_status].each_pair do |host, error|
|
|
66
|
-
st.add_row [line[:id], line[:members], host,
|
|
67
|
-
Rainbow(error).red.bright]
|
|
62
|
+
st.add_row [line[:id], line[:members], host, Rainbow(error).red.bright]
|
|
68
63
|
end
|
|
69
64
|
end
|
|
70
65
|
end
|
|
71
66
|
puts "#{my_screen_table}\n\n"
|
|
72
67
|
end
|
|
73
|
-
# rubocop:enable Metrics/MethodLength
|
|
74
|
-
# rubocop:enable Metrics/AbcSize
|
|
75
68
|
|
|
76
|
-
# rubocop:disable Style/FormatString
|
|
77
|
-
# rubocop:disable Style/FormatStringToken
|
|
78
|
-
# rubocop:disable Metrics/AbcSize
|
|
79
|
-
# rubocop:disable Metrics/MethodLength
|
|
80
69
|
def show_targets_history
|
|
81
|
-
tab =
|
|
82
|
-
puts Rainbow(
|
|
70
|
+
tab = " "
|
|
71
|
+
puts Rainbow("CASE RESULTS").bright
|
|
83
72
|
if @lines.size == 1
|
|
84
73
|
puts @lines[0]
|
|
85
74
|
else
|
|
86
75
|
@lines.each do |i|
|
|
87
|
-
if i.class.to_s ==
|
|
76
|
+
if i.class.to_s == "Hash"
|
|
88
77
|
value = 0.0
|
|
89
78
|
value = i[:weight] if i[:check]
|
|
90
|
-
print tab +
|
|
91
|
-
print
|
|
92
|
-
print
|
|
93
|
-
puts
|
|
79
|
+
print tab + "%03d" % i[:id].to_i
|
|
80
|
+
print " (%2.1f" % value.to_f
|
|
81
|
+
print "/%2.1f" % i[:weight].to_f
|
|
82
|
+
puts ") %s" % i[:description].to_s
|
|
94
83
|
else
|
|
95
84
|
puts "#{tab}=> #{i}"
|
|
96
85
|
end
|
|
@@ -98,15 +87,9 @@ class Report
|
|
|
98
87
|
end
|
|
99
88
|
puts "\n\n"
|
|
100
89
|
end
|
|
101
|
-
# rubocop:enable Style/FormatString
|
|
102
|
-
# rubocop:enable Style/FormatStringToken
|
|
103
|
-
# rubocop:enable Metrics/AbcSize
|
|
104
|
-
# rubocop:enable Metrics/MethodLength
|
|
105
90
|
|
|
106
|
-
##
|
|
107
|
-
# Display final values section on screen
|
|
108
91
|
def show_final_values
|
|
109
|
-
puts Rainbow(
|
|
92
|
+
puts Rainbow("FINAL VALUES").bright
|
|
110
93
|
my_screen_table = Terminal::Table.new do |st|
|
|
111
94
|
@tail.each do |key, value|
|
|
112
95
|
st.add_row [key.to_s, value.to_s]
|
|
@@ -115,13 +98,11 @@ class Report
|
|
|
115
98
|
puts "#{my_screen_table}\n\n"
|
|
116
99
|
end
|
|
117
100
|
|
|
118
|
-
##
|
|
119
|
-
# Display hall of fame section on screen
|
|
120
101
|
def show_hall_of_fame
|
|
121
102
|
app = Application.instance
|
|
122
103
|
return if app.hall_of_fame.size < 3
|
|
123
104
|
|
|
124
|
-
puts Rainbow(
|
|
105
|
+
puts Rainbow("HALL OF FAME").bright
|
|
125
106
|
my_screen_table = Terminal::Table.new do |st|
|
|
126
107
|
app.hall_of_fame.each do |line|
|
|
127
108
|
st.add_row [line[0], line[1]]
|
data/lib/teuton/skeleton.rb
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
require 'rainbow'
|
|
1
|
+
require "fileutils"
|
|
2
|
+
require "rainbow"
|
|
4
3
|
|
|
5
4
|
module Skeleton
|
|
6
|
-
##
|
|
7
|
-
# Create teuton project skeleton
|
|
8
5
|
def self.create(project_dir)
|
|
9
6
|
project_name = File.basename(project_dir)
|
|
10
7
|
puts "\n[INFO] Creating #{Rainbow(project_name).bright} project skeleton"
|
|
@@ -13,15 +10,11 @@ module Skeleton
|
|
|
13
10
|
create_main_dir_and_files(project_dir, source_basedir)
|
|
14
11
|
end
|
|
15
12
|
|
|
16
|
-
##
|
|
17
|
-
# Create main dir and files
|
|
18
|
-
# @param project_dir (String)
|
|
19
|
-
# @param source_basedir (String)
|
|
20
13
|
private_class_method def self.create_main_dir_and_files(project_dir, source_basedir)
|
|
21
14
|
# Directory and files: Ruby script, Configfile, gitignore
|
|
22
15
|
items = [
|
|
23
|
-
{
|
|
24
|
-
{
|
|
16
|
+
{source: "files/config.yaml", target: "config.yaml"},
|
|
17
|
+
{source: "files/start.rb", target: "start.rb"}
|
|
25
18
|
]
|
|
26
19
|
items.each do |item|
|
|
27
20
|
source = File.join(source_basedir, item[:source])
|
|
@@ -37,7 +30,7 @@ module Skeleton
|
|
|
37
30
|
begin
|
|
38
31
|
FileUtils.mkdir_p(dirpath)
|
|
39
32
|
puts "* Create dir => #{Rainbow(dirpath).green}"
|
|
40
|
-
rescue
|
|
33
|
+
rescue
|
|
41
34
|
puts "* Create dir ERROR => #{Rainbow(dirpath).red}"
|
|
42
35
|
end
|
|
43
36
|
end
|
|
@@ -47,7 +40,6 @@ module Skeleton
|
|
|
47
40
|
# Copy file
|
|
48
41
|
# @param source (String) Source file
|
|
49
42
|
# @param dest (String) Dest file
|
|
50
|
-
# rubocop:disable Metrics/MethodLength
|
|
51
43
|
private_class_method def self.copyfile(source, dest)
|
|
52
44
|
if File.exist? dest
|
|
53
45
|
puts "* Exists file! => #{Rainbow(dest).yellow}"
|
|
@@ -56,7 +48,7 @@ module Skeleton
|
|
|
56
48
|
begin
|
|
57
49
|
FileUtils.cp(source, dest)
|
|
58
50
|
puts "* Create file => #{Rainbow(dest).green}"
|
|
59
|
-
rescue
|
|
51
|
+
rescue
|
|
60
52
|
puts "* Create file ERROR => #{Rainbow(dest).red}"
|
|
61
53
|
end
|
|
62
54
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
require 'json/pure'
|
|
1
|
+
require "yaml"
|
|
2
|
+
require "json/pure"
|
|
4
3
|
|
|
5
4
|
##
|
|
6
5
|
# Functions that read data from ConfigFile using YAML or JSON formats
|
|
@@ -14,12 +13,12 @@ module ConfigFileReader
|
|
|
14
13
|
data = {}
|
|
15
14
|
data[:global] = {}
|
|
16
15
|
data[:alias] = {}
|
|
17
|
-
data[:cases] = [{
|
|
16
|
+
data[:cases] = [{tt_members: "anonymous"}]
|
|
18
17
|
return data
|
|
19
18
|
end
|
|
20
|
-
return read_yaml(filepath) if File.extname(filepath) ==
|
|
19
|
+
return read_yaml(filepath) if File.extname(filepath) == ".yaml"
|
|
21
20
|
|
|
22
|
-
return read_json(filepath) if File.extname(filepath) ==
|
|
21
|
+
return read_json(filepath) if File.extname(filepath) == ".json"
|
|
23
22
|
|
|
24
23
|
raise "[ERROR] ConfigFileReader: #{filepath}"
|
|
25
24
|
end
|
|
@@ -31,11 +30,11 @@ module ConfigFileReader
|
|
|
31
30
|
def self.read_yaml(filepath)
|
|
32
31
|
begin
|
|
33
32
|
data = YAML.load(File.open(filepath))
|
|
34
|
-
rescue
|
|
35
|
-
puts "\n" + (
|
|
33
|
+
rescue => e
|
|
34
|
+
puts "\n" + ("=" * 80)
|
|
36
35
|
puts "[ERROR] ConfigFileReader#read <#{filepath}>"
|
|
37
|
-
puts
|
|
38
|
-
puts " #{e.message}\n" + (
|
|
36
|
+
puts " I suggest to revise file format!"
|
|
37
|
+
puts " #{e.message}\n" + ("=" * 80)
|
|
39
38
|
raise "[ERROR] ConfigFileReader <#{e}>"
|
|
40
39
|
end
|
|
41
40
|
data = convert_string_keys_to_symbol(data)
|
|
@@ -68,21 +67,23 @@ module ConfigFileReader
|
|
|
68
67
|
return if data[:global][:tt_include].nil?
|
|
69
68
|
|
|
70
69
|
include_dir = data[:global][:tt_include]
|
|
71
|
-
if include_dir == File.absolute_path(include_dir)
|
|
72
|
-
|
|
70
|
+
basedir = if include_dir == File.absolute_path(include_dir)
|
|
71
|
+
include_dir
|
|
73
72
|
else
|
|
74
|
-
|
|
73
|
+
File.join(File.dirname(filepath), data[:global][:tt_include])
|
|
75
74
|
end
|
|
76
|
-
files = Dir.glob(File.join(basedir,
|
|
77
|
-
files += Dir.glob(File.join(basedir,
|
|
75
|
+
files = Dir.glob(File.join(basedir, "**/*.yaml"))
|
|
76
|
+
files += Dir.glob(File.join(basedir, "**/*.yml"))
|
|
77
|
+
files += Dir.glob(File.join(basedir, "**/*.YAML"))
|
|
78
|
+
files += Dir.glob(File.join(basedir, "**/*.YML"))
|
|
78
79
|
files.each { |file|
|
|
79
80
|
begin
|
|
80
81
|
data[:cases] << YAML.load(File.open(file))
|
|
81
|
-
rescue
|
|
82
|
-
puts "\n" + (
|
|
82
|
+
rescue => e
|
|
83
|
+
puts "\n" + ("=" * 80)
|
|
83
84
|
puts "[ERROR] ConfigFileReader#read <#{file}>"
|
|
84
|
-
puts
|
|
85
|
-
puts " #{e.message}\n" + (
|
|
85
|
+
puts " I suggest to revise file format!"
|
|
86
|
+
puts " #{e.message}\n" + ("=" * 80)
|
|
86
87
|
end
|
|
87
88
|
}
|
|
88
89
|
end
|
|
@@ -95,9 +96,9 @@ module ConfigFileReader
|
|
|
95
96
|
key2 = key
|
|
96
97
|
key2 = key.to_sym if key.class
|
|
97
98
|
value2 = value
|
|
98
|
-
if value.
|
|
99
|
+
if value.instance_of? Hash
|
|
99
100
|
value2 = convert_string_keys_to_symbol(value)
|
|
100
|
-
elsif value.
|
|
101
|
+
elsif value.instance_of? Array
|
|
101
102
|
value2 = []
|
|
102
103
|
value.each { |i| value2 << convert_string_keys_to_symbol(i) }
|
|
103
104
|
end
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
+
require "rainbow"
|
|
1
2
|
|
|
2
|
-
require 'rainbow'
|
|
3
|
-
require_relative '../application'
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
# NameFileFinder module
|
|
7
|
-
# Methods: find_filenames_for, verbose, verboseln
|
|
8
3
|
module NameFileFinder
|
|
9
4
|
##
|
|
10
5
|
# Find project filenames from input project relative path
|
|
@@ -30,11 +25,11 @@ module NameFileFinder
|
|
|
30
25
|
# @param folder_path (String)
|
|
31
26
|
def self.find_filenames_from_directory(folder_path)
|
|
32
27
|
# COMPLEX MODE: We use start.rb as main RB file
|
|
33
|
-
script_path = File.join(folder_path,
|
|
28
|
+
script_path = File.join(folder_path, "start.rb")
|
|
34
29
|
unless File.exist? script_path
|
|
35
|
-
print Rainbow(
|
|
30
|
+
print Rainbow("[ERROR] File ").red
|
|
36
31
|
print Rainbow(script_path).bright.red
|
|
37
|
-
puts Rainbow(
|
|
32
|
+
puts Rainbow(" not found!").red
|
|
38
33
|
exit 1
|
|
39
34
|
end
|
|
40
35
|
|
|
@@ -52,19 +47,19 @@ module NameFileFinder
|
|
|
52
47
|
def self.find_configfilename_from_directory(folder_path)
|
|
53
48
|
# COMPLEX MODE: We use config.yaml by default
|
|
54
49
|
app = Application.instance
|
|
55
|
-
config_path =
|
|
50
|
+
config_path = ""
|
|
56
51
|
|
|
57
|
-
if app.options[
|
|
58
|
-
config_name =
|
|
52
|
+
if app.options["cpath"].nil?
|
|
53
|
+
config_name = "config"
|
|
59
54
|
# Config name file is introduced by cname arg option from teuton command
|
|
60
|
-
config_name = app.options[
|
|
55
|
+
config_name = app.options["cname"] unless app.options["cname"].nil?
|
|
61
56
|
config_path = File.join(folder_path, "#{config_name}.json")
|
|
62
57
|
unless File.exist? config_path
|
|
63
58
|
config_path = File.join(folder_path, "#{config_name}.yaml")
|
|
64
59
|
end
|
|
65
60
|
else
|
|
66
61
|
# Config path file is introduced by cpath arg option from teuton command
|
|
67
|
-
config_path = app.options[
|
|
62
|
+
config_path = app.options["cpath"]
|
|
68
63
|
end
|
|
69
64
|
app.config_path = config_path
|
|
70
65
|
end
|
|
@@ -72,17 +67,17 @@ module NameFileFinder
|
|
|
72
67
|
def self.find_filenames_from_rb(script_path)
|
|
73
68
|
# SIMPLE MODE: We use script_path as main RB file
|
|
74
69
|
# This must be fullpath to DSL script file
|
|
75
|
-
if File.extname(script_path) !=
|
|
76
|
-
print Rainbow(
|
|
70
|
+
if File.extname(script_path) != ".rb"
|
|
71
|
+
print Rainbow("[ERROR] Script ").red
|
|
77
72
|
print Rainbow(script_path).bright.red
|
|
78
|
-
puts Rainbow(
|
|
73
|
+
puts Rainbow(" must have rb extension").red
|
|
79
74
|
exit 1
|
|
80
75
|
end
|
|
81
76
|
|
|
82
77
|
app = Application.instance
|
|
83
78
|
app.project_path = File.dirname(script_path)
|
|
84
79
|
app.script_path = script_path
|
|
85
|
-
app.test_name = File.basename(script_path,
|
|
80
|
+
app.test_name = File.basename(script_path, ".rb")
|
|
86
81
|
|
|
87
82
|
find_configfilenames_from_rb(script_path)
|
|
88
83
|
end
|
|
@@ -92,19 +87,19 @@ module NameFileFinder
|
|
|
92
87
|
# This must be fullpath to DSL script file
|
|
93
88
|
app = Application.instance
|
|
94
89
|
|
|
95
|
-
config_path =
|
|
96
|
-
if app.options[
|
|
97
|
-
config_name = File.basename(script_path,
|
|
90
|
+
config_path = ""
|
|
91
|
+
if app.options["cpath"].nil?
|
|
92
|
+
config_name = File.basename(script_path, ".rb")
|
|
98
93
|
# Config name file is introduced by cname arg option from teuton command
|
|
99
|
-
config_name = app.options[
|
|
94
|
+
config_name = app.options["cname"] unless app.options["cname"].nil?
|
|
100
95
|
|
|
101
|
-
config_path = File.join(app.project_path, config_name +
|
|
96
|
+
config_path = File.join(app.project_path, config_name + ".json")
|
|
102
97
|
unless File.exist? config_path
|
|
103
|
-
config_path = File.join(app.project_path, config_name +
|
|
98
|
+
config_path = File.join(app.project_path, config_name + ".yaml")
|
|
104
99
|
end
|
|
105
100
|
else
|
|
106
101
|
# Config path file is introduced by cpath arg option from teuton command
|
|
107
|
-
config_path = app.options[
|
|
102
|
+
config_path = app.options["cpath"]
|
|
108
103
|
end
|
|
109
104
|
app.config_path = config_path
|
|
110
105
|
end
|
|
@@ -115,7 +110,7 @@ module NameFileFinder
|
|
|
115
110
|
|
|
116
111
|
def self.verbose(text)
|
|
117
112
|
return unless Application.instance.verbose
|
|
118
|
-
return if Application.instance.options[
|
|
113
|
+
return if Application.instance.options["quiet"]
|
|
119
114
|
|
|
120
115
|
print text
|
|
121
116
|
end
|
data/lib/teuton/utils/verbose.rb
CHANGED
data/lib/teuton/version.rb
CHANGED
data/lib/teuton.rb
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
require_relative 'teuton/application'
|
|
1
|
+
require_relative "teuton/application"
|
|
3
2
|
|
|
4
3
|
module Teuton
|
|
5
4
|
def self.create(path_to_new_dir)
|
|
6
|
-
require_relative
|
|
5
|
+
require_relative "teuton/skeleton"
|
|
7
6
|
Skeleton.create(path_to_new_dir)
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def self.run(projectpath, options = {})
|
|
11
10
|
Application.instance.add_input_params(projectpath, options)
|
|
12
|
-
require_dsl_and_script(
|
|
11
|
+
require_dsl_and_script("teuton/case_manager/dsl") # Define DSL keywords
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
def self.readme(projectpath, options = {})
|
|
16
15
|
# Create Readme file for a teuton test
|
|
17
16
|
Application.instance.add_input_params(projectpath, options)
|
|
18
|
-
require_dsl_and_script(
|
|
17
|
+
require_dsl_and_script("teuton/readme/readme") # Define DSL keywords
|
|
19
18
|
|
|
20
19
|
app = Application.instance
|
|
21
20
|
readme = Readme.new(app.script_path, app.config_path)
|
|
@@ -24,7 +23,7 @@ module Teuton
|
|
|
24
23
|
|
|
25
24
|
def self.check(projectpath, options = {})
|
|
26
25
|
Application.instance.add_input_params(projectpath, options)
|
|
27
|
-
require_dsl_and_script(
|
|
26
|
+
require_dsl_and_script("teuton/check/laboratory") # Define DSL keywords
|
|
28
27
|
|
|
29
28
|
app = Application.instance
|
|
30
29
|
lab = Laboratory.new(app.script_path, app.config_path)
|