Class: Committer::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/committer/config.rb

Overview

Configuration management for the Committer gem

Constant Summary collapse

CONFIG_DIR =
File.join(Dir.home, '.committer')
CONFIG_FILE =
File.join(CONFIG_DIR, 'config.yml')
DEFAULT_CONFIG =
{
  'api_key' => nil,
  'model' => 'claude-3-7-sonnet-20250219',
  'scopes' => nil
}.freeze

Class Method Summary collapse

Class Method Details

.create_default_configObject



28
29
30
31
# File 'lib/committer/config.rb', line 28

def self.create_default_config
  FileUtils.mkdir_p(CONFIG_DIR)
  File.write(CONFIG_FILE, DEFAULT_CONFIG.to_yaml)
end

.loadObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/committer/config.rb', line 17

def self.load
  create_default_config unless File.exist?(CONFIG_FILE)
  begin
    YAML.load_file(CONFIG_FILE) || DEFAULT_CONFIG
  rescue StandardError => e
    # Use $stdout directly for better test capture
    $stdout.puts "Error loading config: #{e.message}"
    DEFAULT_CONFIG
  end
end

.setupObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/committer/config.rb', line 33

def self.setup
  create_default_config
  puts 'Created config file at:'
  puts CONFIG_FILE
  puts "\nPlease edit this file to add your Anthropic API key."
  puts 'Example config format:'
  puts '---'
  puts 'api_key: your_api_key_here'
  puts 'model: claude-3-7-sonnet-20250219'
  puts 'scopes:'
  puts '  - feature'
  puts '  - api'
  puts '  - ui'
end