Class: AIRefactor::Refactors::BaseRefactor

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, options, logger)
  @ai_client = ai_client
  @input_file = input_file
  @options = options
  @logger = logger
end

Instance Attribute Details

#ai_clientObject (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_messageObject



35
36
37
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 35

def failed_message
  @failed_message || "Reason not specified"
end

#input_contentObject

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_fileObject (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

#loggerObject (readonly)

Returns the value of attribute logger.



20
21
22
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 20

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 20

def options
  @options
end

Class Method Details

.command_line_optionsObject



187
188
189
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 187

def command_line_options
  []
end

.descriptionObject



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_nameObject



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

Returns:

  • (Boolean)


16
17
18
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 16

def self.takes_input_files?
  true
end

Instance Method Details

#runObject

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/ai_refactor/refactors/base_refactor.rb', line 31

def run
  raise NotImplementedError
end