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,12 +1,9 @@
1
- # frozen_string_literal: true
1
+ require "terminal-table"
2
+ require "rainbow"
3
+ require_relative "array_formatter"
2
4
 
3
- require 'terminal-table'
4
- require 'rainbow'
5
- require_relative 'array_formatter'
6
-
7
- # TXTFormatter class
8
5
  class TXTFormatter < ArrayFormatter
9
- def initialize(report, color=false)
6
+ def initialize(report, color = false)
10
7
  @color = color
11
8
  super(report)
12
9
  @data = {}
@@ -32,9 +29,9 @@ class TXTFormatter < ArrayFormatter
32
29
  def process_config
33
30
  w "#{Rainbow("CONFIGURATION").bg(:blue)}\n"
34
31
  my_screen_table = Terminal::Table.new do |st|
35
- @data[:config].sort.each { |key,value| st.add_row [ key.to_s, value.to_s] }
32
+ @data[:config].sort.each { |key, value| st.add_row [key.to_s, value.to_s] }
36
33
  end
37
- w my_screen_table.to_s+"\n\n"
34
+ w "#{my_screen_table}\n\n"
38
35
  end
39
36
 
40
37
  def process_logs
@@ -54,11 +51,11 @@ class TXTFormatter < ArrayFormatter
54
51
  def process_results
55
52
  w "\n#{Rainbow("RESULTS").bg(:blue)}\n"
56
53
  my_screen_table = Terminal::Table.new do |st|
57
- @data[:results].each do |key,value|
58
- st.add_row [ key.to_s, value.to_s]
54
+ @data[:results].each do |key, value|
55
+ st.add_row [key.to_s, value.to_s]
59
56
  end
60
57
  end
61
- w my_screen_table.to_s+"\n"
58
+ w "#{my_screen_table}\n"
62
59
  end
63
60
 
64
61
  def process_hof
@@ -78,25 +75,25 @@ class TXTFormatter < ArrayFormatter
78
75
  st.add_row [text1, text2]
79
76
  end
80
77
  end
81
- w my_screen_table.to_s + "\n"
78
+ w "#{my_screen_table}\n"
82
79
  end
83
80
 
84
81
  private
85
82
 
86
83
  def process_group(group)
87
- tab = ' '
84
+ tab = " "
88
85
  w "- #{Rainbow(group[:title]).blue.bright}\n"
89
86
  group[:targets].each do |i|
90
87
  color = :red
91
88
  color = :green if i[:check]
92
- w tab*2 + format("%02d", i[:target_id].to_i)
93
- w " (#{Rainbow(i[:score].to_s+"/"+i[:weight].to_s).color(color)})\n"
94
- w tab*4+"Description : #{i[:description].to_s}\n"
95
- w tab*4+"Command : #{i[:command].to_s}\n"
96
- w tab*4+"Duration : #{i[:duration].to_s} (#{i[:conn_type].to_s})\n"
97
- w tab*4+"Alterations : #{i[:alterations].to_s}\n"
98
- w tab*4+"Expected : #{i[:expected].to_s} (#{i[:expected].class.to_s})\n"
99
- w tab*4+"Result : #{i[:result].to_s} (#{i[:result].class.to_s})\n"
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"
100
97
  end
101
98
  end
102
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
- def initialize(pReport)
7
- super(pReport)
8
- end
9
-
10
- def process
11
- tab=" "
12
- w "<tt-checker version='0.2'>\n"
13
- w tab+"<head>\n"
14
- @head.each { |key,value| w tab*2+"<"+key.to_s+">"+value.to_s+"</"+key.to_s+">\n" }
15
- w tab+"</head>\n"
16
-
17
- w tab+"<lines>\n"
18
- @lines.each do |i|
19
- if i.class.to_s=='Hash' then
20
- w tab*2+"<line>\n"
21
- w tab*3+"<id>"+i[:id].to_s+"</id>\n"
22
- w tab*3+"<description>"+i[:description].to_s+"</description>\n"
23
- w tab*3+"<command"
24
- w " tempfile='"+i[:tempfile]+"'" if i[:tempfile]
25
- w ">"+i[:command].to_s+"</command>\n"
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
- w tab+"</lines>\n"
34
-
35
- w tab+"<tail>\n"
36
- @tail.each { |key,value| w tab*2+"<"+key.to_s+">"+value.to_s+"</"+key.to_s+">\n" }
37
- w tab+"</tail>\n"
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
- deinit
41
- end
32
+ deinit
33
+ end
42
34
  end
@@ -1,19 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yaml'
4
- require_relative 'array_formatter'
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]
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'terminal-table'
4
- require_relative '../application'
5
- require_relative 'formatter/formatter_factory'
6
- require_relative 'show'
7
- require_relative 'close'
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 = '00')
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, 'moodle.csv')
67
+ filepath = File.join(@output_dir, "moodle.csv")
68
68
  formatter = FormatterFactory.get(self, :moodle_csv, filepath)
69
69
  formatter.process
70
70
  end
@@ -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? 'resume'
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('INITIAL CONFIGURATIONS').bright
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('CASE RESULTS').bright
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('CONN ERRORS').bright
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('CASE RESULTS').bright
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 == 'Hash'
76
+ if i.class.to_s == "Hash"
88
77
  value = 0.0
89
78
  value = i[:weight] if i[:check]
90
- print tab + '%03d' % i[:id].to_i
91
- print ' (%2.1f' % value.to_f
92
- print '/%2.1f' % i[:weight].to_f
93
- puts ') %s' % i[:description].to_s
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('FINAL VALUES').bright
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('HALL OF FAME').bright
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]]
@@ -1,10 +1,7 @@
1
-
2
- require 'fileutils'
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
- { source: 'files/config.yaml', target: 'config.yaml' },
24
- { source: 'files/start.rb', target: 'start.rb' }
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 StandardError
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 StandardError
51
+ rescue
60
52
  puts "* Create file ERROR => #{Rainbow(dest).red}"
61
53
  end
62
54
  end
@@ -1,6 +1,5 @@
1
-
2
- require 'yaml'
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] = [{ tt_members: 'anonymous' }]
16
+ data[:cases] = [{tt_members: "anonymous"}]
18
17
  return data
19
18
  end
20
- return read_yaml(filepath) if File.extname(filepath) == '.yaml'
19
+ return read_yaml(filepath) if File.extname(filepath) == ".yaml"
21
20
 
22
- return read_json(filepath) if File.extname(filepath) == '.json'
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 StandardError => e
35
- puts "\n" + ('=' * 80)
33
+ rescue => e
34
+ puts "\n" + ("=" * 80)
36
35
  puts "[ERROR] ConfigFileReader#read <#{filepath}>"
37
- puts ' I suggest to revise file format!'
38
- puts " #{e.message}\n" + ('=' * 80)
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
- basedir = include_dir
70
+ basedir = if include_dir == File.absolute_path(include_dir)
71
+ include_dir
73
72
  else
74
- basedir = File.join(File.dirname(filepath), data[:global][:tt_include])
73
+ File.join(File.dirname(filepath), data[:global][:tt_include])
75
74
  end
76
- files = Dir.glob(File.join(basedir, '**/*.yaml'))
77
- files += Dir.glob(File.join(basedir, '**/*.yml'))
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 StandardError => e
82
- puts "\n" + ('=' * 80)
82
+ rescue => e
83
+ puts "\n" + ("=" * 80)
83
84
  puts "[ERROR] ConfigFileReader#read <#{file}>"
84
- puts ' I suggest to revise file format!'
85
- puts " #{e.message}\n" + ('=' * 80)
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.class == Hash
99
+ if value.instance_of? Hash
99
100
  value2 = convert_string_keys_to_symbol(value)
100
- elsif value.class == Array
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, 'start.rb')
28
+ script_path = File.join(folder_path, "start.rb")
34
29
  unless File.exist? script_path
35
- print Rainbow('[ERROR] File ').red
30
+ print Rainbow("[ERROR] File ").red
36
31
  print Rainbow(script_path).bright.red
37
- puts Rainbow(' not found!').red
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['cpath'].nil?
58
- config_name = 'config'
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['cname'] unless app.options['cname'].nil?
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['cpath']
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) != '.rb'
76
- print Rainbow('[ERROR] Script ').red
70
+ if File.extname(script_path) != ".rb"
71
+ print Rainbow("[ERROR] Script ").red
77
72
  print Rainbow(script_path).bright.red
78
- puts Rainbow(' must have rb extension').red
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, '.rb')
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['cpath'].nil?
97
- config_name = File.basename(script_path, '.rb')
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['cname'] unless app.options['cname'].nil?
94
+ config_name = app.options["cname"] unless app.options["cname"].nil?
100
95
 
101
- config_path = File.join(app.project_path, config_name + '.json')
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 + '.yaml')
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['cpath']
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['quiet']
113
+ return if Application.instance.options["quiet"]
119
114
 
120
115
  print text
121
116
  end
@@ -1,5 +1,4 @@
1
-
2
- require_relative '../application'
1
+ require_relative "../application"
3
2
 
4
3
  module Verbose
5
4
  def verboseln(text)
@@ -1,8 +1,7 @@
1
-
2
1
  module Teuton
3
- VERSION = '2.3.5'
4
- APPNAME = 'teuton'
5
- GEMNAME = 'teuton'
2
+ VERSION = "2.3.7"
3
+ APPNAME = "teuton"
4
+ GEMNAME = "teuton"
6
5
  DOCKERNAME = "dvarrui/#{GEMNAME}"
7
6
  HOMEPAGE = "https://github.com/teuton-software/teuton"
8
7
  end
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 'teuton/skeleton'
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('teuton/case_manager/dsl') # Define DSL keywords
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('teuton/readme/readme') # Define DSL keywords
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('teuton/check/laboratory') # Define DSL keywords
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)