Class: Rpruby::Settings

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rpruby/settings.rb

Instance Method Summary collapse

Constructor Details

#initializeSettings

Returns a new instance of Settings.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rpruby/settings.rb', line 8

def initialize
  filename = ENV.fetch('rp_config') do
    glob = Dir.glob('{,.config/,config/}report{,-,_}portal{.yml,.yaml}')
    p "Multiple configuration files found for ReportPortal. Using the first one: #{glob.first}" if glob.size > 1
    glob.first
  end

  @properties = filename.nil? ? {} : YAML.load_file(filename)
  keys = {
    'uuid' => true,
    'endpoint' => true,
    'project' => true,
    'launch' => true,
    'tags' => false,
    'description' => false,
    'attributes' => false,
    'is_debug' => false,
    'disable_ssl_verification' => false,
    # for parallel execution only
    'use_standard_logger' => false,
    'launch_id' => false,
    'file_with_launch_id' => false
  }

  keys.each do |key, is_required|
    define_singleton_method(key.to_sym) { setting(key) }
    next unless is_required && public_send(key).nil?

    env_variable_name = env_variable_name(key)
    raise "ReportPortal: Define environment variable '#{env_variable_name.upcase}', '#{env_variable_name}' "\
      "or key #{key} in the configuration YAML file"
  end
end

Instance Method Details

#formatter_modesObject



46
47
48
# File 'lib/rpruby/settings.rb', line 46

def formatter_modes
  setting('formatter_modes') || []
end

#launch_modeObject



42
43
44
# File 'lib/rpruby/settings.rb', line 42

def launch_mode
  is_debug ? 'DEBUG' : 'DEFAULT'
end