Class: RubynCode::Tools::RailsGenerate

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/tools/rails_generate.rb

Constant Summary collapse

TOOL_NAME =
'rails_generate'
DESCRIPTION =
'Runs a Rails generator command. Validates that the project is a Rails application.'
PARAMETERS =
{
  generator: { type: :string, required: true,
               description: "Generator name (e.g. 'model', 'controller', 'migration')" },
  args: { type: :string, required: true,
          description: "Arguments for the generator (e.g. 'User name:string email:string')" }
}.freeze
RISK_LEVEL =
:execute
REQUIRES_CONFIRMATION =
false

Instance Attribute Summary

Attributes inherited from Base

#project_root

Instance Method Summary collapse

Methods inherited from Base

description, #initialize, parameters, requires_confirmation?, risk_level, #safe_path, summarize, to_schema, tool_name, #truncate

Constructor Details

This class inherits a constructor from RubynCode::Tools::Base

Instance Method Details

#execute(generator:, args:) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/rubyn_code/tools/rails_generate.rb', line 21

def execute(generator:, args:)
  validate_rails_project!

  command = "bundle exec rails generate #{generator} #{args}"
  stdout, stderr, status = safe_capture3(command, chdir: project_root)

  build_output(stdout, stderr, status)
end