Class: Msf::MCP::Config::Loader
- Inherits:
-
Object
- Object
- Msf::MCP::Config::Loader
- Defined in:
- lib/msf/core/mcp/config/loader.rb
Class Method Summary collapse
-
.load(file_path) ⇒ Hash
Load configuration from YAML file with environment variable overrides.
-
.load_from_hash(config_hash) ⇒ Hash
Load configuration from hash (for testing).
Class Method Details
.load(file_path) ⇒ Hash
Load configuration from YAML file with environment variable overrides
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/msf/core/mcp/config/loader.rb', line 13 def self.load(file_path) unless File.exist?(file_path) raise ConfigurationError, "Configuration file not found: #{file_path}" end begin config = YAML.safe_load_file(file_path, symbolize_names: true) rescue Psych::SyntaxError => e raise ConfigurationError, "Invalid YAML syntax in #{file_path}: #{e.}" end unless config.is_a?(Hash) raise ConfigurationError, "Configuration file must contain a YAML hash/dictionary" end apply_defaults(config) apply_env_overrides(config) config end |
.load_from_hash(config_hash) ⇒ Hash
Load configuration from hash (for testing)
37 38 39 40 41 42 |
# File 'lib/msf/core/mcp/config/loader.rb', line 37 def self.load_from_hash(config_hash) config = config_hash.dup apply_defaults(config) apply_env_overrides(config) config end |