4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rails-mcp-server/analyzers/analyze_controller_views.rb', line 4
def call(controller_name: nil, detail_level: "full", analysis_type: "introspection")
unless current_project
return "No active project. Please switch to a project first."
end
detail_level = "full" unless %w[names summary full].include?(detail_level)
analysis_type = "introspection" unless %w[introspection static full].include?(analysis_type)
controllers_dir = File.join(active_project_path, "app", "controllers")
return "Controllers directory not found." unless File.directory?(controllers_dir)
controller_files = Dir.glob(File.join(controllers_dir, "**", "*_controller.rb"))
.reject { |f| f.include?("application_controller") }
return "No controllers found." if controller_files.empty?
if controller_name
normalized = normalize_controller_name(controller_name)
controller_files = controller_files.select { |f| File.basename(f).downcase == "#{normalized}_controller.rb" }
return "Controller '#{controller_name}' not found." if controller_files.empty?
end
analyze_controllers(controller_files, detail_level, analysis_type)
end
|