Class: Parabot::LanguageInference

Inherits:
Object
  • Object
show all
Defined in:
lib/parabot/language_inference.rb

Constant Summary collapse

EXTENSION_PATTERNS =
{
  "python" => [".py", ".pyx", ".pyi"],
  "java" => [".java"],
  "cpp" => [".cpp", ".cc", ".cxx", ".c++", ".hpp", ".h"],
  "c" => [".c", ".h"],
  "go" => [".go"],
  "rust" => [".rs"],
  "php" => [".php"],
  "swift" => [".swift"],
  "dart" => [".dart"],
  "scala" => [".scala"],
  "clojure" => [".clj", ".cljs", ".cljc"],
  "haskell" => [".hs", ".lhs"],
  "erlang" => [".erl", ".hrl"],
  "csharp" => [".cs"],
  "fsharp" => [".fs", ".fsx"],
  "perl" => [".pl", ".pm"],
  "lua" => [".lua"],
  "r" => [".R", ".r"],
  "matlab" => [".m"],
  "julia" => [".jl"]
}.freeze
TEST_DIR_PATTERNS =
{
  "python" => %w[tests test],
  "java" => ["src/test/java", "test"],
  "go" => ["."], # Go tests alongside source
  "rust" => ["tests"],
  "php" => %w[tests test],
  "swift" => ["Tests"],
  "dart" => ["test"],
  "scala" => ["src/test/scala", "test"],
  "clojure" => ["test"],
  "haskell" => ["test"],
  "erlang" => ["test"],
  "csharp" => %w[test tests],
  "fsharp" => %w[test tests],
  "perl" => %w[t test],
  "lua" => %w[test spec],
  "r" => %w[tests test],
  "matlab" => ["test"],
  "julia" => ["test"]
}.freeze
PROJECT_FILES =
{
  "python" => ["requirements.txt", "setup.py", "pyproject.toml", "Pipfile"],
  "java" => ["pom.xml", "build.gradle", "build.gradle.kts"],
  "go" => ["go.mod", "go.sum"],
  "rust" => ["Cargo.toml", "Cargo.lock"],
  "php" => ["composer.json", "composer.lock"],
  "swift" => ["Package.swift"],
  "dart" => ["pubspec.yaml"],
  "scala" => ["build.sbt", "project/build.properties"],
  "clojure" => ["project.clj", "deps.edn"],
  "haskell" => ["*.cabal", "stack.yaml"],
  "erlang" => ["rebar.config", "erlang.mk"],
  "csharp" => ["*.csproj", "*.sln"],
  "fsharp" => ["*.fsproj", "*.sln"],
  "perl" => ["Makefile.PL", "Build.PL"],
  "lua" => ["*.rockspec"],
  "r" => %w[DESCRIPTION NAMESPACE],
  "matlab" => ["*.prj"],
  "julia" => ["Project.toml", "Manifest.toml"]
}.freeze

Class Method Summary collapse

Class Method Details

.infer_extensions(language) ⇒ Object



70
71
72
# File 'lib/parabot/language_inference.rb', line 70

def self.infer_extensions(language)
  EXTENSION_PATTERNS[language.downcase] || [".#{language}"]
end

.infer_project_files(language) ⇒ Object



78
79
80
# File 'lib/parabot/language_inference.rb', line 78

def self.infer_project_files(language)
  PROJECT_FILES[language.downcase] || []
end

.infer_test_dirs(language) ⇒ Object



74
75
76
# File 'lib/parabot/language_inference.rb', line 74

def self.infer_test_dirs(language)
  TEST_DIR_PATTERNS[language.downcase] || %w[test tests]
end