Sha256: 2388563178ea58e713abf8b5eb1b9ea599730f87e94781e5da0313bdb0b55fc6

Contents?: true

Size: 930 Bytes

Versions: 1

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

module AIRefactor
  module Refactors
    class Generic
      attr_reader :input_file, :options, :logger

      def initialize(input_file, options, logger)
        @input_file = input_file
        @options = options
        @logger = logger
      end

      def run
        raise "Not implemented"
      end

      private

      def ai_client
        @ai_client ||= OpenAI::Client.new
      end

      class << self
        def command_line_options
          []
        end

        def refactor_name
          name.split("::")
            .last
            .gsub(/::/, "/")
            .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
            .gsub(/([a-z\d])([A-Z])/, '\1_\2')
            .tr("-", "_")
            .downcase
        end

        def prompt_file_path
          File.join(File.dirname(File.expand_path(__FILE__)), "prompts", "#{refactor_name}.md")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ai_refactor-0.1.0 lib/ai_refactor/refactors/generic.rb