Class: Ocak::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/ocak/config.rb
Defined Under Namespace
Classes: ConfigError, ConfigNotFound
Constant Summary
collapse
- CONFIG_FILE =
'ocak.yml'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data, project_dir = Dir.pwd) ⇒ Config
Returns a new instance of Config.
18
19
20
21
22
23
|
# File 'lib/ocak/config.rb', line 18
def initialize(data, project_dir = Dir.pwd)
@data = data || {}
@project_dir = project_dir
@overrides = {}
validate!
end
|
Instance Attribute Details
#project_dir ⇒ Object
Returns the value of attribute project_dir.
9
10
11
|
# File 'lib/ocak/config.rb', line 9
def project_dir
@project_dir
end
|
Class Method Details
.load(dir = Dir.pwd) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/ocak/config.rb', line 11
def self.load(dir = Dir.pwd)
path = File.join(dir, CONFIG_FILE)
raise ConfigNotFound, "No ocak.yml found in #{dir}. Run `ocak init` first." unless File.exist?(path)
new(YAML.safe_load_file(path, symbolize_names: true), dir)
end
|
Instance Method Details
#agent_path(name) ⇒ Object
73
74
75
76
77
78
|
# File 'lib/ocak/config.rb', line 73
def agent_path(name)
custom = dig(:agents, name.to_sym)
return File.join(@project_dir, custom) if custom
File.join(@project_dir, '.claude', 'agents', "#{name.to_s.tr('_', '-')}.md")
end
|
#allowed_authors ⇒ Object
57
|
# File 'lib/ocak/config.rb', line 57
def allowed_authors = dig(:safety, :allowed_authors) || []
|
#cost_budget ⇒ Object
54
|
# File 'lib/ocak/config.rb', line 54
def cost_budget = dig(:pipeline, :cost_budget)
|
34
|
# File 'lib/ocak/config.rb', line 34
def format_command = dig(:stack, :format_command)
|
#framework ⇒ Object
31
|
# File 'lib/ocak/config.rb', line 31
def framework = dig(:stack, :framework)
|
#label_completed ⇒ Object
64
|
# File 'lib/ocak/config.rb', line 64
def label_completed = dig(:labels, :completed) || 'completed'
|
#label_failed ⇒ Object
65
|
# File 'lib/ocak/config.rb', line 65
def label_failed = dig(:labels, :failed) || 'pipeline-failed'
|
#label_in_progress ⇒ Object
63
|
# File 'lib/ocak/config.rb', line 63
def label_in_progress = dig(:labels, :in_progress) || 'in-progress'
|
#label_ready ⇒ Object
62
|
# File 'lib/ocak/config.rb', line 62
def label_ready = dig(:labels, :ready) || 'auto-ready'
|
#language ⇒ Object
30
|
# File 'lib/ocak/config.rb', line 30
def language = dig(:stack, :language) || 'unknown'
|
#lint_check_command ⇒ Object
Returns the lint command with auto-fix flags stripped, suitable for check-only verification.
38
39
40
41
42
43
|
# File 'lib/ocak/config.rb', line 38
def lint_check_command
cmd = lint_command
return nil unless cmd
cmd.gsub(/\s+(?:-A|--fix|--write|--allow-dirty)\b/, '').strip
end
|
#lint_command ⇒ Object
33
|
# File 'lib/ocak/config.rb', line 33
def lint_command = dig(:stack, :lint_command)
|
#log_dir ⇒ Object
53
|
# File 'lib/ocak/config.rb', line 53
def log_dir = dig(:pipeline, :log_dir) || 'logs/pipeline'
|
#max_issues_per_run ⇒ Object
59
|
# File 'lib/ocak/config.rb', line 59
def max_issues_per_run = dig(:safety, :max_issues_per_run) || 5
|
#max_parallel ⇒ Object
50
|
# File 'lib/ocak/config.rb', line 50
def max_parallel = @overrides[:max_parallel] || dig(:pipeline, :max_parallel) || 3
|
#override(key, value) ⇒ Object
25
26
27
|
# File 'lib/ocak/config.rb', line 25
def override(key, value)
@overrides[key] = value
end
|
#poll_interval ⇒ Object
51
|
# File 'lib/ocak/config.rb', line 51
def poll_interval = @overrides[:poll_interval] || dig(:pipeline, :poll_interval) || 60
|
58
|
# File 'lib/ocak/config.rb', line 58
def = dig(:safety, :require_comment)
|
#security_commands ⇒ Object
45
46
47
|
# File 'lib/ocak/config.rb', line 45
def security_commands
dig(:stack, :security_commands) || []
end
|
#setup_command ⇒ Object
35
|
# File 'lib/ocak/config.rb', line 35
def setup_command = dig(:stack, :setup_command)
|
#steps ⇒ Object
68
69
70
|
# File 'lib/ocak/config.rb', line 68
def steps
@data[:steps] || default_steps
end
|
#test_command ⇒ Object
32
|
# File 'lib/ocak/config.rb', line 32
def test_command = dig(:stack, :test_command)
|
#worktree_dir ⇒ Object
52
|
# File 'lib/ocak/config.rb', line 52
def worktree_dir = dig(:pipeline, :worktree_dir) || '.claude/worktrees'
|