Class: Aircon::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/aircon/configuration.rb

Constant Summary collapse

CONFIG_FILE =
".aircon/aircon.yml"
VALID_CREDENTIALS_SOURCES =
%w[keychain file oauth_token api_key].freeze
DEFAULTS =
{
  "compose_file" => ".aircon/docker-compose.yml",
  "app_name" => nil,
  "gh_token" => nil,
  "credentials_source" => "keychain",
  "claude_code_oauth_token" => nil,
  "anthropic_api_key" => nil,
  "workspace_path" => nil,
  "claude_config_path" => "~/.claude.json",
  "claude_dir_path" => "~/.claude",
  "service" => "app",
  "git_email" => "claude_docker@localhost.com",
  "git_name" => "Claude Docker",
  "container_user" => "appuser",
  "init_script" => ".aircon/aircon_init.sh"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir: Dir.pwd) ⇒ Configuration

Returns a new instance of Configuration.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/aircon/configuration.rb', line 32

def initialize(dir: Dir.pwd)
  attrs = DEFAULTS.dup
  config_path = File.join(dir, CONFIG_FILE)

  if File.exist?(config_path)
    raw = File.read(config_path)
    rendered = ERB.new(raw).result
    user_attrs = YAML.safe_load(rendered) || {}
    attrs.merge!(user_attrs)
  end

  @compose_file = attrs["compose_file"]
  @app_name = attrs["app_name"] || File.basename(dir)
  @gh_token = attrs["gh_token"]
  @credentials_source = attrs["credentials_source"]
  @claude_code_oauth_token = attrs["claude_code_oauth_token"]
  @anthropic_api_key = attrs["anthropic_api_key"]
  @workspace_path = attrs["workspace_path"] || "/workspace"
  @claude_config_path = attrs["claude_config_path"]
  @claude_dir_path = attrs["claude_dir_path"]
  @service = attrs["service"]
  @git_email = attrs["git_email"]
  @git_name = attrs["git_name"]
  @container_user = attrs["container_user"]
  @init_script = attrs["init_script"]

  validate!
end

Instance Attribute Details

#anthropic_api_keyObject (readonly)

Returns the value of attribute anthropic_api_key.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def anthropic_api_key
  @anthropic_api_key
end

#app_nameObject (readonly)

Returns the value of attribute app_name.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def app_name
  @app_name
end

#claude_code_oauth_tokenObject (readonly)

Returns the value of attribute claude_code_oauth_token.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def claude_code_oauth_token
  @claude_code_oauth_token
end

#claude_config_pathObject (readonly)

Returns the value of attribute claude_config_path.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def claude_config_path
  @claude_config_path
end

#claude_dir_pathObject (readonly)

Returns the value of attribute claude_dir_path.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def claude_dir_path
  @claude_dir_path
end

#compose_fileObject (readonly)

Returns the value of attribute compose_file.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def compose_file
  @compose_file
end

#container_userObject (readonly)

Returns the value of attribute container_user.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def container_user
  @container_user
end

#credentials_sourceObject (readonly)

Returns the value of attribute credentials_source.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def credentials_source
  @credentials_source
end

#gh_tokenObject (readonly)

Returns the value of attribute gh_token.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def gh_token
  @gh_token
end

#git_emailObject (readonly)

Returns the value of attribute git_email.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def git_email
  @git_email
end

#git_nameObject (readonly)

Returns the value of attribute git_name.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def git_name
  @git_name
end

#init_scriptObject (readonly)

Returns the value of attribute init_script.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def init_script
  @init_script
end

#serviceObject (readonly)

Returns the value of attribute service.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def service
  @service
end

#workspace_pathObject (readonly)

Returns the value of attribute workspace_path.



28
29
30
# File 'lib/aircon/configuration.rb', line 28

def workspace_path
  @workspace_path
end

Instance Method Details

#container_homeObject



61
62
63
# File 'lib/aircon/configuration.rb', line 61

def container_home
  @container_user == "root" ? "/root" : "/home/#{@container_user}"
end