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" } } }.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
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
40 41 42 43 |
# File 'lib/git_auto/config/settings.rb', line 40 def initialize ensure_config_dir @settings = load_settings end |
Instance Method Details
#all ⇒ Object
55 56 57 |
# File 'lib/git_auto/config/settings.rb', line 55 def all @settings end |
#available_models ⇒ Object
63 64 65 |
# File 'lib/git_auto/config/settings.rb', line 63 def available_models provider_info[:models] end |
#get(key) ⇒ Object
51 52 53 |
# File 'lib/git_auto/config/settings.rb', line 51 def get(key) @settings[key.to_sym] end |
#provider_info ⇒ Object
59 60 61 |
# File 'lib/git_auto/config/settings.rb', line 59 def provider_info SUPPORTED_PROVIDERS[get(:ai_provider)] end |
#save(options = {}) ⇒ Object
45 46 47 48 49 |
# File 'lib/git_auto/config/settings.rb', line 45 def save( = {}) validate_settings!() @settings = @settings.merge() File.write(CONFIG_FILE, YAML.dump(@settings)) end |