Class: RosettAi::Configuration
- Inherits:
-
Object
- Object
- RosettAi::Configuration
- Defined in:
- lib/rosett_ai/configuration.rb
Overview
Manages hierarchical configuration for Rosett-AI Supports global -> group -> project configuration inheritance
Constant Summary collapse
- SETTINGS_FILE =
'settings.json'- LOCAL_SETTINGS_FILE =
'settings.local.json'- BEHAVIOUR_DIR =
'conf/behaviour'- SCHEMA_DIR =
'conf/schemas'
Instance Attribute Summary collapse
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
-
#behaviour_files ⇒ Array<String>
Returns the list of behaviour YAML files found in the behaviour directory.
-
#behaviour_path ⇒ Pathname
Returns the path to the behaviour configuration directory.
-
#initialize(root_path: nil) ⇒ Configuration
constructor
Initializes a new Configuration instance.
-
#local_settings ⇒ Hash
Returns the parsed local overrides from settings.local.json.
-
#merged_settings ⇒ Hash
Returns global settings deep-merged with local overrides.
-
#reload!
Clears all memoized state so the next access re-reads from disk.
-
#schema_path ⇒ Pathname
Returns the path to the JSON Schema directory.
-
#settings ⇒ Hash
Returns the parsed global settings from settings.json.
Constructor Details
#initialize(root_path: nil) ⇒ Configuration
Initializes a new Configuration instance.
25 26 27 |
# File 'lib/rosett_ai/configuration.rb', line 25 def initialize(root_path: nil) @root_path = resolve_root_path(root_path) end |
Instance Attribute Details
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
18 19 20 |
# File 'lib/rosett_ai/configuration.rb', line 18 def root_path @root_path end |
Instance Method Details
#behaviour_files ⇒ Array<String>
Returns the list of behaviour YAML files found in the behaviour directory.
53 54 55 |
# File 'lib/rosett_ai/configuration.rb', line 53 def behaviour_files @behaviour_files ||= Dir.glob(behaviour_path.join('*.yml')) end |
#behaviour_path ⇒ Pathname
Returns the path to the behaviour configuration directory.
60 61 62 |
# File 'lib/rosett_ai/configuration.rb', line 60 def behaviour_path root_path.join(BEHAVIOUR_DIR) end |
#local_settings ⇒ Hash
Returns the parsed local overrides from settings.local.json.
39 40 41 |
# File 'lib/rosett_ai/configuration.rb', line 39 def local_settings @local_settings ||= load_local_settings end |
#merged_settings ⇒ Hash
Returns global settings deep-merged with local overrides.
46 47 48 |
# File 'lib/rosett_ai/configuration.rb', line 46 def merged_settings @merged_settings ||= deep_merge(settings, local_settings) end |
#reload!
This method returns an undefined value.
Clears all memoized state so the next access re-reads from disk.
74 75 76 77 78 79 |
# File 'lib/rosett_ai/configuration.rb', line 74 def reload! @settings = nil @local_settings = nil @merged_settings = nil @behaviour_files = nil end |
#schema_path ⇒ Pathname
Returns the path to the JSON Schema directory.
67 68 69 |
# File 'lib/rosett_ai/configuration.rb', line 67 def schema_path root_path.join(SCHEMA_DIR) end |
#settings ⇒ Hash
Returns the parsed global settings from settings.json.
32 33 34 |
# File 'lib/rosett_ai/configuration.rb', line 32 def settings @settings ||= load_settings end |