Class: CodexNotify::EnvSourceLoader
- Inherits:
-
Object
- Object
- CodexNotify::EnvSourceLoader
- Includes:
- ConfigSupport
- Defined in:
- lib/codex_notify/env_source_loader.rb
Defined Under Namespace
Classes: Error, LookupResult, Source, SourceSet
Constant Summary
Constants included from ConfigSupport
ConfigSupport::DEFAULT_ENV_PATH, ConfigSupport::DEFAULT_ENV_POLICY, ConfigSupport::ENV_POLICIES, ConfigSupport::REPOSITORY_ALLOWED_KEYS, ConfigSupport::REPOSITORY_CREDENTIAL_PATTERN
Instance Method Summary collapse
-
#initialize(legacy_checkout_root: nil, environment: ENV, stderr: $stderr, config_loader: nil) ⇒ EnvSourceLoader
constructor
A new instance of EnvSourceLoader.
- #load(path: ConfigSupport::DEFAULT_ENV_PATH, explicit: false, config_path: nil) ⇒ Object
Methods included from ConfigSupport
#add_common_options, #apply_destination, #eligible_sources, #getenv_any, #load_env_file, #resolve_env_paths, #resolve_policy, #system_user_name, #trusted_sources, #warn_if_legacy_tool_source, #warn_ignored_repository_values
Constructor Details
#initialize(legacy_checkout_root: nil, environment: ENV, stderr: $stderr, config_loader: nil) ⇒ EnvSourceLoader
Returns a new instance of EnvSourceLoader.
48 49 50 51 52 53 |
# File 'lib/codex_notify/env_source_loader.rb', line 48 def initialize(legacy_checkout_root: nil, environment: ENV, stderr: $stderr, config_loader: nil) @legacy_checkout_root = Pathname(legacy_checkout_root). if legacy_checkout_root @environment = environment @stderr = stderr @config_loader = config_loader || TrustedConfigLoader.new(environment:, stderr:) end |
Instance Method Details
#load(path: ConfigSupport::DEFAULT_ENV_PATH, explicit: false, config_path: nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/codex_notify/env_source_loader.rb', line 55 def load(path: ConfigSupport::DEFAULT_ENV_PATH, explicit: false, config_path: nil) process = Source.new(kind: :process, path: nil, values: @environment.to_h) files = resolve_env_paths(path, legacy_checkout_root:).map { |env_path| load_file(env_path, explicit:) } configs = @config_loader.load(explicit_path: config_path).map do |config| Source.new(kind: config.kind, path: config.path, values: config.values) end explicit_config, default_config = configs.partition { |source| source.kind == :config_explicit } ordered = if explicit [process, *explicit_config, *files, *default_config] else [process, *explicit_config, *default_config, *files] end SourceSet.new(ordered) end |