Class: Ukiryu::Config::EnvProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/config/env_provider.rb

Overview

Provides environment variable values for configuration Reads and parses UKIRYU_* environment variables and standard env vars like NO_COLOR

Class Method Summary collapse

Class Method Details

.load_allObject

Load all environment overrides



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ukiryu/config/env_provider.rb', line 10

def load_all
  result = {}

  # Load UKIRYU_* environment variables
  Ukiryu::Config::EnvSchema.all_attributes.each do |attr|
    env_key = Ukiryu::Config::EnvSchema.env_key(attr)
    value = ENV[env_key]

    # Convert and store if value exists
    result[attr] = Ukiryu::Config::TypeConverter.convert(attr, value) if value
  end

  # Handle NO_COLOR standard environment variable (https://no-color.org/)
  # NO_COLOR takes precedence over UKIRYU_USE_COLOR
  # When set (to any value), colors are disabled
  result[:use_color] = false if ENV['NO_COLOR']

  result
end

.load_executionObject

Load execution-specific environment overrides



31
32
33
# File 'lib/ukiryu/config/env_provider.rb', line 31

def load_execution
  load_attributes(Ukiryu::Config::EnvSchema.all_execution_attributes)
end

.load_outputObject

Load output-specific environment overrides



36
37
38
# File 'lib/ukiryu/config/env_provider.rb', line 36

def load_output
  load_attributes(Ukiryu::Config::EnvSchema.all_output_attributes)
end

.load_registerObject

Load register-specific environment overrides



41
42
43
# File 'lib/ukiryu/config/env_provider.rb', line 41

def load_register
  load_attributes(Ukiryu::Config::EnvSchema.all_register_attributes)
end