Skip to content

Commit

Permalink
Not a class method and fix reference to built in prompt paths
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegeek committed May 25, 2023
1 parent effb54d commit 7a3fad7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
20 changes: 8 additions & 12 deletions lib/ai_refactor/base_refactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ def can_overwrite_output_file?(output_path)
end

def prompt_file_path
self.class.prompt_file_path
file = if options && options[:prompt_file_path]&.length&.positive?
options[:prompt_file_path]
else
File.join(File.dirname(File.expand_path(__FILE__)), "refactors", "prompts", "#{refactor_name}.md")
end
file.tap do |prompt|
raise "No prompt file '#{prompt}' found for #{refactor_name}" unless File.exist?(prompt)
end
end

def ai_client
Expand All @@ -54,17 +61,6 @@ def refactor_name
.tr("-", "_")
.downcase
end

def prompt_file_path
file = if options && options[:prompt_file_path]&.length&.positive?
options[:prompt_file_path]
else
File.join(File.dirname(File.expand_path(__FILE__)), "prompts", "#{refactor_name}.md")
end
file.tap do |prompt|
raise "No prompt file '#{prompt}' found for #{refactor_name}" unless File.exist?(prompt)
end
end
end
end
end
4 changes: 0 additions & 4 deletions lib/ai_refactor/refactors/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ def prompt_file_path
end

class << self
def prompt_file_path
raise "Generic refactor requires prompt file to be user specified."
end

def command_line_options
[
{
Expand Down

0 comments on commit 7a3fad7

Please sign in to comment.