Class: RubberDuck::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/rubber_duck/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_routeObject



26
27
28
29
# File 'lib/generators/rubber_duck/install_generator.rb', line 26

def add_route
	say "Adding engine mount point to routes.rb", :green
	route "mount RubberDuck::Engine => '/rubber_duck'"
end

#create_initializer_fileObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/rubber_duck/install_generator.rb', line 8

def create_initializer_file
	create_file "config/initializers/rubber_duck.rb", <<~CONTENT
		RubberDuck.configure do |config|
			# Get your API key from https://platform.openai.com
			config.openai_api_key = ENV["OPENAI_API_KEY"]
		
			# Model to use
			config.model = "gpt-5-nano"
		
			# Enable/disable the helper
			config.enabled = true
		
			# Number of log lines to send to AI for context
			config.log_lines = 50
		end
	CONTENT
end

#show_instructionsObject



31
32
33
34
35
36
37
# File 'lib/generators/rubber_duck/install_generator.rb', line 31

def show_instructions
	say "\n✅ RubberDuck installed!", :green
	say "\nNext steps:"
	say "  1. Add OPENAI_API_KEY to your .env file"
	say "  2. Restart your Rails server"
	say "  3. Trigger an error and look for the 'Ask AI' button\n"
end