teuton 3.0.2 → 3.1.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.
@@ -1,18 +1,14 @@
1
1
  require "rainbow"
2
2
 
3
3
  class NameFileFinder
4
- attr_reader :options
5
- attr_reader :project_path
6
- attr_reader :script_path
7
- attr_reader :config_path
8
- attr_reader :test_name
4
+ attr_reader :options, :project_path, :script_path, :config_path, :testname
9
5
 
10
6
  def initialize(options = {})
11
7
  @options = options
12
8
  @project_path = nil
13
9
  @script_path = nil # Path to DSL script file
14
10
  @config_path = nil # Path to YAML config file
15
- @test_name = nil
11
+ @testname = nil
16
12
  end
17
13
 
18
14
  ##
@@ -44,7 +40,7 @@ class NameFileFinder
44
40
 
45
41
  @project_path = folder_path
46
42
  @script_path = script_path
47
- @test_name = folder_path.split(File::SEPARATOR)[-1]
43
+ @testname = folder_path.split(File::SEPARATOR)[-1]
48
44
 
49
45
  find_configfilename_from_directory(folder_path)
50
46
  end
@@ -59,9 +55,7 @@ class NameFileFinder
59
55
  # Config name file is introduced by cname arg option from teuton command
60
56
  config_name = options["cname"] unless options["cname"].nil?
61
57
  config_path = File.join(folder_path, "#{config_name}.json")
62
- unless File.exist? config_path
63
- config_path = File.join(folder_path, "#{config_name}.yaml")
64
- end
58
+ config_path = File.join(folder_path, "#{config_name}.yaml") unless File.exist? config_path
65
59
  else
66
60
  # Config path file is introduced by cpath arg option from teuton command
67
61
  config_path = options["cpath"]
@@ -81,7 +75,7 @@ class NameFileFinder
81
75
 
82
76
  @project_path = File.dirname(script_path)
83
77
  @script_path = script_path
84
- @test_name = File.basename(script_path, ".rb")
78
+ @testname = File.basename(script_path, ".rb")
85
79
  find_configfilenames_from_rb(script_path)
86
80
  end
87
81
 
@@ -95,9 +89,7 @@ class NameFileFinder
95
89
  config_name = options["cname"] unless options["cname"].nil?
96
90
 
97
91
  config_path = File.join(@project_path, config_name + ".json")
98
- unless File.exist? config_path
99
- config_path = File.join(@project_path, config_name + ".yaml")
100
- end
92
+ config_path = File.join(@project_path, config_name + ".yaml") unless File.exist? config_path
101
93
  else
102
94
  # Config path file is introduced by cpath arg option from teuton command
103
95
  config_path = options["cpath"]
@@ -7,6 +7,7 @@ class Project
7
7
  @project = {}
8
8
  @project[:running_basedir] = Dir.getwd
9
9
  @project[:output_basedir] = "var"
10
+ @project[:output_dir] = @project[:output_basedir]
10
11
  @project[:name] = "teuton"
11
12
  @project[:format] = :txt # Default export format
12
13
  @project[:debug] = false # Disable/enable local executions
@@ -42,7 +43,7 @@ class Project
42
43
  # Preprocess input options:
43
44
  # * Convert input case options String to an Array of integers
44
45
  # * Read color input option
45
- def self.add_input_params(projectpath, options)
46
+ def self.add_options(projectpath, options)
46
47
  value[:options].merge! options
47
48
  Rainbow.enabled = value[:options]["color"]
48
49
 
@@ -51,7 +52,7 @@ class Project
51
52
  value[:project_path] = finder.project_path
52
53
  value[:script_path] = finder.script_path
53
54
  value[:config_path] = finder.config_path
54
- value[:test_name] = finder.test_name
55
+ value[:testname] = finder.testname
55
56
 
56
57
  return if value[:options]["case"].nil?
57
58
 
@@ -59,6 +60,19 @@ class Project
59
60
  value[:options]["case"] = numbers.collect!(&:to_i)
60
61
  end
61
62
 
63
+ def self.add_config(configdata)
64
+ # Load configurations from config file
65
+ value[:ialias] = configdata[:alias] || {}
66
+ value[:global] = configdata[:global] || {}
67
+ value[:global][:tt_sequence] = false if value[:global][:tt_sequence].nil?
68
+ running_basedir = "#{value[:running_basedir]}/"
69
+ value[:global][:tt_script_path] = value[:script_path].gsub(running_basedir, "")
70
+ value[:global][:tt_config_path] = value[:config_path].gsub(running_basedir, "")
71
+
72
+ value[:testname] = value[:global][:tt_testname] if value[:global][:tt_testname]
73
+ value[:output_dir] = (value[:global][:tt_output_dir] || File.join(value[:output_basedir], value[:testname]))
74
+ end
75
+
62
76
  def self.relative_path(filepath)
63
77
  if filepath.start_with?(Dir.pwd)
64
78
  filepath[Dir.pwd.length + 1, filepath.length]
@@ -1,5 +1,5 @@
1
1
  module Teuton
2
- VERSION = "3.0.2".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  APPNAME = "teuton".freeze
4
4
  GEMNAME = "teuton".freeze
5
5
  DOCKERNAME = "dvarrui/#{GEMNAME}".freeze
data/lib/teuton.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require_relative "teuton/utils/project"
2
- require_relative "teuton/version"
2
+ # require_relative "teuton/version"
3
3
 
4
4
  module Teuton
5
5
  def self.create(path_to_new_dir)
@@ -8,7 +8,7 @@ module Teuton
8
8
  end
9
9
 
10
10
  def self.check(projectpath, options = {})
11
- Project.add_input_params(projectpath, options)
11
+ Project.add_options(projectpath, options)
12
12
  require_dsl_and_script("teuton/check/main")
13
13
  require_relative "teuton/check/checker"
14
14
  checker = Checker.new(
@@ -19,12 +19,12 @@ module Teuton
19
19
  end
20
20
 
21
21
  def self.run(projectpath, options = {})
22
- Project.add_input_params(projectpath, options)
22
+ Project.add_options(projectpath, options)
23
23
  require_dsl_and_script("teuton/case_manager/dsl")
24
24
  end
25
25
 
26
26
  def self.readme(projectpath, options = {})
27
- Project.add_input_params(projectpath, options)
27
+ Project.add_options(projectpath, options)
28
28
  require_dsl_and_script("teuton/readme/main")
29
29
  readme = Readme.new(
30
30
  Project.value[:script_path],
@@ -33,18 +33,13 @@ module Teuton
33
33
  readme.show
34
34
  end
35
35
 
36
- def self.server(projectpath)
37
- require_relative "teuton/config/server"
38
- ConfigServer.configure_project(projectpath)
39
- end
40
-
41
36
  private_class_method def self.require_dsl_and_script(dslpath)
42
37
  # Load DSL file and then load script file
43
38
  require_relative dslpath
44
39
  begin
45
40
  mainscriptfile = Project.value[:script_path]
46
41
  require_relative mainscriptfile
47
- rescue StandardError => e
42
+ rescue => e
48
43
  warn Rainbow("[ERROR] #{e}").bright.red
49
44
  e.backtrace&.first(3)&.each do |line|
50
45
  warn Rainbow("[ERROR] #{line}").red
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: 3.0.2
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
@@ -349,7 +349,7 @@ files:
349
349
  - lib/teuton/version.rb
350
350
  homepage: https://github.com/teuton-software/teuton
351
351
  licenses:
352
- - MPL-2.0
352
+ - AGPL-3.0
353
353
  metadata: {}
354
354
  rdoc_options: []
355
355
  require_paths: