teuton 2.1.8dev1 → 2.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9adfc25439c6c4041e3ebe2c3defd49f2377fd5bc9283da0849e5e2ad220581
4
- data.tar.gz: ddfb9194f6ce7d070fd53aa796094ffa25faa19f7d7142bb044ce9d92ed6725a
3
+ metadata.gz: cfb81fb786d0111b84d43f68a98b222639f37cc620fcf1156bf8722416f78a25
4
+ data.tar.gz: 71ba4a3325eb5d2ed76b64efbe9476fc77d82794d620416482a7ac57b835f692
5
5
  SHA512:
6
- metadata.gz: ca261f8258065c3684c82dae7ea8929c1d77bfeeb64baea71dd60c2aa52d99f1767af1bd2467a1747881a4e37ba4078df1dc9541895bcee6f0695b73874e8cc8
7
- data.tar.gz: 001aa6f198e560ec39cac6a1cca65ed67d7ef887751e7f9e13759309c7bf42cf772c8c8fb32fc8e0f8ec1ddc92477ef2a8bfbdae7c74851cad4afb7123eadeff
6
+ metadata.gz: 599b8e1e1dece4f9a3afad33c1d7e71417a280f31ed7e78632d62d8b2819d8cb99d04409b152a1e1cabfa90191e244863ca02593fbe44638ddd9fde9bdb682d7
7
+ data.tar.gz: d781970ef1d69087099915f6474df31af872fd64823e2643279407df6f9a83731127696c91bb5b8a0627b3543d0cfb6dac8c2db29b0edb006a64222a589ea01d
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'singleton'
2
4
 
3
5
  # This Singleton contains application params
4
6
  class Application
5
7
  include Singleton
6
8
 
7
- VERSION = '2.1.8dev1' # Application version
8
- NAME = 'teuton' # Application name
9
+ VERSION = '2.1.8' # Application version
10
+ NAME = 'teuton' # Application name
9
11
 
10
12
  attr_reader :letter
11
13
  attr_reader :running_basedir, :output_basedir
@@ -17,10 +19,15 @@ class Application
17
19
  attr_accessor :hall_of_fame
18
20
  attr_accessor :project_path, :script_path, :config_path, :test_name
19
21
 
22
+ ##
23
+ # Initialize Application instance
20
24
  def initialize
21
25
  reset
22
26
  end
23
27
 
28
+ ##
29
+ # Reset param values
30
+ # rubocop:disable Metrics/MethodLength
24
31
  def reset
25
32
  @letter = { good: '.', bad: 'F', error: '?', none: ' ' }
26
33
  @running_basedir = Dir.getwd
@@ -36,18 +43,29 @@ class Application
36
43
  @uses = [] # TODO
37
44
  @hall_of_fame = []
38
45
  end
46
+ # rubocop:enable Metrics/MethodLength
39
47
 
48
+ ##
49
+ # Return debug param
50
+ # @return Boolean
40
51
  def debug
41
52
  @default[:debug]
42
53
  end
43
54
 
55
+ ##
56
+ # Return name param
57
+ # @return String
44
58
  def name
45
59
  @default[:name]
46
60
  end
47
61
 
62
+ ##
63
+ # Return quiet param
64
+ # @return Boolean
48
65
  def quiet?
49
66
  return true if Application.instance.options['quiet']
50
67
  return true unless Application.instance.verbose
68
+
51
69
  false
52
70
  end
53
71
  end
@@ -26,8 +26,11 @@ class Case
26
26
  attr_accessor :result
27
27
  attr_accessor :action # TODO: why not reader only???
28
28
  attr_reader :id, :config, :uniques, :conn_status
29
- @@id = '01'
29
+ @@id = '01' # First case ID value
30
30
 
31
+ ##
32
+ # Initialize case from specified config
33
+ # @param config (Hash)
31
34
  def initialize(config)
32
35
  app = Application.instance
33
36
  @config = Case::Config.new(local: config, global: app.global)
@@ -46,7 +49,7 @@ class Case
46
49
  @skip = get(:tt_skip) unless get(:tt_skip) == 'NODATA'
47
50
  unless app.options['case'].nil?
48
51
  @skip = true
49
- @skip = false if app.options['case'].include? @id
52
+ @skip = false if app.options['case'].include? @id.to_i
50
53
  end
51
54
 
52
55
  @conn_status = {}
@@ -70,8 +73,12 @@ class Case
70
73
  tempfile :default
71
74
  end
72
75
 
76
+ ##
77
+ # Export Case with specific output format
78
+ # @param format (Symbol)
73
79
  def export(format)
74
80
  return if skip?
81
+
75
82
  @report.export format
76
83
  end
77
84
 
@@ -79,21 +86,33 @@ class Case
79
86
  @report.filename #+ '.' + @report.format.to_s
80
87
  end
81
88
 
89
+ ##
90
+ # Return case grade
91
+ # @return grade
82
92
  def grade
83
93
  return 0.0 if skip
94
+
84
95
  @report.tail[:grade]
85
96
  end
86
97
 
98
+ ## Return case members
99
+ # @return members
87
100
  def members
88
101
  return '-' if skip
102
+
89
103
  @report.head[:tt_members] || 'noname'
90
104
  end
91
105
 
106
+ ##
107
+ # Return case skip value
108
+ # @return skip
92
109
  def skip
93
110
  @skip
94
111
  end
95
112
  alias skip? skip
96
113
 
114
+ ##
115
+ # Show case
97
116
  def show
98
117
  @report.show
99
118
  end
@@ -7,6 +7,8 @@
7
7
  # * fill_report
8
8
  # * close_opened_sessions
9
9
  class Case
10
+ ##
11
+ # Execute "play" order on this case
10
12
  def play
11
13
  if skip?
12
14
  verbose "Skipping case <#{@config.get(:tt_members)}>\n"
@@ -21,6 +23,8 @@ class Case
21
23
  end
22
24
  alias start play
23
25
 
26
+ ##
27
+ # Close opened sessions for this case
24
28
  def close_opened_sessions
25
29
  @sessions.each_value do |s|
26
30
  s.close if s.class == Net::SSH::Connection::Session
@@ -29,6 +33,9 @@ class Case
29
33
 
30
34
  private
31
35
 
36
+ ##
37
+ # Execute every play#group in parallel
38
+ # TO-DO: Under construction!
32
39
  def play_in_parallel
33
40
  @groups.each do |t|
34
41
  @action[:groupname] = t[:name]
@@ -36,6 +43,8 @@ class Case
36
43
  end
37
44
  end
38
45
 
46
+ ##
47
+ # Execute every play#group in sequence
39
48
  def play_in_sequence
40
49
  verboseln "Starting case <#{@config.get(:tt_members)}>"
41
50
  @groups.each do |t|
@@ -47,12 +56,14 @@ class Case
47
56
  verboseln "\n"
48
57
  end
49
58
 
59
+ ##
60
+ # Fill case report with time information
50
61
  def fill_report(start_time, finish_time)
51
62
  @report.head.merge! @config.global
52
63
  @report.head.merge! @config.local
53
64
  @report.head.merge! @config.running
54
65
  @report.tail[:case_id] = @id
55
- @report.tail[:start_time_] = start_time
66
+ @report.tail[:start_time] = start_time
56
67
  @report.tail[:finish_time] = finish_time
57
68
  @report.tail[:duration] = finish_time - start_time
58
69
  end
@@ -23,12 +23,17 @@ class CaseManager
23
23
  include Singleton
24
24
  include Utils
25
25
 
26
+ ##
27
+ # Initialize CaseManager
26
28
  def initialize
27
29
  @cases = []
28
30
  @report = Report.new(0)
29
31
  @report.filename = 'resume'
30
32
  end
31
33
 
34
+ ##
35
+ # Execute "play" order: Start every single case test
36
+ # @param block (Block)
32
37
  def play(&block)
33
38
  check_cases!
34
39
  instance_eval(&block)
@@ -40,6 +45,9 @@ class CaseManager
40
45
  export(format: i.to_sym) unless i.nil?
41
46
  end
42
47
 
48
+ ##
49
+ # Execute "export" order: Export every case report
50
+ # @param args (Hash) Export options
43
51
  def export(args = {})
44
52
  if args.class != Hash
45
53
  puts "[ERROR] CaseManager#export: Argument = <#{args}>, " \
@@ -47,10 +55,27 @@ class CaseManager
47
55
  puts ' Usage: export :format => :colored_text'
48
56
  raise '[ERROR] CaseManager#export: Argument error!'
49
57
  end
58
+ # First: export files
50
59
  ExportManager.run(@report, @cases, args)
60
+ # Second: preserve files if required
51
61
  preserve_files if args[:preserve] == true
52
62
  end
53
63
 
64
+ ##
65
+ # Execute "send" order: Send every case report
66
+ # @param args (Hash) Send options
67
+ def send(args = {})
68
+ threads = []
69
+ puts ''
70
+ puts "[INFO] Sending files...#{args.to_s}"
71
+ @cases.each { |c| threads << Thread.new { c.send(args) } }
72
+ threads.each(&:join)
73
+ end
74
+
75
+ private
76
+
77
+ ##
78
+ # Preserve output files for current project
54
79
  def preserve_files
55
80
  app = Application.instance
56
81
  t = Time.now
@@ -61,14 +86,6 @@ class CaseManager
61
86
  srcdir = File.join(app.output_basedir, app.global[:tt_testname])
62
87
  puts "[INFO] Preserving files => #{logdir}"
63
88
  FileUtils.mkdir(logdir)
64
- Dir.glob(srcdir, '**.*').each { |file| FileUtils.cp(file, logdir) }
65
- end
66
-
67
- def send(args = {})
68
- threads = []
69
- puts ''
70
- puts "[INFO] Sending files...#{args.to_s}"
71
- @cases.each { |c| threads << Thread.new { c.send(args) } }
72
- threads.each(&:join)
89
+ Dir.glob(File.join(srcdir, '**.*')).each { |file| FileUtils.cp(file, logdir) }
73
90
  end
74
91
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # CaseManager#check_cases!
3
+ ##
4
+ # CaseManager: check_cases!
4
5
  class CaseManager
5
6
  private
6
7
 
@@ -33,6 +33,6 @@ class CLI < Thor
33
33
  # Verify or test Teuton test units syntax
34
34
  # @param path_to_rb_file [String] Route to main rb Teuton file
35
35
  def check(path_to_rb_file)
36
- Project.test(path_to_rb_file, options)
36
+ Project.check(path_to_rb_file, options)
37
37
  end
38
38
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'check'
3
4
  require_relative 'play'
4
5
  require_relative 'readme'
5
- require_relative 'test'
6
6
  require_relative 'version'
@@ -30,8 +30,8 @@ class CLI < Thor
30
30
  LONGDESC
31
31
  ##
32
32
  # Execute Teuton test unit
33
- # @param path_to_rb_file [String] Route to main rb Teuton file
34
- def play(path_to_rb_file)
35
- Project.play(path_to_rb_file, options)
33
+ # @param filepath [String] Route to main: rb file or folder
34
+ def play(filepath)
35
+ Project.play(filepath, options)
36
36
  end
37
37
  end
@@ -6,25 +6,31 @@ require_relative '../application'
6
6
  # Project:
7
7
  # * find_filenames_for, verbose, verboseln
8
8
  module NameFileFinder
9
- def self.find_filenames_for(relpathtofile)
10
- pathtofile = File.absolute_path(relpathtofile)
9
+ ##
10
+ # Find project filenames from input project relative path
11
+ # @param relprojectpath (String)
12
+ def self.find_filenames_for(relprojectpath)
13
+ projectpath = File.absolute_path(relprojectpath)
11
14
 
12
15
  # Define:
13
16
  # script_path, must contain fullpath to DSL script file
14
17
  # config_path, must contain fullpath to YAML config file
15
- if File.directory?(pathtofile)
18
+ if File.directory?(projectpath)
16
19
  # COMPLEX MODE: We use start.rb as main RB file
17
- find_filenames_from_directory(pathtofile)
20
+ find_filenames_from_directory(projectpath)
18
21
  else
19
22
  # SIMPLE MODE: We use pathtofile as main RB file
20
- find_filenames_from_rb(pathtofile)
23
+ find_filenames_from_rb(projectpath)
21
24
  end
22
25
  true
23
26
  end
24
27
 
25
- def self.find_filenames_from_directory(pathtodir)
28
+ ##
29
+ # Find project filenames from input folder path
30
+ # @param folder_path (String)
31
+ def self.find_filenames_from_directory(folder_path)
26
32
  # COMPLEX MODE: We use start.rb as main RB file
27
- script_path = File.join(pathtodir, 'start.rb')
33
+ script_path = File.join(folder_path, 'start.rb')
28
34
  unless File.exist? script_path
29
35
  print Rainbow('[ERROR] File ').red
30
36
  print Rainbow(script_path).bright.red
@@ -33,14 +39,17 @@ module NameFileFinder
33
39
  end
34
40
 
35
41
  app = Application.instance
36
- app.project_path = pathtodir
42
+ app.project_path = folder_path
37
43
  app.script_path = script_path
38
- app.test_name = pathtodir.split(File::SEPARATOR)[-1]
44
+ app.test_name = folder_path.split(File::SEPARATOR)[-1]
39
45
 
40
- find_configfilename_from_directory(pathtodir)
46
+ find_configfilename_from_directory(folder_path)
41
47
  end
42
48
 
43
- def self.find_configfilename_from_directory(pathtodir)
49
+ ##
50
+ # Find project config filename from input folder path
51
+ # @param folder_path (String)
52
+ def self.find_configfilename_from_directory(folder_path)
44
53
  # COMPLEX MODE: We use config.yaml by default
45
54
  app = Application.instance
46
55
 
@@ -49,9 +58,9 @@ module NameFileFinder
49
58
  config_name = 'config'
50
59
  # Config name file is introduced by cname arg option from teuton command
51
60
  config_name = app.options['cname'] unless app.options['cname'].nil?
52
- config_path = File.join(pathtodir, "#{config_name}.json")
61
+ config_path = File.join(folder_path, "#{config_name}.json")
53
62
  unless File.exist? config_path
54
- config_path = File.join(pathtodir, "#{config_name}.yaml")
63
+ config_path = File.join(folder_path, "#{config_name}.yaml")
55
64
  end
56
65
  else
57
66
  # Config path file is introduced by cpath arg option from teuton command
@@ -111,6 +120,10 @@ module NameFileFinder
111
120
  verboseln Rainbow(trim(app.test_name)).blue.bright
112
121
  end
113
122
 
123
+ ##
124
+ # Trim string text when is too long
125
+ # @param input (String)
126
+ # @return String
114
127
  def self.trim(input)
115
128
  output = input.to_s
116
129
  output = "...#{input[input.size - 50, input.size]}" if output.size > 65
@@ -9,10 +9,14 @@ require_relative 'name_file_finder'
9
9
  # * process_input_case_option
10
10
  # * readme
11
11
  # * require_dsl_and_script
12
- module Project
13
- def self.test(pathtofile, options)
12
+ module Project ##
13
+ ##
14
+ # Check teuton test syntax
15
+ # @param projectpath (String) Path to teuton test
16
+ # @param options (Array) Array of input options
17
+ def self.check(projectpath, options)
14
18
  Application.instance.options.merge! options
15
- NameFileFinder.find_filenames_for(pathtofile)
19
+ NameFileFinder.find_filenames_for(projectpath)
16
20
  NameFileFinder.puts_input_info_on_screen
17
21
  require_dsl_and_script('laboratory/laboratory') # Define DSL keywords
18
22
 
@@ -23,14 +27,20 @@ module Project
23
27
  lab.show_dsl unless options[:r] || options[:c]
24
28
  end
25
29
 
26
- def self.play(pathtofile, options)
30
+ ##
31
+ # Run test
32
+ # @param projectpath (String) Path to teuton test
33
+ # @param options (Array) Array of input options
34
+ def self.play(projectpath, options)
27
35
  Application.instance.options.merge! options
28
36
  process_input_case_option
29
- NameFileFinder.find_filenames_for(pathtofile)
37
+ NameFileFinder.find_filenames_for(projectpath)
30
38
  NameFileFinder.puts_input_info_on_screen
31
39
  require_dsl_and_script('../case_manager/dsl') # Define DSL keywords
32
40
  end
33
41
 
42
+ ##
43
+ # Convert input case options String to an Array of integers
34
44
  def self.process_input_case_option
35
45
  options = Application.instance.options
36
46
  return if options['case'].nil?
@@ -39,9 +49,13 @@ module Project
39
49
  options['case'] = a.collect!(&:to_i)
40
50
  end
41
51
 
42
- def self.readme(pathtofile, options)
52
+ ##
53
+ # Create Readme file for a test
54
+ # @param projectpath (String) Path to teuton test
55
+ # @param options (Array) Array of input options
56
+ def self.readme(projectpath, options)
43
57
  Application.instance.options.merge! options
44
- NameFileFinder.find_filenames_for(pathtofile)
58
+ NameFileFinder.find_filenames_for(projectpath)
45
59
  require_dsl_and_script('readme/readme') # Define DSL keywords
46
60
 
47
61
  app = Application.instance
@@ -11,7 +11,7 @@ require_relative 'resume_yaml_formatter'
11
11
  require_relative 'resume_txt_formatter'
12
12
  require_relative 'moodle_csv_formatter'
13
13
  require_relative 'csv_formatter'
14
- require_relative 'html_formatter'
14
+ #require_relative 'html_formatter'
15
15
  require_relative 'xml_formatter'
16
16
 
17
17
  # FormaterFactory module
@@ -23,11 +23,17 @@ module FormatterFactory
23
23
  when :csv
24
24
  f = CSVFormatter.new(report)
25
25
  when :html
26
- f = HTMLFormatter.new(report)
26
+ # f = HTMLFormatter.new(report)
27
27
  when :json
28
28
  f = JSONFormatter.new(report)
29
29
  when :list
30
30
  f = ListFormatter.new(report)
31
+ when :txt
32
+ f = TXTFormatter.new(report,false)
33
+ when :xml
34
+ f = XMLFormatter.new(report)
35
+ when :yaml
36
+ f = YAMLFormatter.new(report)
31
37
  when :moodle_csv
32
38
  f = MoodleCSVFormatter.new(report)
33
39
  when :resume_txt
@@ -40,12 +46,6 @@ module FormatterFactory
40
46
  f = ResumeListFormatter.new(report)
41
47
  when :resume_yaml
42
48
  f = ResumeYAMLFormatter.new(report)
43
- when :txt
44
- f = TXTFormatter.new(report,false)
45
- when :xml
46
- f = XMLFormatter.new(report)
47
- when :yaml
48
- f = YAMLFormatter.new(report)
49
49
  else
50
50
  raise Rainbow("[ERROR] FormaterFactory #{format} unkown!").red.bright
51
51
  end
@@ -1,19 +1,41 @@
1
+ # frozen_string_literal: true
1
2
 
2
- require_relative 'base_formatter'
3
+ require_relative 'yaml_formatter'
3
4
 
4
- class HTMLFormatter < BaseFormatter
5
-
6
- def initialize(pReport)
7
- super(pReport)
5
+ ##
6
+ # HTMLFormatter class receive a [Report] and generates HAML output.
7
+ class HAMLFormatter < YAMLFormatter
8
+ ##
9
+ # Class constructor
10
+ # @param report [Report] Parent object that contains data to be exported.
11
+ def initialize(report)
12
+ super(report)
13
+ @data = {}
8
14
  end
9
15
 
16
+ ##
17
+ # Process data from parent object and export it into YAML format.
18
+ # @return [nil]
10
19
  def process
20
+ build_data
21
+ # w @data.to_yaml # Write data into ouput file
22
+ build_page
23
+ deinit
24
+ end
25
+
26
+ def build_page
11
27
  puts "<html>"
12
- puts "<head><title>Checking Machines</title></head>"
28
+ puts "<head><title>TEUTON report</title></head>"
13
29
  puts "<body>"
30
+ build_config
31
+ build_targets
32
+ build_results
33
+ end
34
+
35
+ def build_config
14
36
  puts "<header><h1><a name=\"index\">Checking Machines v0.4</a></h1>"
15
37
  puts '<ul>'
16
- @head.each do |key,value|
38
+ @data[:head].each do |key,value|
17
39
  puts "<li><b>"+key.to_s+": </b>"+value.to_s+"</li>" if key!=:title
18
40
  end
19
41
  puts '</ul>'
@@ -22,19 +44,20 @@ class HTMLFormatter < BaseFormatter
22
44
  puts "<tbody>"
23
45
 
24
46
  counter=0
25
- @datagroups.each do |i|
47
+ @data[:groups].each do |group|
48
+ group[:targets].each do |target|
26
49
  counter+=1
27
- puts "<tr><td><a href=\"#group"+counter.to_s+"\">"+i.head[:members]+"</a></td>"
28
- puts "<td>"+i.tail[:grade].to_s+"</td>"
29
- puts "<td>"+i.tail[:fail_counter].to_s+"</td></tr>"
50
+ puts "<tr><td><a href=\"#group"+counter.to_s+"\">"+target.head[:members]+"</a></td>"
51
+ puts "<td>"+target[:tail][:grade]+"</td>"
52
+ puts "<td>"+target[:tail][:fail_counter]+"</td></tr>"
30
53
  end
31
54
  puts "</tbody></table></header>"
32
55
  puts "<h1>Cases</h1>"
33
56
 
34
57
  counter=0
35
- @datagroups.each do |i|
36
- counter+=1
37
- process_datagroup(i,counter)
58
+ @data[:groups].each do |group|
59
+ counter += 1
60
+ process_datagroup(group, counter)
38
61
  end
39
62
 
40
63
  puts '<ul>'
@@ -77,5 +100,5 @@ class HTMLFormatter < BaseFormatter
77
100
  end
78
101
  puts '</ul>'
79
102
  end
80
-
103
+ end
81
104
  end
@@ -65,8 +65,8 @@ class ResumeTXTFormatter < ResumeArrayFormatter
65
65
  end
66
66
  end
67
67
  return unless my_screen_table.rows.size > 1
68
- w "#{Rainbow('CONN ERRORS').bg(:red)}\n"
69
- w "#{my_screen_table}\n"
68
+
69
+ w "#{Rainbow('CONN ERRORS').bg(:red)}\n#{my_screen_table}\n"
70
70
  end
71
71
 
72
72
  def process_results
data/lib/teuton.rb CHANGED
@@ -34,8 +34,8 @@ module Teuton
34
34
  ##
35
35
  # Simulate play Teuton project, check syntax and display stats.
36
36
  # @param path_to_rb_file [String] Path to main rb file.
37
- def self.test(path_to_rb_file)
38
- Project.test(path_to_rb_file, options)
37
+ def self.check(path_to_rb_file)
38
+ Project.check(path_to_rb_file, options)
39
39
  end
40
40
 
41
41
  ##
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.8dev1
4
+ version: 2.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
@@ -281,10 +281,10 @@ files:
281
281
  - lib/teuton/case_manager/show.rb
282
282
  - lib/teuton/case_manager/utils.rb
283
283
  - lib/teuton/cli.rb
284
+ - lib/teuton/cli/check.rb
284
285
  - lib/teuton/cli/main.rb
285
286
  - lib/teuton/cli/play.rb
286
287
  - lib/teuton/cli/readme.rb
287
- - lib/teuton/cli/test.rb
288
288
  - lib/teuton/cli/version.rb
289
289
  - lib/teuton/files/README.md
290
290
  - lib/teuton/files/config.yaml
@@ -336,9 +336,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
336
336
  version: 2.5.0
337
337
  required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  requirements:
339
- - - ">"
339
+ - - ">="
340
340
  - !ruby/object:Gem::Version
341
- version: 1.3.1
341
+ version: '0'
342
342
  requirements: []
343
343
  rubygems_version: 3.1.2
344
344
  signing_key: