Class: GitAuto::Config::Settings
- Inherits:
-
Object
- Object
- GitAuto::Config::Settings
- Defined in:
- lib/git_auto/config/settings.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- CONFIG_DIR =
File.("~/.git_auto")
- CONFIG_FILE =
File.join(CONFIG_DIR, "config.yml")
- SUPPORTED_PROVIDERS =
{ "claude" => { name: "Anthropic (Claude 3.5 Sonnet, Claude 3.5 Haiku)", models: { "Claude 3.5 Sonnet" => "claude-3-5-sonnet-latest", "Claude 3.5 Haiku" => "claude-3-5-haiku-latest" } }, "openai" => { name: "OpenAI (GPT-4o, GPT-4o mini)", models: { "GPT-4o" => "gpt-4o", "GPT-4o mini" => "gpt-4o-mini" } }, "gemini" => { name: "Google (Gemini 2.5 Flash)", models: { "Gemini 2.5 Flash Preview" => "gemini-2.5-flash-preview-05-20" } } }.freeze
- DEFAULT_SETTINGS =
{ commit_style: "conventional", ai_provider: "openai", ai_model: "gpt-4o", show_diff: true, save_history: true, max_retries: 3 }.freeze
Instance Method Summary collapse
- #all ⇒ Object
- #available_models ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #provider_info ⇒ Object
- #save(options = {}) ⇒ Object
- #set(key, value) ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
46 47 48 49 |
# File 'lib/git_auto/config/settings.rb', line 46 def initialize ensure_config_dir @settings = load_settings end |
Instance Method Details
#all ⇒ Object
66 67 68 |
# File 'lib/git_auto/config/settings.rb', line 66 def all @settings end |
#available_models ⇒ Object
74 75 76 |
# File 'lib/git_auto/config/settings.rb', line 74 def available_models provider_info[:models] end |
#get(key) ⇒ Object
57 58 59 |
# File 'lib/git_auto/config/settings.rb', line 57 def get(key) @settings[key.to_sym] end |
#provider_info ⇒ Object
70 71 72 |
# File 'lib/git_auto/config/settings.rb', line 70 def provider_info SUPPORTED_PROVIDERS[get(:ai_provider)] end |
#save(options = {}) ⇒ Object
51 52 53 54 55 |
# File 'lib/git_auto/config/settings.rb', line 51 def save( = {}) validate_settings!() @settings = @settings.merge() File.write(CONFIG_FILE, YAML.dump(@settings)) end |
#set(key, value) ⇒ Object
61 62 63 64 |
# File 'lib/git_auto/config/settings.rb', line 61 def set(key, value) @settings[key.to_sym] = value save end |