Class: RobotLab::Generators::InstallGenerator

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

Overview

Installs RobotLab into a Rails application

Usage:

rails generate robot_lab:install

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ String

Returns the next migration number for ActiveRecord migrations.

Parameters:

  • dirname (String)

    the migrations directory

Returns:

  • (String)

    the next migration number



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

def self.next_migration_number(dirname)
  ::ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#create_directoriesvoid

This method returns an undefined value.

Creates the robots and tools directories.



69
70
71
72
# File 'lib/generators/robot_lab/install_generator.rb', line 69

def create_directories
  empty_directory "app/robots"
  empty_directory "app/tools"
end

#create_initializervoid

This method returns an undefined value.

Creates the RobotLab initializer file.



34
35
36
# File 'lib/generators/robot_lab/install_generator.rb', line 34

def create_initializer
  template "initializer.rb.tt", "config/initializers/robot_lab.rb"
end

#create_jobvoid

This method returns an undefined value.

Creates the background job for robot execution.



60
61
62
63
64
# File 'lib/generators/robot_lab/install_generator.rb', line 60

def create_job
  return if options[:skip_job]

  template "job.rb.tt", "app/jobs/robot_run_job.rb"
end

#create_migrationvoid

This method returns an undefined value.

Creates the database migration for RobotLab tables.



41
42
43
44
45
# File 'lib/generators/robot_lab/install_generator.rb', line 41

def create_migration
  return if options[:skip_migration]

  migration_template "migration.rb.tt", "db/migrate/create_robot_lab_tables.rb"
end

#create_modelsvoid

This method returns an undefined value.

Creates the ActiveRecord model files.



50
51
52
53
54
55
# File 'lib/generators/robot_lab/install_generator.rb', line 50

def create_models
  return if options[:skip_migration]

  template "thread_model.rb.tt", "app/models/robot_lab_thread.rb"
  template "result_model.rb.tt", "app/models/robot_lab_result.rb"
end

#display_post_installvoid

This method returns an undefined value.

Displays post-installation instructions.



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/generators/robot_lab/install_generator.rb', line 77

def display_post_install
  say ""
  say "RobotLab installed successfully!", :green
  say ""
  say "Next steps:"
  say "  1. Run migrations: rails db:migrate"
  say "  2. Configure your LLM API keys in config/initializers/robot_lab.rb"
  say "  3. Generate your first robot: rails g robot_lab:robot MyRobot"
  say "  4. Enqueue robot runs via RobotRunJob (app/jobs/robot_run_job.rb)" unless options[:skip_job]
  say ""
end