Class: Zwischen::ProjectDetector
- Inherits:
-
Object
- Object
- Zwischen::ProjectDetector
- Defined in:
- lib/zwischen/project_detector.rb
Constant Summary collapse
- DETECTION_PATTERNS =
Base detection patterns for runtime/language
{ "node" => ["package.json"], "python" => ["requirements.txt", "pyproject.toml", "setup.py", "Pipfile", "poetry.lock"], "ruby" => ["Gemfile", "Rakefile"], "go" => ["go.mod", "go.sum"], "java" => ["pom.xml", "build.gradle", "build.gradle.kts"], "rust" => ["Cargo.toml", "Cargo.lock"], "php" => ["composer.json"], "dotnet" => ["*.csproj", "*.sln", "*.fsproj"] }.freeze
- JS_FRAMEWORKS =
Framework detection in package.json dependencies
{ "nextjs" => ["next"], "react" => ["react"], "vue" => ["vue"], "angular" => ["@angular/core"], "svelte" => ["svelte"], "express" => ["express"], "nestjs" => ["@nestjs/core"], "nuxt" => ["nuxt"], "remix" => ["@remix-run/react"], "astro" => ["astro"], "gatsby" => ["gatsby"] }.freeze
- PYTHON_FRAMEWORKS =
Framework detection in Python dependencies
{ "django" => ["django", "Django"], "fastapi" => ["fastapi", "FastAPI"], "flask" => ["flask", "Flask"], "pyramid" => ["pyramid"], "tornado" => ["tornado"], "starlette" => ["starlette"], "streamlit" => ["streamlit"], "jupyter" => ["jupyter", "jupyterlab", "notebook"] }.freeze
- RUBY_FRAMEWORKS =
Framework detection in Gemfile
{ "rails" => ["rails"], "sinatra" => ["sinatra"], "hanami" => ["hanami"], "grape" => ["grape"], "roda" => ["roda"] }.freeze
- FRAMEWORK_LANGUAGES =
Map frameworks to primary language
{ "nextjs" => "javascript", "react" => "javascript", "vue" => "javascript", "angular" => "typescript", "svelte" => "javascript", "express" => "javascript", "nestjs" => "typescript", "nuxt" => "javascript", "remix" => "javascript", "astro" => "javascript", "gatsby" => "javascript", "django" => "python", "fastapi" => "python", "flask" => "python", "pyramid" => "python", "tornado" => "python", "starlette" => "python", "streamlit" => "python", "jupyter" => "python", "rails" => "ruby", "sinatra" => "ruby", "hanami" => "ruby", "grape" => "ruby", "roda" => "ruby" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #detect ⇒ Object
-
#initialize(project_root = Dir.pwd) ⇒ ProjectDetector
constructor
A new instance of ProjectDetector.
Constructor Details
#initialize(project_root = Dir.pwd) ⇒ ProjectDetector
Returns a new instance of ProjectDetector.
73 74 75 |
# File 'lib/zwischen/project_detector.rb', line 73 def initialize(project_root = Dir.pwd) @project_root = project_root end |
Class Method Details
.detect(project_root = Dir.pwd) ⇒ Object
69 70 71 |
# File 'lib/zwischen/project_detector.rb', line 69 def self.detect(project_root = Dir.pwd) new(project_root).detect end |
Instance Method Details
#detect ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/zwischen/project_detector.rb', line 77 def detect detected_types = detect_base_types frameworks = detect_frameworks # Determine primary type - prefer framework over base type primary = frameworks.first || detected_types.first # Determine language language = if frameworks.any? FRAMEWORK_LANGUAGES[frameworks.first] || detected_types.first else detected_types.first end { types: detected_types, primary_type: primary, language: language || "unknown", frameworks: frameworks, root: @project_root } end |