teuton 2.5.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/docs/CHANGELOG.md +2 -0
  3. data/docs/changelog/todo.md +4 -6
  4. data/docs/changelog/v2.6.md +4 -0
  5. data/docs/changelog/v2.7.md +11 -0
  6. data/docs/diagram.md +55 -0
  7. data/docs/learn/02-target.md +37 -12
  8. data/docs/learn/03-remote_hosts.md +1 -1
  9. data/docs/learn/04-config.md +1 -1
  10. data/docs/learn/06-cmd_check.md +4 -6
  11. data/docs/learn/07-target_weight.md +1 -3
  12. data/docs/learn/21-exit_codes.md +9 -16
  13. data/docs/learn/README.md +1 -1
  14. data/lib/teuton/case/case.rb +95 -0
  15. data/lib/teuton/{case_manager/case → case}/close.rb +2 -0
  16. data/lib/teuton/{case_manager/case → case}/config.rb +3 -3
  17. data/lib/teuton/{case_manager/case → case/deprecated}/runner.rb +14 -10
  18. data/lib/teuton/case/deprecated/utils.rb +40 -0
  19. data/lib/teuton/{case_manager/case/dsl/main.rb → case/dsl/all.rb} +0 -2
  20. data/lib/teuton/{case_manager/case → case}/dsl/expect.rb +25 -9
  21. data/lib/teuton/{case_manager/case → case}/dsl/goto.rb +10 -9
  22. data/lib/teuton/{case_manager/case → case}/dsl/log.rb +1 -2
  23. data/lib/teuton/{case_manager/case → case}/dsl/macro.rb +2 -2
  24. data/lib/teuton/{case_manager/case → case}/dsl/send.rb +3 -8
  25. data/lib/teuton/case/execute/execute_base.rb +55 -0
  26. data/lib/teuton/case/execute/execute_local.rb +29 -0
  27. data/lib/teuton/case/execute/execute_manager.rb +56 -0
  28. data/lib/teuton/case/execute/execute_ssh.rb +90 -0
  29. data/lib/teuton/case/execute/execute_telnet.rb +56 -0
  30. data/lib/teuton/{case_manager/case → case}/play.rb +11 -14
  31. data/lib/teuton/case_manager/case_manager.rb +20 -39
  32. data/lib/teuton/case_manager/check_cases.rb +14 -12
  33. data/lib/teuton/case_manager/dsl.rb +7 -9
  34. data/lib/teuton/case_manager/export_manager.rb +19 -6
  35. data/lib/teuton/case_manager/hall_of_fame.rb +9 -10
  36. data/lib/teuton/case_manager/report.rb +11 -9
  37. data/lib/teuton/case_manager/send_manager.rb +17 -0
  38. data/lib/teuton/{report/show.rb → case_manager/show_report.rb} +4 -6
  39. data/lib/teuton/case_manager/utils.rb +2 -43
  40. data/lib/teuton/check/dsl.rb +1 -2
  41. data/lib/teuton/check/laboratory.rb +7 -7
  42. data/lib/teuton/check/show.rb +5 -8
  43. data/lib/teuton/cli.rb +10 -0
  44. data/lib/teuton/readme/dsl.rb +5 -7
  45. data/lib/teuton/readme/lang.rb +3 -2
  46. data/lib/teuton/readme/readme.rb +15 -18
  47. data/lib/teuton/report/formatter/default/array.rb +6 -5
  48. data/lib/teuton/report/formatter/default/txt.rb +1 -0
  49. data/lib/teuton/report/formatter/resume/array.rb +3 -3
  50. data/lib/teuton/report/formatter/resume/html.rb +2 -2
  51. data/lib/teuton/report/report.rb +6 -5
  52. data/lib/teuton/skeleton.rb +8 -10
  53. data/lib/teuton/{application.rb → utils/application.rb} +13 -5
  54. data/lib/teuton/utils/name_file_finder.rb +40 -45
  55. data/lib/teuton/utils/project.rb +73 -0
  56. data/lib/teuton/{case_manager/case → utils}/result/ext_array.rb +5 -5
  57. data/lib/teuton/{case_manager/case → utils}/result/result.rb +10 -8
  58. data/lib/teuton/utils/settings.rb +12 -0
  59. data/lib/teuton/utils/verbose.rb +2 -2
  60. data/lib/teuton/version.rb +1 -1
  61. data/lib/teuton.rb +28 -27
  62. metadata +43 -30
  63. data/lib/teuton/case_manager/case/case.rb +0 -117
  64. data/lib/teuton/case_manager/case/main.rb +0 -7
  65. data/lib/teuton/case_manager/main.rb +0 -3
  66. /data/lib/teuton/{case_manager/case → case}/builtin/main.rb +0 -0
  67. /data/lib/teuton/{case_manager/case → case}/builtin/package.rb +0 -0
  68. /data/lib/teuton/{case_manager/case → case}/builtin/service.rb +0 -0
  69. /data/lib/teuton/{case_manager/case → case}/builtin/teuton_file.rb +0 -0
  70. /data/lib/teuton/{case_manager/case → case}/builtin/teuton_host.rb +0 -0
  71. /data/lib/teuton/{case_manager/case → case}/builtin/user.rb +0 -0
  72. /data/lib/teuton/{case_manager/case → case}/dsl/getset.rb +0 -0
  73. /data/lib/teuton/{case_manager/case → case}/dsl/target.rb +0 -0
  74. /data/lib/teuton/{case_manager/case → case}/dsl/unique.rb +0 -0
  75. /data/lib/teuton/{case_manager/case → utils}/result/ext_compare.rb +0 -0
  76. /data/lib/teuton/{case_manager/case → utils}/result/ext_filter.rb +0 -0
@@ -1,17 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../application"
3
+ require "rainbow"
4
4
 
5
- module ExportManager
5
+ ##
6
+ # Execute "export" order: Export every case report
7
+ # @param args (Hash) Export options
8
+ class ExportManager
6
9
  ##
7
10
  # Run export function
8
11
  # @param main_report (Report)
9
12
  # @param cases (Array)
10
13
  # @param input (Hash) Selected export options
11
- def self.run(main_report, cases, args)
14
+ def call(main_report, cases, args, default_format)
15
+ if args.class != Hash
16
+ puts Rainbow("[ERROR] Export argument error!").red
17
+ puts Rainbow(" Revise: export #{args}").red
18
+ puts Rainbow(" Use : export format: 'txt'").red
19
+ puts ""
20
+ exit 1
21
+ end
22
+
12
23
  options = strings2symbols(args)
13
24
  if options[:format].nil?
14
- options[:format] = Application.instance.default[:format]
25
+ options[:format] = default_format
15
26
  end
16
27
 
17
28
  # Step 1: Export case reports
@@ -26,10 +37,12 @@ module ExportManager
26
37
  preserve_files if options[:preserve] == true
27
38
  end
28
39
 
40
+ private
41
+
29
42
  ##
30
43
  # Convert Hash String values into Symbol values
31
44
  # @param input (Hash)
32
- private_class_method def self.strings2symbols(input)
45
+ def strings2symbols(input)
33
46
  args = {}
34
47
  input.each_pair do |key, value|
35
48
  args[key] = if value.instance_of? String
@@ -43,7 +56,7 @@ module ExportManager
43
56
 
44
57
  ##
45
58
  # Preserve output files for current project execution
46
- private_class_method def self.preserve_files
59
+ def preserve_files
47
60
  app = Application.instance
48
61
  t = Time.now
49
62
  data = {year: t.year, month: t.month, day: t.day, hour: t.hour, min: t.min, sec: t.sec}
@@ -1,4 +1,4 @@
1
- require_relative "../application"
1
+ require_relative "../utils/project"
2
2
 
3
3
  class CaseManager
4
4
  class HallOfFame
@@ -9,22 +9,21 @@ class CaseManager
9
9
  def call
10
10
  celebrities = {}
11
11
 
12
- @cases.each do |c|
13
- grade = c.grade # report.tail[:grade]
12
+ @cases.each do |acase|
13
+ next if acase.skip
14
+
15
+ grade = acase.grade
14
16
  label = if celebrities[grade]
15
17
  celebrities[grade] + "*"
16
18
  else
17
19
  "*"
18
20
  end
19
- celebrities[grade] = label unless c.skip
21
+ celebrities[grade] = label
20
22
  end
21
23
 
22
- a = celebrities.sort_by { |key, _value| key }
23
- list = a.reverse
24
-
25
- app = Application.instance
26
- app.options[:case_number] = @cases.size
27
- app.hall_of_fame = list
24
+ Project.value[:options][:case_number] = @cases.size
25
+ ordered_list = celebrities.sort_by { |key, _value| key }
26
+ Project.value[:hall_of_fame] = ordered_list.reverse
28
27
  end
29
28
  end
30
29
  end
@@ -1,4 +1,6 @@
1
1
  require "rainbow"
2
+ require_relative "../utils/project"
3
+ require_relative "../utils/settings"
2
4
 
3
5
  class CaseManager
4
6
  private
@@ -7,15 +9,15 @@ class CaseManager
7
9
  # Open main report (resume report)
8
10
  # @param config_filepath (String)
9
11
  def open_main_report(config_filepath)
10
- app = Application.instance
12
+ # app = Application.instance
11
13
 
12
14
  @report.head[:tt_title] = "Teuton (#{Teuton::VERSION})"
13
- @report.head[:tt_scriptname] = trim(app.script_path)
15
+ @report.head[:tt_scriptname] = trim(Project.value[:script_path])
14
16
  @report.head[:tt_configfile] = trim(config_filepath)
15
- @report.head[:tt_pwd] = app.running_basedir
17
+ @report.head[:tt_pwd] = Project.value[:running_basedir]
16
18
  @report.head[:tt_debug] = true if @debug
17
- # @report.head[:tt_uses] = app.uses.join(', ') # TO-REVISE
18
- @report.head.merge!(app.global)
19
+ @report.head[:tt_uses] = Project.value[:uses].join(", ") # TO-REVISE
20
+ @report.head.merge!(Project.value[:global])
19
21
  end
20
22
 
21
23
  def close_main_report(start_time)
@@ -29,7 +31,7 @@ class CaseManager
29
31
  verboseln Rainbow("-" * 36).green
30
32
  verboseln " "
31
33
 
32
- app = Application.instance
34
+ # app = Application.instance
33
35
  @cases.each do |c|
34
36
  line = {}
35
37
  if c.skip?
@@ -46,9 +48,9 @@ class CaseManager
46
48
  else
47
49
  line[:skip] = false
48
50
  line[:id] = format("%<id>02d", {id: c.id.to_i})
49
- line[:letter] = app.letter[:cross] if c.grade.zero?
50
- line[:letter] = app.letter[:error] if c.grade < 50.0
51
- line[:letter] = app.letter[:ok] if c.grade.to_i == 100
51
+ line[:letter] = Settings.letter[:cross] if c.grade.zero?
52
+ line[:letter] = Settings.letter[:error] if c.grade < 50.0
53
+ line[:letter] = Settings.letter[:ok] if c.grade.to_i == 100
52
54
  line[:grade] = c.grade.to_f
53
55
  line[:members] = c.members
54
56
  line[:conn_status] = c.conn_status
@@ -0,0 +1,17 @@
1
+ require "rainbow"
2
+
3
+ class SendManager
4
+ ##
5
+ # Execute "send" order: Send every case report
6
+ # @param args (Hash) Send options
7
+ def call(cases, args)
8
+ threads = []
9
+ puts ""
10
+ puts Rainbow("-" * 50).green
11
+ puts Rainbow("Sending files...#{args}").color(:green)
12
+ cases.each { |c| threads << Thread.new { c.send(args) } }
13
+ threads.each(&:join)
14
+ puts Rainbow("Sending finished!").color(:green)
15
+ puts Rainbow("-" * 50).green
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  require "rainbow"
2
2
  require "terminal-table"
3
- require_relative "../application"
3
+ require_relative "../utils/project"
4
4
 
5
5
  # | Verbosity level | Description |
6
6
  # | :-------------: | ----------- |
@@ -15,7 +15,7 @@ class ShowReport
15
15
  end
16
16
 
17
17
  def call(verbose)
18
- return if Application.instance.quiet?
18
+ return if Project.quiet?
19
19
 
20
20
  show_initial_configurations if verbose > 2
21
21
  if filename.to_s.include? "resume"
@@ -121,8 +121,7 @@ class ShowReport
121
121
  end
122
122
 
123
123
  def show_hall_of_fame
124
- app = Application.instance
125
- return if app.hall_of_fame.size < 3
124
+ return if Project.value[:hall_of_fame].size < 3
126
125
 
127
126
  puts Rainbow("HALL OF FAME").bright
128
127
  my_screen_table = Terminal::Table.new do |st|
@@ -133,9 +132,8 @@ class ShowReport
133
132
  puts "#{my_screen_table}\n"
134
133
  end
135
134
 
136
- ##
137
- # Trim absolute path values
138
135
  def trim(input)
136
+ # Trim absolute path values
139
137
  return input unless input.to_s.start_with? Dir.pwd.to_s
140
138
  return input if input == Dir.pwd.to_s
141
139
 
@@ -1,8 +1,9 @@
1
- require_relative "../application"
2
1
  require "fileutils"
2
+ require_relative "../utils/project"
3
3
 
4
4
  module Utils
5
5
  def ensure_dir(dirname)
6
+ # TODO: Mover a la carpeta Utils
6
7
  # Create the directory if it dosn't exist.
7
8
  unless Dir.exist?(dirname)
8
9
  FileUtils.mkdir_p(dirname)
@@ -10,46 +11,4 @@ module Utils
10
11
  end
11
12
  true
12
13
  end
13
-
14
- def encode_and_split(encoding, text)
15
- # Convert text to UTF-8 deleting unknown chars
16
- text ||= "" # Ensure text is not nil
17
- flag = [:default, "UTF-8"].include? encoding
18
- return text.encode("UTF-8", invalid: :replace).split("\n") if flag
19
-
20
- # Convert text from input ENCODING to UTF-8
21
- ec = Encoding::Converter.new(encoding.to_s, "UTF-8")
22
- begin
23
- text = ec.convert(text)
24
- rescue => e
25
- puts "[ERROR] #{e}: Declare text encoding..."
26
- puts " run 'command', on: :host, :encoding => 'ISO-8859-1'"
27
- end
28
-
29
- text.split("\n")
30
- end
31
-
32
- def my_execute(cmd, encoding = "UTF-8")
33
- return {exitstatus: 0, content: ""} if Application.instance.debug
34
-
35
- begin
36
- text = `#{cmd}`
37
- exitstatus = $CHILD_STATUS.exitstatus
38
- rescue => e
39
- verbose "!"
40
- puts("[ERROR] #{e}: Local exec: #{cmd}")
41
- end
42
- content = encode_and_split(encoding, text)
43
- {exitstatus: exitstatus, content: content}
44
- end
45
-
46
- def verboseln(text)
47
- verbose(text + "\n")
48
- end
49
-
50
- def verbose(text)
51
- return if Application.instance.quiet?
52
-
53
- print text
54
- end
55
14
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##
4
- # Include Teuton DSL keywords into Laboratory class
5
3
  class Laboratory
4
+ # Include Teuton DSL keywords into Laboratory class
6
5
  def readme(_text)
7
6
  # Usefull for "teuton readme" command action.
8
7
  end
@@ -1,28 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../application"
4
- require_relative "../case_manager/case/result/result"
3
+ require_relative "../utils/project"
4
+ require_relative "../utils/result/result"
5
5
  require_relative "show"
6
6
  require_relative "dsl"
7
7
  require_relative "builtin"
8
8
 
9
9
  def use(filename)
10
10
  filename += ".rb"
11
- app = Application.instance
12
- rbfiles = File.join(app.project_path, "**", filename)
11
+ rbfiles = File.join(Project.value[:project_path], "**", filename)
13
12
  files = Dir.glob(rbfiles)
14
13
  use = []
15
14
  files.sort.each { |f| use << f if f.include?(filename) }
16
15
  require_relative use[0]
16
+ Project.value[:uses] << use[0]
17
17
  end
18
18
 
19
19
  def group(name, &block)
20
- Application.instance.groups << {name: name, block: block}
20
+ Project.value[:groups] << {name: name, block: block}
21
21
  end
22
22
  alias task group
23
23
 
24
24
  def define_macro(name, *args, &block)
25
- Application.instance.macros[name] = {args: args, block: block}
25
+ Project.value[:macros][name] = {args: args, block: block}
26
26
  end
27
27
  alias def_macro define_macro
28
28
  alias defmacro define_macro
@@ -54,6 +54,6 @@ class Laboratory
54
54
  @sets = {}
55
55
  @hosts = {}
56
56
  @requests = [] # REVISE this
57
- @verbose = Application.instance.verbose
57
+ @verbose = Project.value[:verbose]
58
58
  end
59
59
  end
@@ -1,13 +1,9 @@
1
1
  require "terminal-table"
2
2
  require "rainbow"
3
3
 
4
- require_relative "../application"
4
+ require_relative "../utils/project"
5
5
  require_relative "../utils/configfile_reader"
6
6
 
7
- # Laboratory
8
- # * show_dsl
9
- # * show_stats
10
- # * show_config
11
7
  class Laboratory
12
8
  def show
13
9
  @verbose = true
@@ -34,9 +30,9 @@ class Laboratory
34
30
  end
35
31
 
36
32
  def process_content
37
- groups = Application.instance.groups
38
- option = Application.instance.options
39
-
33
+ groups = Project.value[:groups]
34
+ option = Project.value[:options]
35
+ @stats[:uses] = Project.value[:uses].size
40
36
  verboseln ""
41
37
  groups.each do |t|
42
38
  @stats[:groups] += 1
@@ -124,6 +120,7 @@ class Laboratory
124
120
  my_screen_table = Terminal::Table.new do |st|
125
121
  st.add_row ["DSL Stats", "Count"]
126
122
  st.add_separator
123
+ st.add_row ["Uses", @stats[:uses]]
127
124
  st.add_row ["Groups", @stats[:groups]]
128
125
  st.add_row ["Targets", @stats[:targets]]
129
126
  st.add_row ["Runs", @stats[:hosts]]
data/lib/teuton/cli.rb CHANGED
@@ -37,6 +37,16 @@ class CLI < Thor
37
37
  Teuton.check(projectpath, options)
38
38
  end
39
39
 
40
+ map ["co", "-co", "--config"] => "config"
41
+ desc "config DIRECTORY", "Suggest configuration"
42
+ long_desc <<~LONGDESC
43
+ config [OPTIONS] DIRECTORY", "Suggest configuration"
44
+ LONGDESC
45
+ def config(projectpath)
46
+ opt = {"onlyconfig" => true}
47
+ Teuton.check(projectpath, opt)
48
+ end
49
+
40
50
  map ["--readme"] => "readme"
41
51
  option :lang, type: :string
42
52
  desc "readme DIRECTORY", "Show README extracted from test contents"
@@ -1,12 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Readme
4
- # * target
5
- # * goto
6
- # * run
7
- # * expect
8
- # * unique
9
- # * log
4
+ # readme, target, goto, run
5
+ # expect,
6
+ # gett, set, unique, log
10
7
  class Readme
11
8
  def readme(text)
12
9
  if @action[:target].nil?
@@ -92,7 +89,8 @@ class Readme
92
89
  m = method.to_s
93
90
  if m[0] == "_"
94
91
  instance_eval("get(:#{m[1, m.size - 1]})", __FILE__, __LINE__)
95
- elsif not Application.instance.macros[m].nil?
92
+ # elsif not Application.instance.macros[m].nil?
93
+ elsif not Project.value[:macros][m].nil?
96
94
  puts "macro exec: #{m}"
97
95
  code = ""
98
96
  args[0].keys.each { |key| code += "set(:#{key}, '#{args[0][key]}')\n" }
@@ -1,4 +1,4 @@
1
- require_relative "../application"
1
+ require_relative "../utils/project"
2
2
 
3
3
  module Lang
4
4
  def self.get(key)
@@ -23,7 +23,8 @@ module Lang
23
23
  global: "\nParámetros globales que pueden ser modificados:\n",
24
24
  created: "\nParámetros creados durante la ejecución del reto:\n"
25
25
  }
26
- locale = Application.instance.options["lang"].downcase
26
+ # locale = Application.instance.options["lang"].downcase
27
+ locale = Project.value[:options]["lang"].downcase
27
28
  lang[locale][key]
28
29
  end
29
30
  end
@@ -1,27 +1,27 @@
1
- require_relative "../application"
1
+ require_relative "../utils/project"
2
2
  require_relative "../utils/configfile_reader"
3
- require_relative "../case_manager/case/result/result"
3
+ require_relative "../utils/result/result"
4
4
  require_relative "../version"
5
5
  require_relative "dsl"
6
6
  require_relative "lang"
7
7
 
8
8
  def use(filename)
9
9
  filename += ".rb"
10
- app = Application.instance
11
- rbfiles = File.join(app.project_path, "**", filename)
10
+ rbfiles = File.join(Project.value[:project_path], "**", filename)
12
11
  files = Dir.glob(rbfiles)
13
12
  use = []
14
13
  files.sort.each { |f| use << f if f.include?(filename) }
15
14
  require_relative use[0]
15
+ Project.value[:uses] << use[0]
16
16
  end
17
17
 
18
18
  def define_macro(name, *args, &block)
19
19
  puts "macro: #{name}"
20
- Application.instance.macros[name] = {args: args, block: block}
20
+ Project.value[:macros][name] = {args: args, block: block}
21
21
  end
22
22
 
23
23
  def group(name, &block)
24
- Application.instance.groups << {name: name, block: block}
24
+ Project.value[:groups] << {name: name, block: block}
25
25
  end
26
26
  alias task group
27
27
 
@@ -31,16 +31,14 @@ end
31
31
  # alias_method "play", "start" # REVISE THIS
32
32
  alias play start
33
33
 
34
- # Creates README.md file from RB script file
35
34
  class Readme
35
+ # Creates README.md file from RB script file
36
36
  attr_reader :result
37
37
  attr_reader :data
38
38
 
39
- ##
40
- # Initialize Readme instance
41
- # @param script_path (String) Path to main rb file (start.rb)
42
- # @param config_path (String) Path to main config file (config.yaml)
43
39
  def initialize(script_path, config_path)
40
+ # script_path Path to main rb file (start.rb)
41
+ # config_path Path to main config file (config.yaml)
44
42
  @path = {}
45
43
  @path[:script] = script_path
46
44
  @path[:dirname] = File.dirname(script_path)
@@ -59,9 +57,9 @@ class Readme
59
57
  private
60
58
 
61
59
  def reset
62
- app = Application.instance
63
- @config = ConfigFileReader.read(app.config_path)
64
- @verbose = app.verbose
60
+ # app = Application.instance
61
+ @config = ConfigFileReader.read(Project.value[:config_path])
62
+ @verbose = Project.value[:verbose]
65
63
  @result = Result.new
66
64
  @data = {}
67
65
  @data[:macros] = []
@@ -76,7 +74,7 @@ class Readme
76
74
  end
77
75
 
78
76
  def process_content
79
- Application.instance.groups.each do |g|
77
+ Project.value[:groups].each do |g|
80
78
  @current = {name: g[:name], readme: [], actions: []}
81
79
  @data[:groups] << @current
82
80
  reset_action
@@ -89,14 +87,13 @@ class Readme
89
87
  end
90
88
 
91
89
  def show_head
92
- app = Application.instance
93
90
  puts "```"
94
- puts format(Lang.get(:testname), app.test_name)
91
+ puts format(Lang.get(:testname), Project.value[:test_name])
95
92
  puts format(Lang.get(:date), Time.now)
96
93
  puts format(Lang.get(:version), Teuton::VERSION)
97
94
  puts "```"
98
95
  puts "\n"
99
- puts "# #{app.test_name}\n"
96
+ puts "# #{Project.value[:test_name]}\n"
100
97
 
101
98
  i = 1
102
99
  unless @required_hosts.empty?
@@ -1,5 +1,5 @@
1
1
  require_relative "../base_formatter"
2
- require_relative "../../../application"
2
+ require_relative "../../../utils/project"
3
3
 
4
4
  class ArrayFormatter < BaseFormatter
5
5
  def initialize(report)
@@ -60,12 +60,14 @@ class ArrayFormatter < BaseFormatter
60
60
  target[:duration] = i[:duration]
61
61
 
62
62
  target[:command] = i[:command]
63
+ target[:output] = i[:output]
63
64
  target[:alterations] = i[:alterations]
64
65
  target[:expected] = i[:expected]
65
66
  target[:result] = i[:result]
66
67
 
67
68
  if options[:feedback] == false
68
69
  target[:command] = "*" * i[:command].size
70
+ target[:output] = "*" * i[:output].size
69
71
  target[:alterations] = "*" * i[:alterations].size
70
72
  target[:expected] = "*" * i[:expected].size
71
73
  target[:result] = "*" * i[:result].size
@@ -85,12 +87,11 @@ class ArrayFormatter < BaseFormatter
85
87
  end
86
88
 
87
89
  def build_hof_data
88
- app = Application.instance
89
90
  @data[:hall_of_fame] = {}
90
- return if app.options[:case_number] < 3
91
+ return if Project.value[:options][:case_number] < 3
91
92
 
92
93
  fame = {}
93
- app.hall_of_fame.each { |line| fame[line[0]] = line[1] }
94
+ Project.value[:hall_of_fame].each { |line| fame[line[0]] = line[1] }
94
95
  @data[:hall_of_fame] = fame
95
96
  end
96
97
 
@@ -115,6 +116,6 @@ class ArrayFormatter < BaseFormatter
115
116
  end
116
117
 
117
118
  def version
118
- Application::VERSION
119
+ Teuton::VERSION
119
120
  end
120
121
  end
@@ -91,6 +91,7 @@ class TXTFormatter < ArrayFormatter
91
91
  w " (" + Rainbow(i[:score].to_s + "/" + i[:weight].to_s).color(color) + ")\n"
92
92
  w "#{tab * 4}Description : #{i[:description]}\n"
93
93
  w "#{tab * 4}Command : #{i[:command]}\n"
94
+ w "#{tab * 4}Output : #{i[:output]}\n"
94
95
  w "#{tab * 4}Duration : #{i[:duration]} (#{i[:conn_type]})\n"
95
96
  w "#{tab * 4}Alterations : #{i[:alterations]}\n"
96
97
  w "#{tab * 4}Expected : #{i[:expected]} (#{i[:expected].class})\n"
@@ -1,4 +1,5 @@
1
1
  require_relative "../base_formatter"
2
+ require_relative "../../../utils/project"
2
3
 
3
4
  class ResumeArrayFormatter < BaseFormatter
4
5
  def initialize(report)
@@ -36,10 +37,9 @@ class ResumeArrayFormatter < BaseFormatter
36
37
  end
37
38
 
38
39
  def build_hof_data
39
- app = Application.instance
40
40
  fame = {}
41
- if app.options[:case_number] > 2
42
- app.hall_of_fame.each { |line| fame[line[0]] = line[1] }
41
+ if Project.value[:options][:case_number] > 2
42
+ Project.value[:hall_of_fame].each { |line| fame[line[0]] = line[1] }
43
43
  end
44
44
  @data[:hall_of_fame] = fame
45
45
  end
@@ -1,6 +1,6 @@
1
1
  require "erb"
2
2
  require_relative "yaml"
3
- require_relative "../../../application"
3
+ # require_relative "../../../../teuton"
4
4
 
5
5
  class ResumeHTMLFormatter < ResumeYAMLFormatter
6
6
  def initialize(report)
@@ -42,6 +42,6 @@ class ResumeHTMLFormatter < ResumeYAMLFormatter
42
42
  end
43
43
 
44
44
  def version
45
- Application::VERSION
45
+ Teuton::VERSION
46
46
  end
47
47
  end
@@ -1,4 +1,5 @@
1
- require_relative "../application"
1
+ require_relative "../utils/project"
2
+ require_relative "../utils/settings"
2
3
  require_relative "formatter/formatter"
3
4
 
4
5
  class Report
@@ -12,7 +13,8 @@ class Report
12
13
  def initialize(id = "00")
13
14
  @id = id
14
15
  @filename = "case-#{@id}"
15
- @output_dir = Application.instance.output_basedir
16
+ # @output_dir = Application.instance.output_basedir
17
+ @output_dir = Project.value[:output_basedir]
16
18
  @head = {}
17
19
  @lines = []
18
20
  @tail = {}
@@ -57,7 +59,6 @@ class Report
57
59
  # * fail_weight
58
60
  # * fail_counter
59
61
  def close
60
- app = Application.instance
61
62
  max = 0.0
62
63
  good = 0.0
63
64
  fail = 0.0
@@ -68,11 +69,11 @@ class Report
68
69
  max += i[:weight] if i[:weight].positive?
69
70
  if i[:check]
70
71
  good += i[:weight]
71
- @history += app.letter[:good]
72
+ @history += Settings.letter[:good]
72
73
  else
73
74
  fail += i[:weight]
74
75
  fail_counter += 1
75
- @history += app.letter[:bad]
76
+ @history += Settings.letter[:bad]
76
77
  end
77
78
  end
78
79
  @tail[:max_weight] = max
@@ -1,16 +1,18 @@
1
1
  require "fileutils"
2
2
  require "rainbow"
3
3
 
4
- module Skeleton
5
- def self.create(project_dir)
4
+ class Skeleton
5
+ def create(project_dir)
6
6
  project_name = File.basename(project_dir)
7
- puts "\n[INFO] Creating #{Rainbow(project_name).bright} project skeleton"
7
+ puts "\nCreating #{Rainbow(project_name).bright} project"
8
8
  source_basedir = File.dirname(__FILE__)
9
9
  create_dir project_dir
10
10
  create_main_dir_and_files(project_dir, source_basedir)
11
11
  end
12
12
 
13
- private_class_method def self.create_main_dir_and_files(project_dir, source_basedir)
13
+ private
14
+
15
+ def create_main_dir_and_files(project_dir, source_basedir)
14
16
  # Directory and files: Ruby script, Configfile, gitignore
15
17
  items = [
16
18
  {source: "files/config.yaml", target: "config.yaml"},
@@ -23,7 +25,7 @@ module Skeleton
23
25
  end
24
26
  end
25
27
 
26
- private_class_method def self.create_dir(dirpath)
28
+ def create_dir(dirpath)
27
29
  if Dir.exist? dirpath
28
30
  puts "* Exists dir! => #{Rainbow(dirpath).yellow}"
29
31
  else
@@ -36,11 +38,7 @@ module Skeleton
36
38
  end
37
39
  end
38
40
 
39
- ##
40
- # Copy file
41
- # @param source (String) Source file
42
- # @param dest (String) Dest file
43
- private_class_method def self.copyfile(source, dest)
41
+ def copyfile(source, dest)
44
42
  if File.exist? dest
45
43
  puts "* Exists file! => #{Rainbow(dest).yellow}"
46
44
  else