Class: RailsMcpInsight::ProjectDetector
- Inherits:
-
Object
- Object
- RailsMcpInsight::ProjectDetector
- Defined in:
- lib/rails_mcp_insight/project_detector.rb
Overview
Detects Rails project structure and validates that the target directory is a valid Rails application.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#detect ⇒ Object
Returns a hash describing the detected project structure.
-
#initialize(config) ⇒ ProjectDetector
constructor
A new instance of ProjectDetector.
-
#validate! ⇒ Object
Validate that the project path is usable.
Constructor Details
#initialize(config) ⇒ ProjectDetector
Returns a new instance of ProjectDetector.
9 10 11 |
# File 'lib/rails_mcp_insight/project_detector.rb', line 9 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/rails_mcp_insight/project_detector.rb', line 7 def config @config end |
Instance Method Details
#detect ⇒ Object
Returns a hash describing the detected project structure
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_mcp_insight/project_detector.rb', line 14 def detect { is_rails_app: config.rails_app?, ruby_version: detect_ruby_version, rails_version: detect_rails_version, has_rspec: Dir.exist?(config.spec_path), has_minitest: Dir.exist?(config.test_path), has_schema: File.exist?(config.schema_file), has_structure_sql: File.exist?(config.structure_file), model_count: count_files(config.models_path, "*.rb"), controller_count: count_files(config.controllers_path, "*.rb"), job_count: count_files(config.jobs_path, "*.rb"), mailer_count: count_files(config.mailers_path, "*.rb"), migration_count: count_files(config.migrations_path, "*.rb") } end |
#validate! ⇒ Object
Validate that the project path is usable
32 33 34 35 36 37 38 39 |
# File 'lib/rails_mcp_insight/project_detector.rb', line 32 def validate! raise Error, "Project path does not exist: #{config.project_path}" unless Dir.exist?(config.project_path) return if config.rails_app? raise Error, "Not a Rails application: #{config.project_path}. " \ "Expected config/routes.rb, Gemfile, and app/ directory." end |