teuton 2.3.5 → 2.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -5
  3. data/bin/teuton +1 -1
  4. data/docs/CHANGELOG.md +8 -0
  5. data/docs/changelog/v2.4.md +16 -0
  6. data/docs/dsl/definition/expect.md +11 -7
  7. data/docs/dsl/definition/result.md +7 -6
  8. data/docs/dsl/definition/run_local.md +0 -1
  9. data/docs/dsl/definition/target.md +1 -1
  10. data/docs/dsl/execution/export.md +14 -16
  11. data/docs/dsl/execution/send.md +12 -12
  12. data/docs/dsl/setting/get.md +5 -5
  13. data/docs/es/exit_code.md +59 -0
  14. data/docs/es/guess_os.md +28 -0
  15. data/docs/{Challenge-Server-Project.md → ideas/Challenge-Server-Project.md} +0 -0
  16. data/docs/{changelog → ideas}/contributions.md +0 -0
  17. data/docs/{changelog → ideas}/ideas.md +0 -0
  18. data/docs/{changelog → ideas}/servidor-de-retos.md +0 -0
  19. data/docs/learn/{example-01-target.md → 01-target.md} +1 -3
  20. data/docs/learn/{example-02-config.md → 02-config.md} +1 -3
  21. data/docs/learn/{example-03-remote-hosts.md → 03-remote_hosts.md} +10 -10
  22. data/docs/learn/{example-04-new-test.md → 04-new_test.md} +8 -16
  23. data/docs/learn/{example-05-use.md → 05-use.md} +1 -3
  24. data/docs/learn/{example-06-debug.md → 06-debug.md} +1 -3
  25. data/docs/learn/{example-07-log.md → 07-log.md} +1 -3
  26. data/docs/learn/{example-08-readme.md → 08-readme.md} +1 -3
  27. data/docs/learn/{example-09-preserve.md → 09-preserve.md} +7 -4
  28. data/docs/learn/10-result.md +36 -0
  29. data/docs/learn/11-moodle_id.md +19 -0
  30. data/docs/learn/12-get_vars.md +37 -0
  31. data/docs/learn/13-include.md +59 -0
  32. data/docs/learn/16-exit_codes.md +24 -0
  33. data/docs/learn/README.md +19 -17
  34. data/lib/teuton/application.rb +24 -17
  35. data/lib/teuton/case_manager/case/builtin/main.rb +2 -3
  36. data/lib/teuton/case_manager/case/builtin/package.rb +2 -3
  37. data/lib/teuton/case_manager/case/builtin/service.rb +4 -5
  38. data/lib/teuton/case_manager/case/builtin/teuton_file.rb +3 -4
  39. data/lib/teuton/case_manager/case/builtin/teuton_host.rb +5 -6
  40. data/lib/teuton/case_manager/case/builtin/user.rb +1 -2
  41. data/lib/teuton/case_manager/case/case.rb +27 -27
  42. data/lib/teuton/case_manager/case/close.rb +2 -2
  43. data/lib/teuton/case_manager/case/config.rb +14 -14
  44. data/lib/teuton/case_manager/case/dsl/expect.rb +46 -39
  45. data/lib/teuton/case_manager/case/dsl/goto.rb +2 -2
  46. data/lib/teuton/case_manager/case/dsl/log.rb +5 -6
  47. data/lib/teuton/case_manager/case/dsl/macro.rb +11 -7
  48. data/lib/teuton/case_manager/case/dsl/main.rb +8 -8
  49. data/lib/teuton/case_manager/case/dsl/send.rb +12 -14
  50. data/lib/teuton/case_manager/case/dsl/unique.rb +1 -3
  51. data/lib/teuton/case_manager/case/main.rb +5 -5
  52. data/lib/teuton/case_manager/case/play.rb +1 -1
  53. data/lib/teuton/case_manager/case/result/ext_array.rb +9 -9
  54. data/lib/teuton/case_manager/case/result/ext_compare.rb +44 -58
  55. data/lib/teuton/case_manager/case/result/ext_filter.rb +20 -8
  56. data/lib/teuton/case_manager/case/result/result.rb +19 -18
  57. data/lib/teuton/case_manager/case/runner.rb +53 -60
  58. data/lib/teuton/case_manager/case_manager.rb +15 -15
  59. data/lib/teuton/case_manager/check_cases.rb +1 -4
  60. data/lib/teuton/case_manager/dsl.rb +5 -5
  61. data/lib/teuton/case_manager/export_manager.rb +8 -19
  62. data/lib/teuton/case_manager/hall_of_fame.rb +4 -6
  63. data/lib/teuton/case_manager/main.rb +4 -5
  64. data/lib/teuton/case_manager/report.rb +21 -16
  65. data/lib/teuton/case_manager/show.rb +2 -2
  66. data/lib/teuton/case_manager/utils.rb +13 -14
  67. data/lib/teuton/check/builtin.rb +5 -1
  68. data/lib/teuton/check/dsl.rb +10 -11
  69. data/lib/teuton/check/laboratory.rb +13 -15
  70. data/lib/teuton/check/show.rb +33 -35
  71. data/lib/teuton/cli.rb +31 -35
  72. data/lib/teuton/files/start.rb +3 -6
  73. data/lib/teuton/readme/dsl.rb +12 -6
  74. data/lib/teuton/readme/lang.rb +20 -21
  75. data/lib/teuton/readme/readme.rb +40 -42
  76. data/lib/teuton/report/close.rb +1 -8
  77. data/lib/teuton/report/formatter/array_formatter.rb +28 -39
  78. data/lib/teuton/report/formatter/base_formatter.rb +2 -13
  79. data/lib/teuton/report/formatter/csv_formatter.rb +12 -18
  80. data/lib/teuton/report/formatter/formatter_factory.rb +31 -29
  81. data/lib/teuton/report/formatter/html_formatter.rb +37 -21
  82. data/lib/teuton/report/formatter/json_formatter.rb +2 -8
  83. data/lib/teuton/report/formatter/list_formatter.rb +6 -12
  84. data/lib/teuton/report/formatter/moodle_csv_formatter.rb +3 -6
  85. data/lib/teuton/report/formatter/resume_array_formatter.rb +1 -1
  86. data/lib/teuton/report/formatter/resume_html_formatter.rb +29 -19
  87. data/lib/teuton/report/formatter/resume_json_formatter.rb +2 -3
  88. data/lib/teuton/report/formatter/resume_list_formatter.rb +4 -4
  89. data/lib/teuton/report/formatter/resume_txt_formatter.rb +14 -18
  90. data/lib/teuton/report/formatter/resume_yaml_formatter.rb +1 -9
  91. data/lib/teuton/report/formatter/txt_formatter.rb +19 -22
  92. data/lib/teuton/report/formatter/xml_formatter.rb +29 -37
  93. data/lib/teuton/report/formatter/yaml_formatter.rb +2 -12
  94. data/lib/teuton/report/report.rb +10 -10
  95. data/lib/teuton/report/show.rb +14 -33
  96. data/lib/teuton/skeleton.rb +6 -14
  97. data/lib/teuton/utils/configfile_reader.rb +22 -21
  98. data/lib/teuton/utils/name_file_finder.rb +21 -26
  99. data/lib/teuton/utils/verbose.rb +1 -2
  100. data/lib/teuton/version.rb +3 -4
  101. data/lib/teuton.rb +5 -6
  102. metadata +60 -86
  103. data/bin/check_teuton +0 -41
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../application'
4
- require_relative '../case_manager/case/result/result'
5
- require_relative 'show'
6
- require_relative 'dsl'
7
- require_relative 'builtin'
3
+ require_relative "../application"
4
+ require_relative "../case_manager/case/result/result"
5
+ require_relative "show"
6
+ require_relative "dsl"
7
+ require_relative "builtin"
8
8
 
9
9
  ##
10
10
  # DSL use: import filename instructions
11
11
  # @param filename (String)
12
12
  def use(filename)
13
- filename += '.rb'
13
+ filename += ".rb"
14
14
  app = Application.instance
15
- rbfiles = File.join(app.project_path, '**', filename)
15
+ rbfiles = File.join(app.project_path, "**", filename)
16
16
  files = Dir.glob(rbfiles)
17
17
  use = []
18
18
  files.sort.each { |f| use << f if f.include?(filename) }
@@ -24,7 +24,7 @@ end
24
24
  # @param name (String or Symbol)
25
25
  # @param block (Proc)
26
26
  def group(name, &block)
27
- Application.instance.groups << { name: name, block: block }
27
+ Application.instance.groups << {name: name, block: block}
28
28
  end
29
29
  alias task group
30
30
 
@@ -40,21 +40,19 @@ alias play start
40
40
  class Laboratory
41
41
  attr_reader :result
42
42
 
43
- ##
44
- # Initialize instance
45
43
  def initialize(script_path, config_path)
46
44
  @path = {}
47
- @path[:script] = script_path
48
- @path[:dirname] = File.dirname(script_path)
49
- @path[:filename] = File.basename(script_path, '.rb')
50
- @path[:config] = config_path
45
+ @path[:script] = script_path
46
+ @path[:dirname] = File.dirname(script_path)
47
+ @path[:filename] = File.basename(script_path, ".rb")
48
+ @path[:config] = config_path
51
49
  reset
52
50
  end
53
51
 
54
52
  def reset
55
53
  @result = Result.new
56
54
  @targetid = 0
57
- @stats = { groups: 0, targets: 0, uniques: 0, gets: 0, logs: 0, sets: 0 }
55
+ @stats = {groups: 0, targets: 0, uniques: 0, gets: 0, logs: 0, sets: 0}
58
56
  @gets = {}
59
57
  @sets = {}
60
58
  @hosts = {}
@@ -1,8 +1,8 @@
1
- require 'terminal-table'
2
- require 'rainbow'
1
+ require "terminal-table"
2
+ require "rainbow"
3
3
 
4
- require_relative '../application'
5
- require_relative '../utils/configfile_reader'
4
+ require_relative "../application"
5
+ require_relative "../utils/configfile_reader"
6
6
 
7
7
  # Laboratory
8
8
  # * show_dsl
@@ -41,7 +41,7 @@ class Laboratory
41
41
  groups = Application.instance.groups
42
42
  option = Application.instance.options
43
43
 
44
- verboseln ''
44
+ verboseln ""
45
45
  groups.each do |t|
46
46
  @stats[:groups] += 1
47
47
  unless option[:panel]
@@ -58,14 +58,14 @@ class Laboratory
58
58
  @hosts.each_key do |k|
59
59
  next if k == :localhost
60
60
 
61
- if k.class == Symbol
62
- script_vars << (k.to_s + '_ip').to_sym
63
- script_vars << (k.to_s + '_username').to_sym
64
- script_vars << (k.to_s + '_password').to_sym
61
+ if k.instance_of? Symbol
62
+ script_vars << (k.to_s + "_ip").to_sym
63
+ script_vars << (k.to_s + "_username").to_sym
64
+ script_vars << (k.to_s + "_password").to_sym
65
65
  else
66
- script_vars << k.to_s + '_ip'
67
- script_vars << k.to_s + '_username'
68
- script_vars << k.to_s + '_password'
66
+ script_vars << k.to_s + "_ip"
67
+ script_vars << k.to_s + "_username"
68
+ script_vars << k.to_s + "_password"
69
69
  end
70
70
  end
71
71
  @gets.each_key { |k| script_vars << k }
@@ -73,29 +73,27 @@ class Laboratory
73
73
  end
74
74
 
75
75
  def recomended_config_content
76
- verbose Rainbow('[WARN] File ').yellow
76
+ verbose Rainbow("[WARN] File ").yellow
77
77
  verbose Rainbow(@path[:config]).yellow.bright
78
- verboseln Rainbow(' not found!').yellow
79
- verboseln '[INFO] Recomended content:'
80
- output = { global: nil, cases: [] }
78
+ verboseln Rainbow(" not found!").yellow
79
+ verboseln "[INFO] Recomended content:"
80
+ output = {global: nil, cases: []}
81
81
  output[:cases][0] = {}
82
82
  script_vars = find_script_vars
83
- script_vars.each { |i| output[:cases][0][i] = 'VALUE' }
83
+ script_vars.each { |i| output[:cases][0][i] = "VALUE" }
84
84
  verboseln YAML.dump(output)
85
85
  end
86
86
 
87
87
  def recomended_panelconfig_content
88
- output = { global: {}, cases: nil }
88
+ output = {global: {}, cases: nil}
89
89
  script_vars = find_script_vars
90
- script_vars.each { |i| output[:global][i] = 'VALUE' }
90
+ script_vars.each { |i| output[:global][i] = "VALUE" }
91
91
  verboseln YAML.dump(output)
92
92
  end
93
93
 
94
- ##
95
- # Revive and check config content
96
94
  def revise_config_content
97
95
  my_screen_table = Terminal::Table.new do |st|
98
- st.add_row ['Revising CONFIG file']
96
+ st.add_row ["Revising CONFIG file"]
99
97
  end
100
98
  verboseln my_screen_table
101
99
 
@@ -119,13 +117,13 @@ class Laboratory
119
117
  script_vars.each do |value|
120
118
  next unless item[value].nil?
121
119
 
122
- next unless @sets[':' + value.to_s].nil?
120
+ next unless @sets[":" + value.to_s].nil?
123
121
 
124
- verbose Rainbow(' * Define ').red
122
+ verbose Rainbow(" * Define ").red
125
123
  verbose Rainbow(value).red.bright
126
- verbose Rainbow(' value for Case[').red
124
+ verbose Rainbow(" value for Case[").red
127
125
  verbose Rainbow(index).red.bright
128
- verboseln Rainbow('] or set tt_skip = true').red
126
+ verboseln Rainbow("] or set tt_skip = true").red
129
127
  end
130
128
  end
131
129
  end
@@ -137,23 +135,23 @@ class Laboratory
137
135
  @hosts.each_pair { |_k, v| @stats[:hosts] += v }
138
136
 
139
137
  my_screen_table = Terminal::Table.new do |st|
140
- st.add_row ['DSL Stats', 'Count']
138
+ st.add_row ["DSL Stats", "Count"]
141
139
  st.add_separator
142
- st.add_row ['Groups', @stats[:groups]]
143
- st.add_row ['Targets', @stats[:targets]]
144
- st.add_row ['Goto', @stats[:hosts]]
140
+ st.add_row ["Groups", @stats[:groups]]
141
+ st.add_row ["Targets", @stats[:targets]]
142
+ st.add_row ["Goto", @stats[:hosts]]
145
143
  @hosts.each_pair { |k, v| st.add_row [" * #{k}", v] }
146
- st.add_row ['Uniques', @stats[:uniques]]
147
- st.add_row ['Logs', @stats[:uniques]]
148
- st.add_row [' ', ' ']
144
+ st.add_row ["Uniques", @stats[:uniques]]
145
+ st.add_row ["Logs", @stats[:uniques]]
146
+ st.add_row [" ", " "]
149
147
 
150
- st.add_row ['Gets', @stats[:gets]]
148
+ st.add_row ["Gets", @stats[:gets]]
151
149
  if @gets.count > 0
152
150
  list = @gets.sort_by { |_k, v| v }
153
151
  list.reverse_each { |item| st.add_row [" * #{item[0]}", item[1].to_s] }
154
152
  end
155
153
 
156
- st.add_row ['Sets', @stats[:sets]]
154
+ st.add_row ["Sets", @stats[:sets]]
157
155
  if @sets.count > 0
158
156
  @sets.each_pair { |k, v| st.add_row [" * #{k}", v.to_s] }
159
157
  end
data/lib/teuton/cli.rb CHANGED
@@ -1,19 +1,12 @@
1
-
2
- require 'thor'
3
- require_relative 'version'
4
- require_relative '../teuton'
1
+ require "thor"
2
+ require_relative "version"
3
+ require_relative "../teuton"
5
4
 
6
5
  class CLI < Thor
7
- map ['h', '-h', '--help'] => 'help'
6
+ map ["h", "-h", "--help"] => "help"
8
7
 
9
- map ['v', '-v', '--version'] => 'version'
10
- desc 'version', 'Show the program version'
11
- def version
12
- puts "#{Teuton::APPNAME} (version #{Teuton::VERSION})"
13
- end
14
-
15
- map ['n', '-n', '--new'] => 'new'
16
- desc 'new DIRECTORY', 'Create skeleton for a new project'
8
+ map ["n", "-n", "--new"] => "new"
9
+ desc "new DIRECTORY", "Create skeleton for a new project"
17
10
  long_desc <<-LONGDESC
18
11
  Create files for a new project.
19
12
  LONGDESC
@@ -21,12 +14,11 @@ class CLI < Thor
21
14
  Teuton.create(projectpath)
22
15
  end
23
16
 
24
- map ['c', '-c', '--check'] => 'check'
17
+ map ["c", "-c", "--check"] => "check"
25
18
  option :panelconfig, type: :boolean
26
19
  option :cname, type: :string
27
20
  option :cpath, type: :string
28
- desc 'check [OPTIONS] DIRECTORY',
29
- 'Check test and config file content'
21
+ desc "check [OPTIONS] DIRECTORY", "Check test and config file content"
30
22
  long_desc <<-LONGDESC
31
23
 
32
24
  (1) teuton check path/to/dir/foo
@@ -46,15 +38,31 @@ class CLI < Thor
46
38
  Teuton.check(projectpath, options)
47
39
  end
48
40
 
49
- map ['--run', 'run'] => 'play'
41
+ map ["--readme"] => "readme"
42
+ option :lang, type: :string
43
+ desc "readme DIRECTORY", "Show README extracted from test contents"
44
+ long_desc <<-LONGDESC
45
+
46
+ (1) teuton readme foo
47
+ , Create README.md from foo/start.rb.
48
+
49
+ (2) teuton readme foo/demo.rb
50
+ , Create README.md from foo/demo.rb.
51
+ LONGDESC
52
+
53
+ def readme(projectpath)
54
+ # Create README from teuton test
55
+ Teuton.readme(projectpath, options)
56
+ end
57
+
58
+ map ["--run", "run"] => "play"
50
59
  option :export, type: :string
51
60
  option :cname, type: :string
52
61
  option :cpath, type: :string
53
62
  option :case, type: :string
54
63
  option :color, type: :boolean
55
64
  option :quiet, type: :boolean
56
- desc '[run] [OPTIONS] DIRECTORY',
57
- 'Run test from directory'
65
+ desc "[run] [OPTIONS] DIRECTORY", "Run test from directory"
58
66
  long_desc <<-LONGDESC
59
67
  This function execute challenge from specified directory.
60
68
  By default, show progress on the screen.
@@ -77,22 +85,10 @@ class CLI < Thor
77
85
  Teuton.run(filepath, options)
78
86
  end
79
87
 
80
- map ['--readme'] => 'readme'
81
- option :lang, type: :string
82
- desc 'readme DIRECTORY',
83
- 'Show README extracted from test contents'
84
- long_desc <<-LONGDESC
85
-
86
- (1) teuton readme foo
87
- , Create README.md from foo/start.rb.
88
-
89
- (2) teuton readme foo/demo.rb
90
- , Create README.md from foo/demo.rb.
91
- LONGDESC
92
-
93
- def readme(projectpath)
94
- # Create README from teuton test
95
- Teuton.readme(projectpath, options)
88
+ map ["v", "-v", "--version"] => "version"
89
+ desc "version", "Show the program version"
90
+ def version
91
+ puts "#{Teuton::APPNAME} version #{Teuton::VERSION}"
96
92
  end
97
93
 
98
94
  ##
@@ -1,10 +1,7 @@
1
-
2
1
  group "GROUP NAME" do
3
-
4
- target "TARGET.1 DESCRIPTION"
5
- run "COMMAND.1"
6
- expect "TEXT.1"
7
-
2
+ target "TARGET_1 DESCRIPTION"
3
+ run "COMMAND_1"
4
+ expect "TEXT_1"
8
5
  end
9
6
 
10
7
  play do
@@ -20,7 +20,7 @@ class Readme
20
20
 
21
21
  def target(desc, args = {})
22
22
  previous_host = @action[:host]
23
- @action = { target: desc, host: previous_host, readme: [] }
23
+ @action = {target: desc, host: previous_host, readme: []}
24
24
  weight = 1.0
25
25
  weight = args[:weight].to_f if args[:weight]
26
26
  @action[:weight] = weight
@@ -54,7 +54,7 @@ class Readme
54
54
  @required_hosts[host.to_s] = b
55
55
  end
56
56
  @action[:host] = host
57
- @action[:exec] = args[:exec] || 'noexec'
57
+ @action[:exec] = args[:exec] || "noexec"
58
58
  end
59
59
 
60
60
  def run(command, args = {})
@@ -85,9 +85,15 @@ class Readme
85
85
  end
86
86
 
87
87
  # If a method call is missing, then delegate to concept parent.
88
- def method_missing(method)
89
- a = method.to_s
90
- instance_eval("get(:#{a[0, a.size - 1]})") if a[a.size - 1] == '?'
88
+ def method_missing(method, args = {})
89
+ m = method.to_s
90
+ if m[0] == "_"
91
+ instance_eval("get(:#{m[1, m.size - 1]})", __FILE__, __LINE__)
92
+ end
93
+ end
94
+
95
+ def respond_to_missing?(method_name, include_private = false)
96
+ true
91
97
  end
92
98
 
93
99
  def gett(value)
@@ -106,7 +112,7 @@ class Readme
106
112
  # don't do nothing
107
113
  end
108
114
 
109
- def log(text = '', type = :info)
115
+ def log(text = "", type = :info)
110
116
  @data[:logs] << "[#{type}]: " + text.to_s
111
117
  end
112
118
  end
@@ -1,30 +1,29 @@
1
-
2
- require_relative '../application'
1
+ require_relative "../application"
3
2
 
4
3
  module Lang
5
4
  def self.get(key)
6
5
  lang = {}
7
- lang['en'] = {
8
- version: 'Teuton version : %s',
9
- testname: 'Test unit name : %s',
10
- date: 'Date : %s',
11
- hosts: "\n\#\#\# Required hosts\n",
12
- params: "\n\#\#\# Required params\n",
13
- goto: "\nGo to [%s](\#required-hosts) host, and do next:\n",
14
- global: "\nGlobal parameters that can be modified:\n",
15
- created: "\nParams created during challenge execution:\n"
6
+ lang["en"] = {
7
+ version: "Teuton version : %s",
8
+ testname: "Test unit name : %s",
9
+ date: "Date : %s",
10
+ hosts: "\n\#\#\# Required hosts\n",
11
+ params: "\n\#\#\# Required params\n",
12
+ goto: "\nGo to [%s](\#required-hosts) host, and do next:\n",
13
+ global: "\nGlobal parameters that can be modified:\n",
14
+ created: "\nParams created during challenge execution:\n"
16
15
  }
17
- lang['es'] = {
18
- version: 'Versión de Teuton : %s',
19
- testname: 'Nombre del test : %s',
20
- date: 'Fecha : %s',
21
- hosts: "\n\#\#\# Máquinas que se necesitan\n",
22
- params: "\n\#\#\# Parámetros de necesarios\n",
23
- goto: "\nIr a la máquina [%s](\#required-hosts), y hacer lo siguiente:\n",
24
- global: "\nParámetros globales que pueden ser modificados:\n",
25
- created: "\nParámetros creados durante la ejecución del reto:\n"
16
+ lang["es"] = {
17
+ version: "Versión de Teuton : %s",
18
+ testname: "Nombre del test : %s",
19
+ date: "Fecha : %s",
20
+ hosts: "\n\#\#\# Máquinas que se necesitan\n",
21
+ params: "\n\#\#\# Parámetros de necesarios\n",
22
+ goto: "\nIr a la máquina [%s](\#required-hosts), y hacer lo siguiente:\n",
23
+ global: "\nParámetros globales que pueden ser modificados:\n",
24
+ created: "\nParámetros creados durante la ejecución del reto:\n"
26
25
  }
27
- locale = Application.instance.options['lang'].downcase
26
+ locale = Application.instance.options["lang"].downcase
28
27
  lang[locale][key]
29
28
  end
30
29
  end
@@ -1,14 +1,13 @@
1
-
2
- require_relative '../application'
3
- require_relative '../utils/configfile_reader'
4
- require_relative '../case_manager/case/result/result'
5
- require_relative 'dsl'
6
- require_relative 'lang'
1
+ require_relative "../application"
2
+ require_relative "../utils/configfile_reader"
3
+ require_relative "../case_manager/case/result/result"
4
+ require_relative "dsl"
5
+ require_relative "lang"
7
6
 
8
7
  def use(filename)
9
- filename += '.rb'
8
+ filename += ".rb"
10
9
  app = Application.instance
11
- rbfiles = File.join(app.project_path, '**', filename)
10
+ rbfiles = File.join(app.project_path, "**", filename)
12
11
  files = Dir.glob(rbfiles)
13
12
  use = []
14
13
  files.sort.each { |f| use << f if f.include?(filename) }
@@ -16,13 +15,14 @@ def use(filename)
16
15
  end
17
16
 
18
17
  def group(name, &block)
19
- Application.instance.groups << { name: name, block: block }
18
+ Application.instance.groups << {name: name, block: block}
20
19
  end
21
20
  alias task group
22
21
 
23
22
  def start(&block)
24
23
  # don't do nothing
25
24
  end
25
+ # alias_method "play", "start" # REVISE THIS
26
26
  alias play start
27
27
 
28
28
  # Creates README.md file from RB script file
@@ -36,10 +36,10 @@ class Readme
36
36
  # @param config_path (String) Path to main config file (config.yaml)
37
37
  def initialize(script_path, config_path)
38
38
  @path = {}
39
- @path[:script] = script_path
40
- @path[:dirname] = File.dirname(script_path)
41
- @path[:filename] = File.basename(script_path, '.rb')
42
- @path[:config] = config_path
39
+ @path[:script] = script_path
40
+ @path[:dirname] = File.dirname(script_path)
41
+ @path[:filename] = File.basename(script_path, ".rb")
42
+ @path[:config] = config_path
43
43
  reset
44
44
  end
45
45
 
@@ -70,7 +70,7 @@ class Readme
70
70
 
71
71
  def process_content
72
72
  Application.instance.groups.each do |g|
73
- @current = { name: g[:name], readme: [], actions: [] }
73
+ @current = {name: g[:name], readme: [], actions: []}
74
74
  @data[:groups] << @current
75
75
  reset_action
76
76
  instance_eval(&g[:block])
@@ -78,29 +78,29 @@ class Readme
78
78
  end
79
79
 
80
80
  def reset_action
81
- @action = { readme: [] }
81
+ @action = {readme: []}
82
82
  end
83
83
 
84
84
  def show_head
85
85
  app = Application.instance
86
- puts '```'
87
- puts format(Lang::get(:testname), app.test_name)
88
- puts format(Lang::get(:date), Time.now)
89
- puts format(Lang::get(:version), Application::VERSION)
90
- puts '```'
86
+ puts "```"
87
+ puts format(Lang.get(:testname), app.test_name)
88
+ puts format(Lang.get(:date), Time.now)
89
+ puts format(Lang.get(:version), Application::VERSION)
90
+ puts "```"
91
91
  puts "\n"
92
92
  puts "# #{app.test_name}\n"
93
93
 
94
94
  i = 1
95
95
  unless @required_hosts.empty?
96
- puts Lang::get(:hosts)
96
+ puts Lang.get(:hosts)
97
97
  puts "\n"
98
- puts '| ID | Host | Configuration |'
99
- puts '| --- | --- | --- |'
98
+ puts "| ID | Host | Configuration |"
99
+ puts "| --- | --- | --- |"
100
100
  @required_hosts.each_pair do |k, v|
101
101
  c = []
102
- v.each_pair { |k2,v2| c << "#{k2}=#{v2}" }
103
- puts "| #{i} | #{k.upcase} | #{c.join(', ')} |"
102
+ v.each_pair { |k2, v2| c << "#{k2}=#{v2}" }
103
+ puts "| #{i} | #{k.upcase} | #{c.join(", ")} |"
104
104
  i += 1
105
105
  end
106
106
  puts "\n> NOTE: SSH Service installation is required on every host."
@@ -108,8 +108,8 @@ class Readme
108
108
 
109
109
  unless @cases_params.empty?
110
110
  @cases_params.sort!
111
- puts Lang::get(:params)
112
- @cases_params.uniq.each { |i| puts format('* %s', i) }
111
+ puts Lang.get(:params)
112
+ @cases_params.uniq.each { |i| puts format("* %s", i) }
113
113
  puts "\n> NOTE: Save every 'param: value' into config file."
114
114
  end
115
115
  end
@@ -126,13 +126,13 @@ class Readme
126
126
  item[:host] = group[:actions][0][:host]
127
127
  end
128
128
  if previous_host.nil? || item[:host] != previous_host
129
- previous_host = item[:host] || 'null'
130
- puts format(Lang::get(:goto), previous_host.upcase)
129
+ previous_host = item[:host] || "null"
130
+ puts format(Lang.get(:goto), previous_host.upcase)
131
131
  end
132
132
 
133
- weight = ''
134
- weight = "(x#{item[:weight]}) " if item[:weight] != 1.0
135
- last = (item[:target].end_with?('.') ? '' : '.')
133
+ weight = ""
134
+ weight = "(x#{item[:weight]}) " if item[:weight].to_i != 1
135
+ last = (item[:target].end_with?(".") ? "" : ".")
136
136
  puts "* #{weight}#{item[:target]}#{last}"
137
137
  item[:readme].each { |line| puts " * #{line}\n" }
138
138
  end
@@ -142,21 +142,19 @@ class Readme
142
142
  def show_tail
143
143
  return if @global_params.empty?
144
144
 
145
- app = Application.instance
146
145
  puts "\n---"
147
146
  puts "# ANEXO"
148
147
  puts "\n\#\# Global params"
149
- puts Lang::get(:global)
148
+ puts Lang.get(:global)
150
149
  puts "\n"
151
- puts '| Global param | Value |'
152
- puts '| --- | --- |'
153
- @global_params.each_pair { |k,v| puts "|#{k}|#{v}|" }
150
+ puts "| Global param | Value |"
151
+ puts "| --- | --- |"
152
+ @global_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
154
153
  puts "\n\#\# Created params"
155
- puts Lang::get(:created)
154
+ puts Lang.get(:created)
156
155
  puts "\n"
157
- puts '| Created params | Value |'
158
- puts '| --- | --- |'
159
- @setted_params.each_pair { |k,v| puts "|#{k}|#{v}|" }
156
+ puts "| Created params | Value |"
157
+ puts "| --- | --- |"
158
+ @setted_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
160
159
  end
161
160
  end
162
-
@@ -1,6 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
- # Close Show methods for Report class.
4
1
  class Report
5
2
  ##
6
3
  # Calculate final values:
@@ -9,8 +6,6 @@ class Report
9
6
  # * good_weight,d
10
7
  # * fail_weight
11
8
  # * fail_counter
12
- # rubocop:disable Metrics/AbcSize
13
- # rubocop:disable Metrics/MethodLength
14
9
  def close
15
10
  app = Application.instance
16
11
  max = 0.0
@@ -18,7 +13,7 @@ class Report
18
13
  fail = 0.0
19
14
  fail_counter = 0
20
15
  @lines.each do |i|
21
- next unless i.class.to_s == 'Hash'
16
+ next unless i.instance_of? Hash
22
17
 
23
18
  max += i[:weight] if i[:weight].positive?
24
19
  if i[:check]
@@ -40,6 +35,4 @@ class Report
40
35
  @tail[:grade] = (100.0 * i).round
41
36
  @tail[:grade] = 0 if @tail[:unique_fault].positive?
42
37
  end
43
- # rubocop:enable Metrics/AbcSize
44
- # rubocop:enable Metrics/MethodLength
45
38
  end