Module: OllamaChat::ConfigHandling
Overview
Provides functionality for handling configuration files and settings for OllamaChat. It loads configuration from YAML files, supports environment variable overrides, and offers methods to read and write configuration data. The module also ensures default values are set and validates configuration structure.
Instance Method Summary collapse
-
#config ⇒ ComplexConfig::Settings
The config method returns the configuration object associated with the class.
-
#run_syntax_check(checker, path) ⇒ Hash?
Runs the syntax checker on the given file and returns a result hash.
-
#syntax_checker_for(path) ⇒ ComplexConfig::Settings?
Returns the first enabled syntax checker whose suffixes match the given file's extension, or nil if no match.
Instance Method Details
#config ⇒ ComplexConfig::Settings
The config method returns the configuration object associated with the class.
21 22 23 |
# File 'lib/ollama_chat/config_handling.rb', line 21 def config self.class.config end |
#run_syntax_check(checker, path) ⇒ Hash?
Runs the syntax checker on the given file and returns a result hash.
45 46 47 48 49 50 51 52 53 |
# File 'lib/ollama_chat/config_handling.rb', line 45 def run_syntax_check(checker, path) _stdout, stderr, status = Open3.capture3(*checker.cmd, path.to_s) { status: status.success? ? 'pass' : 'fail', output: stderr.strip } rescue Errno::ENOENT nil end |
#syntax_checker_for(path) ⇒ ComplexConfig::Settings?
Returns the first enabled syntax checker whose suffixes match the given file's extension, or nil if no match.
30 31 32 33 34 35 36 37 38 |
# File 'lib/ollama_chat/config_handling.rb', line 30 def syntax_checker_for(path) path = Pathname.new(path) ext = path.extname.delete_prefix(?.).full? or return config.syntax_checkers.attribute_values.each do |checker| next unless checker.enabled return checker if checker.suffixes.include?(ext) end nil end |