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_PATH =
Pathname.new(__FILE__).dirname. join('ollama_chat_config/default_config.yml')
- DEFAULT_CONFIG =
File.read(DEFAULT_CONFIG_PATH)
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_config_path ⇒ Object
- #default_path ⇒ Object
- #diff_tool ⇒ Object
-
#initialize(filename = nil) ⇒ OllamaChatConfig
constructor
A new instance of OllamaChatConfig.
Constructor Details
#initialize(filename = nil) ⇒ OllamaChatConfig
Returns a new instance of OllamaChatConfig.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 12 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.
32 33 34 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 32 def config @config end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
30 31 32 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 30 def filename @filename end |
Instance Method Details
#cache_dir_path ⇒ Object
46 47 48 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 46 def cache_dir_path XDG.new.cache_home + 'ollama_chat' end |
#config_dir_path ⇒ Object
42 43 44 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 42 def config_dir_path XDG.new.config_home + 'ollama_chat' end |
#database_path ⇒ Object
50 51 52 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 50 def database_path cache_dir_path + 'documents.db' end |
#default_config_path ⇒ Object
34 35 36 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 34 def default_config_path DEFAULT_CONFIG_PATH end |
#default_path ⇒ Object
38 39 40 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 38 def default_path config_dir_path + 'config.yml' end |
#diff_tool ⇒ Object
54 55 56 |
# File 'lib/ollama_chat/ollama_chat_config.rb', line 54 def diff_tool ENV.fetch('DIFF_TOOL', 'vimdiff') end |