Class: AIRefactor::RunConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_refactor/run_configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ai_max_tokensObject



125
126
127
# File 'lib/ai_refactor/run_configuration.rb', line 125

def ai_max_tokens
  @ai_max_tokens || 1500
end

#ai_temperatureObject



119
120
121
# File 'lib/ai_refactor/run_configuration.rb', line 119

def ai_temperature
  @ai_temperature || 0.7
end

#ai_timeoutObject



131
132
133
# File 'lib/ai_refactor/run_configuration.rb', line 131

def ai_timeout
  @ai_timeout || 60
end

#context_file_pathsObject

Returns the value of attribute context_file_paths.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def context_file_paths
  @context_file_paths
end

#context_file_paths_from_gemsObject

Returns the value of attribute context_file_paths_from_gems.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def context_file_paths_from_gems
  @context_file_paths_from_gems
end

#context_textObject

Returns the value of attribute context_text.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def context_text
  @context_text
end

#debugObject

Returns the value of attribute debug.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def debug
  @debug
end

#descriptionObject

Returns the value of attribute description.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def description
  @description
end

#diffObject

Returns the value of attribute diff.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def diff
  @diff
end

#input_file_pathsObject

Returns the value of attribute input_file_paths.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def input_file_paths
  @input_file_paths
end

#minitest_run_commandObject



88
89
90
# File 'lib/ai_refactor/run_configuration.rb', line 88

def minitest_run_command
  @minitest_run_command || "ruby __FILE__"
end

#output_file_pathObject

Returns the value of attribute output_file_path.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def output_file_path
  @output_file_path
end

#output_template_pathObject

Returns the value of attribute output_template_path.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def output_template_path
  @output_template_path
end

#overwriteObject

Returns the value of attribute overwrite.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def overwrite
  @overwrite
end

#promptObject

Returns the value of attribute prompt.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def prompt
  @prompt
end

#prompt_file_pathObject

Returns the value of attribute prompt_file_path.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def prompt_file_path
  @prompt_file_path
end

#refactorObject

Returns the value of attribute refactor.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def refactor
  @refactor
end

#review_promptObject

Returns the value of attribute review_prompt.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def review_prompt
  @review_prompt
end

#rspec_run_commandObject



84
85
86
# File 'lib/ai_refactor/run_configuration.rb', line 84

def rspec_run_command
  @rspec_run_command || "bundle exec rspec __FILE__"
end

#verboseObject

Returns the value of attribute verbose.



10
11
12
# File 'lib/ai_refactor/run_configuration.rb', line 10

def verbose
  @verbose
end

Class Method Details

.add_new_option(key) ⇒ Object



5
6
7
8
# File 'lib/ai_refactor/run_configuration.rb', line 5

def self.add_new_option(key)
  self.class.define_method(key) { instance_variable_get("@#{key}") }
  self.class.define_method("#{key}=") { |v| instance_variable_set("@#{key}", v) }
end

Instance Method Details

#[](key) ⇒ Object

Deprecated.


36
37
38
# File 'lib/ai_refactor/run_configuration.rb', line 36

def [](key)
  send(key)
end

#ai_max_attemptsObject



95
96
97
# File 'lib/ai_refactor/run_configuration.rb', line 95

def ai_max_attempts
  @ai_max_attempts || 3
end

#ai_max_attempts=(value) ⇒ Object



99
100
101
# File 'lib/ai_refactor/run_configuration.rb', line 99

def ai_max_attempts=(value)
  @ai_max_attempts = value
end

#ai_modelObject



103
104
105
# File 'lib/ai_refactor/run_configuration.rb', line 103

def ai_model
  @ai_model || "gpt-4-turbo"
end

#ai_model=(value) ⇒ Object



107
108
109
# File 'lib/ai_refactor/run_configuration.rb', line 107

def ai_model=(value)
  @ai_model = value
end

#ai_platformObject



111
112
113
114
115
116
117
# File 'lib/ai_refactor/run_configuration.rb', line 111

def ai_platform
  if ai_model&.start_with?("claude")
    "anthropic"
  else
    "openai"
  end
end

#set!(hash) ⇒ Object



26
27
28
29
30
31
# File 'lib/ai_refactor/run_configuration.rb', line 26

def set!(hash)
  hash.each do |key, value|
    raise StandardError, "Invalid option: #{key}" unless respond_to?("#{key}=")
    send("#{key}=", value)
  end
end

#to_optionsObject



149
150
151
152
153
# File 'lib/ai_refactor/run_configuration.rb', line 149

def to_options
  instance_variables.each_with_object({}) do |var, hash|
    hash[var.to_s.delete("@").to_sym] = instance_variable_get(var)
  end
end