Class: OllamaChat::OllamaChatConfig
- Inherits:
-
Object
- Object
- OllamaChat::OllamaChatConfig
- Includes:
- ComplexConfig, FileUtils
- Defined in:
- lib/ollama_chat/ollama_chat_config.rb
Constant Summary collapse
- DEFAULT_CONFIG =
File.read( Pathname.new(__FILE__).dirname.join('ollama_chat_config/default_config.yml') )
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #cache_dir_path ⇒ Object
- #config_dir_path ⇒ Object
- #database_path ⇒ Object
- #default_path ⇒ Object
-
#initialize(filename = nil) ⇒ OllamaChatConfig
constructor
A new instance of OllamaChatConfig.
Constructor Details
#initialize(filename = nil) ⇒ OllamaChatConfig
Returns a new instance of OllamaChatConfig.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 11 def initialize(filename = nil) @filename = filename || default_path unless File.directory?(cache_dir_path) mkdir_p cache_dir_path.to_s end @config = Provider.config(@filename, '⚙️') retried = false rescue ConfigurationFileMissing if @filename == default_path && !retried retried = true mkdir_p config_dir_path.to_s File.secure_write(default_path, DEFAULT_CONFIG) retry else raise end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
31 32 33 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 31 def config @config end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
29 30 31 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 29 def filename @filename end |
Instance Method Details
#cache_dir_path ⇒ Object
41 42 43 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 41 def cache_dir_path XDG.new.cache_home + 'ollama_chat' end |
#config_dir_path ⇒ Object
37 38 39 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 37 def config_dir_path XDG.new.config_home + 'ollama_chat' end |
#database_path ⇒ Object
45 46 47 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 45 def database_path cache_dir_path + 'documents.db' end |
#default_path ⇒ Object
33 34 35 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 33 def default_path config_dir_path + 'config.yml' end |