Top Level Namespace

Defined Under Namespace

Modules: CommonHttpSettings, FileSv, ServerUtils, ServiceLoader Classes: DeleteSettings, FileProcessor, GetSettings, GlobalSettings, HarGenerator, OptionsSettings, PatchSettings, PlannedEndpoint, PostSettings, PutSettings, RenderFile, SvPlan, VirtualServer, YamlProcessor

Constant Summary collapse

CONFIG_FILE =
"file_sv.yaml"

Instance Method Summary collapse

Instance Method Details

#load_default_config(file_path) ⇒ Object

Set values in global settings based on config



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/file_sv.rb', line 54

def load_default_config(file_path)
  unless File.exist? file_path
    FileSv.logger.debug "No config found at #{file_path}" if ENV["debug"] == "true"
    return
  end
  FileSv.logger.debug "Loading config from #{file_path}" if ENV["debug"] == "true"

  config = YAML.load_file file_path
  return unless config # Handle empty YAML file

  FileSv.logger.debug "Config #{config}" if ENV["debug"] == "true"
  config["global"]&.each do |key, value|
    FileSv.logger.debug "Setting #{key} to #{value}" if ENV["debug"] == "true"
    GlobalSettings.send("#{key}=", value)
  end

  load_rest_method_config config
end

#load_rest_method_config(config) ⇒ Object

Load details of each REST method



74
75
76
77
78
# File 'lib/file_sv.rb', line 74

def load_rest_method_config(config)
  FileSv.rest_methods.each do |method, setting_class|
    config[method.to_s]&.each { |key, value| setting_class.send("#{key}=", value) }
  end
end

#set_based_on_env_varsObject

Set global params based on ENV vars



81
82
83
84
85
86
87
88
89
# File 'lib/file_sv.rb', line 81

def set_based_on_env_vars
  GlobalSettings.instance_variables.each do |setting|
    setting_name = setting.to_s[1..]
    if ENV[setting_name]
      FileSv.logger.debug "Setting #{setting_name} to #{ENV[setting_name]}"
      GlobalSettings.send("#{setting_name}=", ENV[setting_name])
    end
  end
end