A Scala wrapper around github/linguist based on GraalVM's TruffleRuby
GraalVM with support for TruffleRuby must be used as the Java runtime
gu install ruby
The github/linguist Ruby gem must be installed (instructions)
gem install github-linguist
sbt
libraryDependencies ++=
"io.taig" %%% "scala-linguist-core" % "x.y.z" ::
"io.taig" %%% "scala-linguist-naive" % "x.y.z" ::
"io.taig" %% "scala-linguist-graalvm-ruby" % "x.y.z" ::
Nil
- Detect the language when given a path and source code
import cats.effect.{IO, IOApp}
import io.taig.linguist.GraalVmLinguist
import java.nio.file.Paths
object App extends IOApp.Simple {
override def run: IO[Unit] =
GraalVmRubyLinguist.default[IO]
.use(_.detect(Paths.get("Main.scala"), "trait Foo {}"))
.flatMap(IO.println)
}
sbt> run
Some(Scala)
- Detect the potential languages when only given a path
import cats.effect.{IO, IOApp}
import io.taig.linguist.GraalVmLinguist
import java.nio.file.Paths
object App extends IOApp.Simple {
override def run: IO[Unit] =
GraalVmRubyLinguist.default[IO]
.use(_.detect(Paths.get("Main.scala")))
.flatMap(IO.println)
}
sbt> run
List(Scala)
> benchmarks/Jmh/run -wi 10 -i 5 -f1 -t4