Skip to content

Commit 7a3fad7

Browse files
committed
Not a class method and fix reference to built in prompt paths
1 parent effb54d commit 7a3fad7

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

lib/ai_refactor/base_refactor.rb

+8-12
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ def can_overwrite_output_file?(output_path)
3333
end
3434

3535
def prompt_file_path
36-
self.class.prompt_file_path
36+
file = if options && options[:prompt_file_path]&.length&.positive?
37+
options[:prompt_file_path]
38+
else
39+
File.join(File.dirname(File.expand_path(__FILE__)), "refactors", "prompts", "#{refactor_name}.md")
40+
end
41+
file.tap do |prompt|
42+
raise "No prompt file '#{prompt}' found for #{refactor_name}" unless File.exist?(prompt)
43+
end
3744
end
3845

3946
def ai_client
@@ -54,17 +61,6 @@ def refactor_name
5461
.tr("-", "_")
5562
.downcase
5663
end
57-
58-
def prompt_file_path
59-
file = if options && options[:prompt_file_path]&.length&.positive?
60-
options[:prompt_file_path]
61-
else
62-
File.join(File.dirname(File.expand_path(__FILE__)), "prompts", "#{refactor_name}.md")
63-
end
64-
file.tap do |prompt|
65-
raise "No prompt file '#{prompt}' found for #{refactor_name}" unless File.exist?(prompt)
66-
end
67-
end
6864
end
6965
end
7066
end

lib/ai_refactor/refactors/generic.rb

-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ def prompt_file_path
9191
end
9292

9393
class << self
94-
def prompt_file_path
95-
raise "Generic refactor requires prompt file to be user specified."
96-
end
97-
9894
def command_line_options
9995
[
10096
{

0 commit comments

Comments
 (0)