Class: Canon::Config::ProfileLoader
- Inherits:
-
Object
- Object
- Canon::Config::ProfileLoader
- Defined in:
- lib/canon/config/profile_loader.rb
Overview
Loads configuration profiles from YAML files. Supports built-in profiles (shipped with the gem) and external file paths. Profiles can inherit from other profiles via the inherits key.
Constant Summary collapse
- PROFILES_DIR =
File.("profiles", __dir__).freeze
Class Method Summary collapse
-
.available_profiles ⇒ Object
List available built-in profile names.
-
.load(name_or_path) ⇒ Object
Load a profile by name (Symbol for built-in) or file path (String).
- .reset_cache! ⇒ Object
Class Method Details
.available_profiles ⇒ Object
List available built-in profile names.
23 24 25 26 27 28 29 |
# File 'lib/canon/config/profile_loader.rb', line 23 def available_profiles return [] unless Dir.exist?(PROFILES_DIR) Dir.glob(File.join(PROFILES_DIR, "*.yml")).map do |path| File.basename(path, ".yml").to_sym end.sort end |
.load(name_or_path) ⇒ Object
Load a profile by name (Symbol for built-in) or file path (String). Returns a merged Hash with inheritance resolved.
17 18 19 20 |
# File 'lib/canon/config/profile_loader.rb', line 17 def load(name_or_path) key = cache_key(name_or_path) cache[key] ||= resolve(name_or_path, []) end |
.reset_cache! ⇒ Object
31 32 33 |
# File 'lib/canon/config/profile_loader.rb', line 31 def reset_cache! @cache = nil end |