Class: UltraSettings::AuditDataSources

Inherits:
Object
  • Object
show all
Defined in:
lib/ultra_settings/audit_data_sources.rb

Class Method Summary collapse

Class Method Details

.env_vars_can_be_runtime_settingArray<Array<(String, String, Object)>>

Find environment variables that could be moved to runtime settings. These are non-default environment variable values where a runtime setting is also available.

Returns:

  • (Array<Array<(String, String, Object)>>)

    An array of tuples containing environment variable name, runtime setting name, and current value



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ultra_settings/audit_data_sources.rb', line 42

def env_vars_can_be_runtime_setting
  env_vars_can_be_runtime = []
  each_configuration do |config|
    each_field_using_source(config, :env) do |field|
      value = config[field.name]
      default_value = default_config_value(config, field)
      next unless field.runtime_setting && value != default_value

      env_vars_can_be_runtime << [field.env_var, field.runtime_setting, value]
    end
  end
  env_vars_can_be_runtime
end

.env_vars_without_defaultArray<Array<(String, Symbol, String, Object)>>

Find environment variables being used that don’t have default values defined. These configurations require an environment variable to be set.

Returns:

  • (Array<Array<(String, Symbol, String, Object)>>)

    An array of tuples containing class name, field name, environment variable name, and current value



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ultra_settings/audit_data_sources.rb', line 60

def env_vars_without_default
  no_default_env_var_fields = []
  each_configuration do |config|
    each_field_using_source(config, :env) do |field|
      value = default_config_value(config, field)
      if value.nil?
        no_default_env_var_fields << [config.class.name, field.name, field.env_var, config[field.name]]
      end
    end
  end
  no_default_env_var_fields
end

.unnecessary_env_varsArray<Array<(String, Object)>>

Find environment variables that are set but have the same value as their default. These environment variables could potentially be removed since they’re not changing behavior.

Returns:

  • (Array<Array<(String, Object)>>)

    An array of tuples containing environment variable names and their default values



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ultra_settings/audit_data_sources.rb', line 10

def unnecessary_env_vars
  env_vars_at_default = []
  each_configuration do |config|
    each_field_using_source(config, :env) do |field|
      value = config[field.name]
      default_value = default_config_value(config, field)
      env_vars_at_default << [field.env_var, default_value] if default_value == value
    end
  end
  env_vars_at_default
end

.unnecessary_runtime_settingsArray<Array<(String, Object)>>

Find runtime settings that are set but have the same value as their default. These runtime settings could potentially be removed since they’re not changing behavior.

Returns:

  • (Array<Array<(String, Object)>>)

    An array of tuples containing runtime setting names and their default values



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ultra_settings/audit_data_sources.rb', line 26

def unnecessary_runtime_settings
  unnecessary_runtime_settings = []
  each_configuration do |config|
    each_field_using_source(config, :settings) do |field|
      value = config[field.name]
      default_value = default_config_value(config, field)
      unnecessary_runtime_settings << [field.runtime_setting, default_value] if default_value == value
    end
  end
  unnecessary_runtime_settings
end