Class: AIRefactor::Refactors::BaseRefactor
- Inherits:
-
Object
- Object
- AIRefactor::Refactors::BaseRefactor
- Defined in:
- lib/ai_refactor/refactors/base_refactor.rb
Direct Known Subclasses
Custom, Minitest::WriteTestForClass, Project::WriteChangelogFromHistory, Rails::Minitest::RspecToMinitest, Rspec::MinitestToRspec, Ruby::WriteRbs
Instance Attribute Summary collapse
-
#ai_client ⇒ Object
readonly
Returns the value of attribute ai_client.
- #failed_message ⇒ Object
-
#input_content ⇒ Object
Returns the value of attribute input_content.
-
#input_file ⇒ Object
readonly
Returns the value of attribute input_file.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .command_line_options ⇒ Object
- .description ⇒ Object
-
.inherited(subclass) ⇒ Object
All subclasses must register themselves with the Registry.
- .refactor_name ⇒ Object
- .takes_input_files? ⇒ Boolean
Instance Method Summary collapse
-
#initialize(ai_client, input_file, options, logger) ⇒ BaseRefactor
constructor
A new instance of BaseRefactor.
- #run ⇒ Object
Constructor Details
#initialize(ai_client, input_file, options, logger) ⇒ BaseRefactor
Returns a new instance of BaseRefactor.
24 25 26 27 28 29 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 24 def initialize(ai_client, input_file, , logger) @ai_client = ai_client @input_file = input_file @options = @logger = logger end |
Instance Attribute Details
#ai_client ⇒ Object (readonly)
Returns the value of attribute ai_client.
20 21 22 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 20 def ai_client @ai_client end |
#failed_message ⇒ Object
35 36 37 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 35 def @failed_message || "Reason not specified" end |
#input_content ⇒ Object
Returns the value of attribute input_content.
21 22 23 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 21 def input_content @input_content end |
#input_file ⇒ Object (readonly)
Returns the value of attribute input_file.
20 21 22 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 20 def input_file @input_file end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
20 21 22 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 20 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 20 def @options end |
Class Method Details
.command_line_options ⇒ Object
187 188 189 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 187 def [] end |
.description ⇒ Object
12 13 14 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 12 def self.description "(No description provided)" end |
.inherited(subclass) ⇒ Object
All subclasses must register themselves with the Registry
7 8 9 10 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 7 def self.inherited(subclass) super Refactors.register(subclass) end |
.refactor_name ⇒ Object
191 192 193 194 195 196 197 198 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 191 def refactor_name name.gsub("AIRefactor::Refactors::", "") .gsub(/::/, "/") .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr("-", "_") .downcase end |
.takes_input_files? ⇒ Boolean
16 17 18 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 16 def self.takes_input_files? true end |
Instance Method Details
#run ⇒ Object
31 32 33 |
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 31 def run raise NotImplementedError end |