Class: RubyClaude::Configuration
- Inherits:
-
Object
- Object
- RubyClaude::Configuration
- Defined in:
- lib/ruby_claude/configuration.rb
Overview
Instance Attribute Summary collapse
-
#add_dirs ⇒ Array<String>
Directories for repeated
--add-dir. -
#allowed_tools ⇒ Array<String>, ...
Tools for
--allowedTools. -
#append_system_prompt ⇒ String?
Text for
--append-system-prompt. -
#binary ⇒ String
Executable name or path of the CLI.
-
#cwd ⇒ String?
Working directory for the subprocess.
-
#disallowed_tools ⇒ Array<String>, ...
Tools for
--disallowedTools. -
#max_turns ⇒ Integer?
Limit for
--max-turns. -
#model ⇒ String?
Model for
--model(nil uses the CLI default). -
#permission_mode ⇒ String?
Mode for
--permission-mode. -
#timeout ⇒ Integer
Seconds before the child process is killed.
-
#use_subscription ⇒ Boolean
When true, strip
ANTHROPIC_API_KEYfrom the child env.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#merge(overrides) ⇒ Configuration
Return a copy with the given overrides applied.
-
#to_h ⇒ Hash{Symbol => Object}
A plain-hash view of the configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby_claude/configuration.rb', line 43 def initialize @binary = "claude" @model = nil @cwd = Dir.pwd @timeout = 300 @use_subscription = true @append_system_prompt = nil @allowed_tools = nil @disallowed_tools = nil @add_dirs = [] @permission_mode = nil @max_turns = nil end |
Instance Attribute Details
#add_dirs ⇒ Array<String>
Returns directories for repeated --add-dir.
35 36 37 |
# File 'lib/ruby_claude/configuration.rb', line 35 def add_dirs @add_dirs end |
#allowed_tools ⇒ Array<String>, ...
Returns tools for --allowedTools.
29 30 31 |
# File 'lib/ruby_claude/configuration.rb', line 29 def allowed_tools @allowed_tools end |
#append_system_prompt ⇒ String?
Returns text for --append-system-prompt.
26 27 28 |
# File 'lib/ruby_claude/configuration.rb', line 26 def append_system_prompt @append_system_prompt end |
#binary ⇒ String
Returns executable name or path of the CLI.
11 12 13 |
# File 'lib/ruby_claude/configuration.rb', line 11 def binary @binary end |
#cwd ⇒ String?
Returns working directory for the subprocess.
17 18 19 |
# File 'lib/ruby_claude/configuration.rb', line 17 def cwd @cwd end |
#disallowed_tools ⇒ Array<String>, ...
Returns tools for --disallowedTools.
32 33 34 |
# File 'lib/ruby_claude/configuration.rb', line 32 def disallowed_tools @disallowed_tools end |
#max_turns ⇒ Integer?
Returns limit for --max-turns.
41 42 43 |
# File 'lib/ruby_claude/configuration.rb', line 41 def max_turns @max_turns end |
#model ⇒ String?
Returns model for --model (nil uses the CLI default).
14 15 16 |
# File 'lib/ruby_claude/configuration.rb', line 14 def model @model end |
#permission_mode ⇒ String?
Returns mode for --permission-mode.
38 39 40 |
# File 'lib/ruby_claude/configuration.rb', line 38 def @permission_mode end |
#timeout ⇒ Integer
Returns seconds before the child process is killed.
20 21 22 |
# File 'lib/ruby_claude/configuration.rb', line 20 def timeout @timeout end |
#use_subscription ⇒ Boolean
Returns when true, strip ANTHROPIC_API_KEY from the child env.
23 24 25 |
# File 'lib/ruby_claude/configuration.rb', line 23 def use_subscription @use_subscription end |
Instance Method Details
#merge(overrides) ⇒ Configuration
Return a copy with the given overrides applied. The receiver is left untouched, so the global configuration is never mutated by a RubyClaude::Client.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ruby_claude/configuration.rb', line 63 def merge(overrides) dup.tap do |copy| overrides.each do |key, value| setter = "#{key}=" raise ArgumentError, "unknown configuration option: #{key}" unless copy.respond_to?(setter) copy.public_send(setter, value) end end end |
#to_h ⇒ Hash{Symbol => Object}
Returns a plain-hash view of the configuration.
75 76 77 78 79 80 81 82 |
# File 'lib/ruby_claude/configuration.rb', line 75 def to_h { binary: binary, model: model, cwd: cwd, timeout: timeout, use_subscription: use_subscription, append_system_prompt: append_system_prompt, allowed_tools: allowed_tools, disallowed_tools: disallowed_tools, add_dirs: add_dirs, permission_mode: , max_turns: max_turns } end |