teuton 2.7.3 → 2.9.0

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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/docs/changelog/changelog.1.md +119 -0
  4. data/docs/changelog/changelog.2.md +105 -0
  5. data/docs/diagram.md +10 -10
  6. data/docs/dsl/expect.md +76 -23
  7. data/docs/dsl/export.md +6 -3
  8. data/docs/dsl/result.md +24 -30
  9. data/docs/dsl/send.md +34 -23
  10. data/docs/learn/02-target.md +32 -27
  11. data/docs/learn/13-feedback.md +8 -9
  12. data/docs/learn/25-expect-result.md +39 -0
  13. data/docs/learn/26-expect_sequence.md +79 -0
  14. data/docs/learn/27-run_script.md +91 -0
  15. data/docs/learn/28-upload.md +55 -0
  16. data/docs/learn/README.md +4 -15
  17. data/docs/videos.md +14 -8
  18. data/lib/teuton/case/case.rb +3 -3
  19. data/lib/teuton/case/config.rb +0 -5
  20. data/lib/teuton/case/dsl/all.rb +5 -1
  21. data/lib/teuton/case/dsl/expect.rb +20 -33
  22. data/lib/teuton/case/dsl/expect_exitcode.rb +31 -0
  23. data/lib/teuton/case/dsl/expect_sequence.rb +173 -0
  24. data/lib/teuton/case/dsl/getset.rb +0 -1
  25. data/lib/teuton/case/dsl/host.rb +5 -0
  26. data/lib/teuton/case/dsl/macro.rb +7 -4
  27. data/lib/teuton/case/dsl/run_script.rb +35 -0
  28. data/lib/teuton/case/dsl/send.rb +3 -3
  29. data/lib/teuton/case/dsl/upload.rb +42 -0
  30. data/lib/teuton/case/dsl/weight.rb +12 -0
  31. data/lib/teuton/case/execute/execute_ssh.rb +11 -7
  32. data/lib/teuton/case/host.rb +68 -0
  33. data/lib/teuton/case/play.rb +2 -6
  34. data/lib/teuton/{utils → case}/result/ext_array.rb +0 -1
  35. data/lib/teuton/{utils → case}/result/ext_compare.rb +0 -1
  36. data/lib/teuton/{utils → case}/result/ext_filter.rb +0 -2
  37. data/lib/teuton/{utils → case}/result/result.rb +13 -21
  38. data/lib/teuton/check/checker.rb +82 -0
  39. data/lib/teuton/check/dsl/all.rb +37 -0
  40. data/lib/teuton/check/{builtin.rb → dsl/builtin.rb} +1 -3
  41. data/lib/teuton/check/dsl/expect.rb +90 -0
  42. data/lib/teuton/check/dsl/expect_sequence.rb +29 -0
  43. data/lib/teuton/check/dsl/getset.rb +23 -0
  44. data/lib/teuton/check/dsl/run.rb +35 -0
  45. data/lib/teuton/check/main.rb +29 -0
  46. data/lib/teuton/check/show.rb +75 -100
  47. data/lib/teuton/{utils → deprecated}/application.rb +0 -6
  48. data/lib/teuton/deprecated/application_test.rb +32 -0
  49. data/lib/teuton/readme/dsl/all.rb +32 -0
  50. data/lib/teuton/readme/dsl/expect.rb +29 -0
  51. data/lib/teuton/readme/dsl/getset.rb +33 -0
  52. data/lib/teuton/readme/dsl/run.rb +51 -0
  53. data/lib/teuton/readme/lang.rb +8 -10
  54. data/lib/teuton/readme/main.rb +27 -0
  55. data/lib/teuton/readme/readme.rb +31 -58
  56. data/lib/teuton/readme/result.rb +7 -0
  57. data/lib/teuton/report/formatter/default/txt.rb +2 -2
  58. data/lib/teuton/utils/configfile_reader.rb +8 -4
  59. data/lib/teuton/utils/logger.rb +32 -0
  60. data/lib/teuton/utils/verbose.rb +1 -1
  61. data/lib/teuton/version.rb +1 -1
  62. data/lib/teuton.rb +6 -5
  63. metadata +45 -37
  64. data/docs/CHANGELOG.md +0 -10
  65. data/docs/changelog/v2.0.md +0 -18
  66. data/docs/changelog/v2.1.md +0 -54
  67. data/docs/changelog/v2.2.md +0 -42
  68. data/docs/changelog/v2.3.md +0 -10
  69. data/docs/changelog/v2.4.md +0 -41
  70. data/docs/changelog/v2.5.md +0 -6
  71. data/docs/changelog/v2.6.md +0 -4
  72. data/docs/changelog/v2.7.md +0 -23
  73. data/docs/changelog/version2.1.md +0 -4
  74. data/docs/learn/videos.md +0 -13
  75. data/lib/teuton/case/execute/copy_ssh.rb +0 -70
  76. data/lib/teuton/check/dsl.rb +0 -112
  77. data/lib/teuton/check/laboratory.rb +0 -59
  78. data/lib/teuton/readme/dsl.rb +0 -126
  79. /data/lib/teuton/case/dsl/{goto.rb → run.rb} +0 -0
  80. /data/lib/teuton/{case/deprecated → deprecated}/runner.rb +0 -0
  81. /data/lib/teuton/{case/deprecated → deprecated}/utils.rb +0 -0
@@ -16,9 +16,7 @@ class Builtin
16
16
  end
17
17
  end
18
18
 
19
- # Laboratory
20
- # * service
21
- class Laboratory
19
+ module CheckDSL
22
20
  def service(param)
23
21
  log "BUILTIN service(#{param})"
24
22
  @builtin ||= Builtin.new(self)
@@ -0,0 +1,90 @@
1
+ require_relative "expect_sequence"
2
+
3
+ module CheckDSL
4
+ def expect(cond)
5
+ unless @target_begin
6
+ Logger.warn "WARN 'expect' with no previous 'target'"
7
+ end
8
+ Logger.info " alter #{result.alterations}" unless result.alterations.empty?
9
+ Logger.info " expect #{cond} (#{cond.class})"
10
+ Logger.info ""
11
+ @target_begin = false
12
+ end
13
+
14
+ def expect_exit(cond)
15
+ unless @target_begin
16
+ Logger.warn "WARN 'expect' with no previous 'target'"
17
+ end
18
+ Logger.info " expect_exit #{cond} (#{cond.class})"
19
+ Logger.info ""
20
+ @target_begin = false
21
+ end
22
+
23
+ def expect_fail
24
+ unless @target_begin
25
+ Logger.warn "WARN 'expect' with no previous 'target'"
26
+ end
27
+ Logger.info " expect_fail"
28
+ Logger.info ""
29
+ @target_begin = false
30
+ end
31
+
32
+ def expect_first(cond)
33
+ unless @target_begin
34
+ Logger.warn "WARN 'expect' with no previous 'target'"
35
+ end
36
+ Logger.info " alter #{result.alterations}" unless result.alterations.empty?
37
+ Logger.info " expect_first #{cond} (#{cond.class})"
38
+ Logger.info ""
39
+ @target_begin = false
40
+ end
41
+
42
+ def expect_last(cond)
43
+ unless @target_begin
44
+ Logger.warn "WARN 'expect' with no previous 'target'"
45
+ end
46
+ Logger.info " alter #{result.alterations}" unless result.alterations.empty?
47
+ Logger.info " expect_last #{cond} (#{cond.class})"
48
+ Logger.info ""
49
+ @target_begin = false
50
+ end
51
+
52
+ def expect_none(cond = nil, args = {})
53
+ unless @target_begin
54
+ Logger.warn "WARN 'expect' with no previous 'target'"
55
+ end
56
+ Logger.info " alter #{result.alterations}" unless result.alterations.empty?
57
+ Logger.info " expect_none #{cond} (#{cond.class})"
58
+ Logger.info ""
59
+ @target_begin = false
60
+ end
61
+
62
+ def expect_nothing
63
+ expect_none nil, {}
64
+ end
65
+
66
+ def expect_ok
67
+ expect_exit 0
68
+ end
69
+
70
+ def expect_one(cond)
71
+ unless @target_begin
72
+ Logger.warn "WARN 'expect' with no previous 'target'"
73
+ end
74
+ Logger.info " alter #{result.alterations}" unless result.alterations.empty?
75
+ Logger.info " expect_one #{cond} (#{cond.class})"
76
+ Logger.info ""
77
+ @target_begin = false
78
+ end
79
+
80
+ def expect_sequence(&block)
81
+ unless @target_begin
82
+ Logger.warn "WARN 'expect' with no previous 'target'"
83
+ end
84
+ seq = CheckDSL::ExpectSequence.new
85
+ seq.is_valid?(&block)
86
+ Logger.info " expect_sequence #{seq.expected}"
87
+ Logger.info ""
88
+ @target_begin = false
89
+ end
90
+ end
@@ -0,0 +1,29 @@
1
+ module CheckDSL
2
+ class ExpectSequence
3
+ def initialize
4
+ @expected = []
5
+ end
6
+
7
+ def is_valid?(&block)
8
+ instance_eval(&block)
9
+ end
10
+
11
+ def expected
12
+ @expected.join(">")
13
+ end
14
+
15
+ private
16
+
17
+ def find(value)
18
+ @expected << "find(#{value})"
19
+ end
20
+
21
+ def next_to(value)
22
+ @expected << "next_to(#{value})"
23
+ end
24
+
25
+ def ignore(value)
26
+ @expected << "ignore(#{value})"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ module CheckDSL
2
+ def get(varname)
3
+ data = @stats[:gets]
4
+ data[varname] = data[varname] ? (data[varname] + 1) : 1
5
+ "get(#{varname})"
6
+ end
7
+
8
+ def gett(option)
9
+ get(option)
10
+ end
11
+
12
+ def set(key, value)
13
+ key = ":" + key.to_s if key.instance_of? Symbol
14
+ value = ":" + value.to_s if value.instance_of? Symbol
15
+
16
+ @stats[:sets] << "#{key}=#{value}"
17
+ Logger.info " set(#{key},#{value})"
18
+ end
19
+
20
+ def unset(key)
21
+ Logger.info " unset(#{key})"
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ module CheckDSL
2
+ def run(command, args = {})
3
+ args[:exec] = command
4
+ host = :localhost
5
+ host = args[:on] if args[:on]
6
+ goto(host, args)
7
+ end
8
+
9
+ def run_script(command, args = {})
10
+ host = :localhost
11
+ host = args[:on] if args[:on]
12
+ filename = command.split[1]
13
+ upload filename, to: host
14
+ run command, args
15
+ end
16
+
17
+ def goto(host = :localhost, args = {})
18
+ result.reset
19
+ @stats[:hosts][host] = @stats[:hosts][host] ? (@stats[:hosts][host] + 1) : 1
20
+ Logger.info " run '#{args[:exec]}' on #{host}"
21
+ end
22
+
23
+ def upload(filename, args = {})
24
+ host = args[:to]
25
+ args.delete(:to)
26
+ custom = if args == {}
27
+ ""
28
+ else
29
+ values = args.map { "#{_1}=#{_2}" }
30
+ "and #{values.join(",")}"
31
+ end
32
+ @stats[:uploads] << filename
33
+ Logger.info " upload '#{filename}' to #{host} #{custom}"
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../utils/project"
4
+
5
+ def use(filename)
6
+ filename += ".rb"
7
+ rbfiles = File.join(Project.value[:project_path], "**", filename)
8
+ files = Dir.glob(rbfiles)
9
+ use = []
10
+ files.sort.each { |f| use << f if f.include?(filename) }
11
+ require_relative use[0]
12
+ Project.value[:uses] << use[0]
13
+ end
14
+
15
+ def group(name, &block)
16
+ Project.value[:groups] << {name: name, block: block}
17
+ end
18
+ alias task group
19
+
20
+ def define_macro(name, *args, &block)
21
+ Project.value[:macros][name] = {args: args, block: block}
22
+ end
23
+ alias def_macro define_macro
24
+ alias defmacro define_macro
25
+
26
+ def start(&block)
27
+ # Don't do nothing. We are checking test not running it
28
+ end
29
+ alias play start
@@ -1,91 +1,29 @@
1
1
  require "terminal-table"
2
2
  require "rainbow"
3
3
 
4
+ require_relative "../utils/logger"
4
5
  require_relative "../utils/project"
5
6
  require_relative "../utils/configfile_reader"
6
7
 
7
- class Laboratory
8
- def show
9
- @verbose = true
10
- process_content
11
- show_stats
12
- revise_config_content
8
+ class ShowCheck
9
+ def initialize(stats:, path:)
10
+ @stats = stats
11
+ @path = path
13
12
  end
14
13
 
15
- def show_onlyconfig
16
- @verbose = false
17
- process_content
18
- @verbose = true
19
- recomended_panelconfig_content
20
- end
21
-
22
- private
23
-
24
- def verbose(text)
25
- print text if @verbose
26
- end
27
-
28
- def verboseln(text)
29
- puts text if @verbose
30
- end
31
-
32
- def process_content
33
- groups = Project.value[:groups]
34
- option = Project.value[:options]
35
- @stats[:uses] = Project.value[:uses].size
36
- verboseln ""
37
- groups.each do |t|
38
- @stats[:groups] += 1
39
- unless option[:panel]
40
- msg = "GROUP: #{t[:name]}"
41
- my_screen_table = Terminal::Table.new { |st| st.add_row [msg] }
42
- verboseln my_screen_table
43
- end
44
- instance_eval(&t[:block])
45
- end
46
- end
47
-
48
- def find_script_vars
49
- script_vars = [:tt_members]
50
- @hosts.each_key do |k|
51
- next if k == :localhost
52
-
53
- if k.instance_of? Symbol
54
- script_vars << (k.to_s + "_ip").to_sym
55
- script_vars << (k.to_s + "_username").to_sym
56
- script_vars << (k.to_s + "_password").to_sym
57
- else
58
- script_vars << k.to_s + "_ip"
59
- script_vars << k.to_s + "_username"
60
- script_vars << k.to_s + "_password"
61
- end
62
- end
63
- @gets.each_key { |k| script_vars << k }
64
- script_vars
65
- end
66
-
67
- def recomended_config_content
68
- warn Rainbow("[WARN] Configfile not found").bright.yellow
69
- warn Rainbow(" #{@path[:config]}").white
70
- warn Rainbow("[INFO] Recomended content:").bright.yellow
71
- output = {global: nil, cases: []}
72
- output[:cases][0] = {}
73
- script_vars = find_script_vars
74
- script_vars.each { |i| output[:cases][0][i] = "VALUE" }
75
- verboseln Rainbow(YAML.dump(output)).white
76
- end
77
-
78
- def recomended_panelconfig_content
79
- output = {global: nil, cases: [{}]}
14
+ def suggest_config_content
15
+ output = {"global" => nil, "cases" => [{}]}
80
16
  script_vars = find_script_vars
81
- # script_vars.each { |i| output[:global][i] = "VALUE" }
82
- script_vars.each { |i| output[:cases][0][i] = "VALUE" }
83
- verboseln YAML.dump(output)
17
+ script_vars.each { |i| output["cases"][0][i.to_s] = "VALUE" }
18
+ Logger.info YAML.dump(output)
84
19
  end
85
20
 
86
21
  def revise_config_content
87
22
  unless File.exist?(@path[:config])
88
- recomended_config_content
23
+ Logger.warn "[WARN] Configfile not found"
24
+ Logger.debug " #{@path[:config]}"
25
+ Logger.warn "[INFO] Recomended content:"
26
+ suggest_config_content
89
27
  return
90
28
  end
91
29
 
@@ -100,46 +38,83 @@ class Laboratory
100
38
  script_vars.each do |value|
101
39
  next unless item[value].nil?
102
40
 
103
- next unless @sets[":" + value.to_s].nil?
41
+ setted = false
42
+ @stats[:sets].each do |assign|
43
+ setted = true if assign.include?(":#{value}=")
44
+ end
104
45
 
105
- verbose Rainbow(" * Define ").red
106
- verbose Rainbow(value).red.bright
107
- verbose Rainbow(" value for Case[").red
108
- verbose Rainbow(index).red.bright
109
- verboseln Rainbow("] or set tt_skip = true").red
46
+ unless setted
47
+ text = " * Define '#{value}' value for Case[#{index}] or set tt_skip = true"
48
+ Logger.error text
49
+ end
110
50
  end
111
51
  end
112
52
  end
113
53
 
114
- ##
115
- # Display stats on screen
116
54
  def show_stats
117
- @stats[:hosts] = 0
118
- @hosts.each_pair { |_k, v| @stats[:hosts] += v }
119
-
120
55
  my_screen_table = Terminal::Table.new do |st|
121
56
  st.add_row ["DSL Stats", "Count"]
122
57
  st.add_separator
123
- st.add_row ["Uses", @stats[:uses]]
58
+
59
+ if Project.value[:uses].size.positive?
60
+ st.add_row ["Uses", Project.value[:uses].size]
61
+ end
62
+ if Project.value[:macros].size.positive?
63
+ st.add_row ["Macros", Project.value[:macros].size]
64
+ Project.value[:macros].each_key { st.add_row ["", _1] }
65
+ end
124
66
  st.add_row ["Groups", @stats[:groups]]
125
67
  st.add_row ["Targets", @stats[:targets]]
126
- st.add_row ["Runs", @stats[:hosts]]
127
- @hosts.each_pair { |k, v| st.add_row [" * #{k}", v] }
128
- st.add_row ["Uniques", @stats[:uniques]]
129
- st.add_row ["Logs", @stats[:uniques]]
130
- st.add_row [" ", " "]
131
-
132
- st.add_row ["Gets", @stats[:gets]]
133
- if @gets.count > 0
134
- list = @gets.sort_by { |_k, v| v }
68
+ runs = @stats[:hosts].values.inject(0) { |acc, item| acc + item }
69
+ st.add_row ["Runs", runs]
70
+ @stats[:hosts].each_pair { |k, v| st.add_row [" * #{k}", v] }
71
+ if @stats[:uniques].positive?
72
+ st.add_row ["Uniques", @stats[:uniques]]
73
+ end
74
+ if @stats[:logs].positive?
75
+ st.add_row ["Logs", @stats[:logs]]
76
+ end
77
+ if @stats[:readmes].positive?
78
+ st.add_row ["Readmes", @stats[:readmes]]
79
+ end
80
+
81
+ if @stats[:gets].size.positive?
82
+ total = @stats[:gets].values.inject(0) { |acc, value| acc + value }
83
+ st.add_row ["Gets", total]
84
+ list = @stats[:gets].sort_by { |_k, v| v }
135
85
  list.reverse_each { |item| st.add_row [" * #{item[0]}", item[1].to_s] }
136
86
  end
137
87
 
138
- st.add_row ["Sets", @stats[:sets]]
139
- if @sets.count > 0
140
- @sets.each_pair { |k, v| st.add_row [" * #{k}", v.to_s] }
88
+ if @stats[:sets].size.positive?
89
+ st.add_row ["Sets", @stats[:sets].size]
90
+ @stats[:sets].each { st.add_row ["", _1] }
91
+ end
92
+ if @stats[:uploads].size.positive?
93
+ st.add_row ["Uploads", @stats[:uploads].size]
94
+ @stats[:uploads].each { st.add_row ["", _1] }
95
+ end
96
+ end
97
+ Logger.info my_screen_table.to_s + "\n"
98
+ end
99
+
100
+ private
101
+
102
+ def find_script_vars
103
+ script_vars = [:tt_members]
104
+ @stats[:hosts].each_key do |k|
105
+ next if k == :localhost
106
+
107
+ if k.instance_of? Symbol
108
+ script_vars << (k.to_s + "_ip").to_sym
109
+ script_vars << (k.to_s + "_username").to_sym
110
+ script_vars << (k.to_s + "_password").to_sym
111
+ else
112
+ script_vars << k.to_s + "_ip"
113
+ script_vars << k.to_s + "_username"
114
+ script_vars << k.to_s + "_password"
141
115
  end
142
116
  end
143
- verboseln my_screen_table.to_s + "\n"
117
+ @stats[:gets].keys.each { script_vars << _1 }
118
+ script_vars
144
119
  end
145
120
  end
@@ -11,10 +11,7 @@ class Application
11
11
  attr_accessor :verbose
12
12
  attr_accessor :global # Global configuration params
13
13
  attr_accessor :ialias # Internal alias
14
- attr_accessor :macros # Array of macros
15
- attr_accessor :groups # Array of groups
16
14
  attr_accessor :uses # Array of uses
17
- attr_accessor :hall_of_fame
18
15
  attr_accessor :project_path, :script_path, :config_path, :test_name
19
16
 
20
17
  def initialize
@@ -42,10 +39,7 @@ class Application
42
39
 
43
40
  @global = {}
44
41
  @ialias = {}
45
- @macros = {}
46
- @groups = []
47
42
  @uses = [] # TODO
48
- @hall_of_fame = []
49
43
  end
50
44
 
51
45
  def debug
@@ -0,0 +1,32 @@
1
+ require "test/unit"
2
+ require_relative "../../lib/teuton/utils/application"
3
+
4
+ class ApplicationTest < Test::Unit::TestCase
5
+ def setup
6
+ @app = Application.instance
7
+ @app.reset
8
+ end
9
+
10
+ def test_init_params
11
+ assert_equal ".", @app.letter[:good]
12
+ assert_equal "F", @app.letter[:bad]
13
+ assert_equal "?", @app.letter[:error]
14
+ assert_equal " ", @app.letter[:none]
15
+ assert_equal "var", @app.output_basedir
16
+ assert_equal false, @app.debug
17
+ assert_equal true, @app.verbose
18
+
19
+ assert_equal true, @app.global == {}
20
+ end
21
+
22
+ def test_quiet?
23
+ @app.verbose = false
24
+ assert_equal false, @app.verbose
25
+ assert_equal true, Application.instance.quiet?
26
+ @app.verbose = true
27
+ assert_equal true, @app.verbose
28
+ assert_equal false, Application.instance.quiet?
29
+ @app.options["quiet"] = true
30
+ assert_equal true, Application.instance.quiet?
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "expect"
4
+ require_relative "getset"
5
+ require_relative "run"
6
+
7
+ module ReadmeDSL
8
+ def readme(text)
9
+ if @action[:target].nil?
10
+ @current[:readme] << text # It's a group readme
11
+ else
12
+ @action[:readme] << text # It's a target readme
13
+ end
14
+ end
15
+
16
+ def target(desc, args = {})
17
+ previous_host = @action[:host]
18
+ @action = {target: desc, host: previous_host, readme: []}
19
+ weight = 1.0
20
+ weight = args[:weight].to_f if args[:weight]
21
+ @action[:weight] = weight
22
+ end
23
+ alias_method :goal, :target
24
+
25
+ def unique(_key, _value)
26
+ # Nothing to do
27
+ end
28
+
29
+ def log(text = "", type = :info)
30
+ # Nothing to do
31
+ end
32
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ReadmeDSL
4
+ def expect(_cond, _args = {})
5
+ @current[:actions] << @action
6
+ result.reset
7
+ end
8
+ alias_method :expect_any, :expect
9
+ alias_method :expect_exit, :expect
10
+ alias_method :expect_first, :expect
11
+ alias_method :expect_last, :expect
12
+ alias_method :expect_one, :expect
13
+
14
+ def expect_fail
15
+ @current[:actions] << @action
16
+ result.reset
17
+ end
18
+ alias_method :expect_ok, :expect_fail
19
+
20
+ def expect_none(cond = nil)
21
+ expect(cond)
22
+ end
23
+ alias_method :expect_nothing, :expect_none
24
+
25
+ def expect_sequence(&block)
26
+ @current[:actions] << @action
27
+ result.reset
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ module ReadmeDSL
2
+ def get(value)
3
+ unless @config[:global][value].nil?
4
+ @global_params[value] = @config[:global][value]
5
+ return @config[:global][value]
6
+ end
7
+
8
+ return value.to_s.upcase if @setted_params.include? value
9
+
10
+ @cases_params << value
11
+ value.to_s.upcase
12
+ end
13
+
14
+ def gett(value)
15
+ a = get(value)
16
+ if @cases_params.include? value
17
+ "[#{value}](#required-params)"
18
+ elsif @setted_params[value]
19
+ "[#{value}](#created-params)"
20
+ elsif @global_params.include? value
21
+ "[#{a}](#global-params)"
22
+ end
23
+ a
24
+ end
25
+
26
+ def set(key, value)
27
+ @setted_params[key] = value
28
+ end
29
+
30
+ def unset(_key)
31
+ # Nothing to do
32
+ end
33
+ end
@@ -0,0 +1,51 @@
1
+ module ReadmeDSL
2
+ def goto(host = :localhost, args = {})
3
+ unless host == :localhost
4
+ b = {}
5
+ a = "#{host}_ip".to_sym
6
+ if @config[:global][a].nil? && !@setted_params.include?(a)
7
+ @cases_params << a
8
+ end
9
+ b[:ip] = @config[:global][a] if @config[:global][a]
10
+ b[:ip] = @setted_params[a] if @setted_params[a]
11
+
12
+ a = "#{host}_username".to_sym
13
+ if @config[:global][a].nil? && !@setted_params.include?(a)
14
+ @cases_params << a
15
+ end
16
+ b[:username] = @config[:global][a] if @config[:global][a]
17
+ b[:username] = @setted_params[a] if @setted_params[a]
18
+
19
+ a = "#{host}_password".to_sym
20
+ if @config[:global][a].nil? && !@setted_params.include?(a)
21
+ @cases_params << a
22
+ end
23
+ b[:password] = @config[:global][a] if @config[:global][a]
24
+ b[:password] = @setted_params[a] if @setted_params[a]
25
+
26
+ @required_hosts[host.to_s] = b
27
+ end
28
+ @action[:host] = host
29
+ @action[:exec] = args[:exec] || "noexec"
30
+ end
31
+
32
+ def run(command, args = {})
33
+ args[:exec] = command
34
+ host = :localhost
35
+ host = args[:on] if args[:on]
36
+ goto(host, args)
37
+ end
38
+
39
+ def run_script(command, args = {})
40
+ host = :localhost
41
+ host = args[:on] if args[:on]
42
+ filename = command.split[1]
43
+ upload filename, on: host
44
+ run command, args = {}
45
+ goto(host, args)
46
+ end
47
+
48
+ def upload(filename, args = {})
49
+ # Nothing to do
50
+ end
51
+ end
@@ -4,24 +4,22 @@ module Lang
4
4
  def self.get(key)
5
5
  lang = {}
6
6
  lang["en"] = {
7
- version: "Teuton version : %s",
8
- testname: "Test unit name : %s",
9
- date: "Date : %s",
7
+ version: "Teuton : %s",
8
+ date: "Date : %s",
10
9
  hosts: "\n### Required hosts\n",
11
10
  params: "\n### Required params\n",
12
11
  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"
12
+ global_params: "\nGlobal parameters:\n",
13
+ created_params: "\nCreated during execution:\n"
15
14
  }
16
15
  lang["es"] = {
17
- version: "Versión de Teuton : %s",
18
- testname: "Nombre del test : %s",
19
- date: "Fecha : %s",
16
+ version: "Teuton : %s",
17
+ date: "Fecha : %s",
20
18
  hosts: "\n### Máquinas que se necesitan\n",
21
19
  params: "\n### Parámetros de necesarios\n",
22
20
  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"
21
+ global_params: "\nParámetros globales que pueden ser modificados:\n",
22
+ created_params: "\nParámetros creados durante la ejecución del reto:\n"
25
23
  }
26
24
  # locale = Application.instance.options["lang"].downcase
27
25
  locale = Project.value[:options]["lang"].downcase