Class: ReportPortal::Settings

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

Constant Summary collapse

PREFIX =
'rp_'

Instance Method Summary collapse

Constructor Details

#initializeSettings

Returns a new instance of Settings.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/report_portal/settings.rb', line 28

def initialize
  filename = ENV.fetch("#{PREFIX}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,
    'description' => false,
    'tags' => 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) }
    fail "ReportPortal: Define environment variable '#{PREFIX}#{key}' or key #{key} in the configuration YAML file" if is_required && public_send(key).nil?
  end
end

Instance Method Details

#formatter_modesObject



61
62
63
# File 'lib/report_portal/settings.rb', line 61

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

#launch_modeObject



57
58
59
# File 'lib/report_portal/settings.rb', line 57

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

#project_urlObject



65
66
67
# File 'lib/report_portal/settings.rb', line 65

def project_url
  "#{endpoint}/#{project}"
end