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 =
Returns Filename for the main settings file.
'settings.json'- LOCAL_SETTINGS_FILE =
Returns Filename for the local settings override file.
'settings.local.json'- BEHAVIOUR_DIR =
Returns Relative path to the behaviour configuration directory.
'conf/behaviour'- SCHEMA_DIR =
Returns Relative path to the JSON Schema directory.
'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! ⇒ void
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.
29 30 31 |
# File 'lib/rosett_ai/configuration.rb', line 29 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.
22 23 24 |
# File 'lib/rosett_ai/configuration.rb', line 22 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.
57 58 59 |
# File 'lib/rosett_ai/configuration.rb', line 57 def behaviour_files @behaviour_files ||= Dir.glob(behaviour_path.join('*.yml')) end |
#behaviour_path ⇒ Pathname
Returns the path to the behaviour configuration directory.
64 65 66 |
# File 'lib/rosett_ai/configuration.rb', line 64 def behaviour_path root_path.join(BEHAVIOUR_DIR) end |
#local_settings ⇒ Hash
Returns the parsed local overrides from settings.local.json.
43 44 45 |
# File 'lib/rosett_ai/configuration.rb', line 43 def local_settings @local_settings ||= load_local_settings end |
#merged_settings ⇒ Hash
Returns global settings deep-merged with local overrides.
50 51 52 |
# File 'lib/rosett_ai/configuration.rb', line 50 def merged_settings @merged_settings ||= deep_merge(settings, local_settings) end |
#reload! ⇒ void
This method returns an undefined value.
Clears all memoized state so the next access re-reads from disk.
78 79 80 81 82 83 |
# File 'lib/rosett_ai/configuration.rb', line 78 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.
71 72 73 |
# File 'lib/rosett_ai/configuration.rb', line 71 def schema_path root_path.join(SCHEMA_DIR) end |
#settings ⇒ Hash
Returns the parsed global settings from settings.json.
36 37 38 |
# File 'lib/rosett_ai/configuration.rb', line 36 def settings @settings ||= load_settings end |