Class: AIRefactor::Refactors::Custom
- Inherits:
-
BaseRefactor
- Object
- BaseRefactor
- AIRefactor::Refactors::Custom
- Defined in:
- lib/ai_refactor/refactors/custom.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BaseRefactor
#ai_client, #failed_message, #input_content, #input_file, #logger, #options
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseRefactor
command_line_options, inherited, #initialize, refactor_name, takes_input_files?
Constructor Details
This class inherits a constructor from AIRefactor::Refactors::BaseRefactor
Class Method Details
.description ⇒ Object
22 23 24 |
# File 'lib/ai_refactor/refactors/custom.rb', line 22 def self.description "Generic refactor using user supplied prompt" end |
Instance Method Details
#run ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ai_refactor/refactors/custom.rb', line 6 def run logger.verbose "Custom refactor to #{input_file}... (using user supplied prompt #{prompt_file_path || "from options"})" logger.verbose "Write output to #{output_file_path}..." if output_file_path begin output_content = process!(strip_ticks: false) rescue => e logger.error "Failed to process #{input_file}: #{e.}" return false end return false unless output_content output_file_path ? true : output_content end |