Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
/ scala-linguist Public archive

A Scala wrapper around github/linguist based on GraalVM's TruffleRuby

License

Notifications You must be signed in to change notification settings

taig/scala-linguist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scala Linguist

CI & CD scala-linguist-core Scala version support Scala Steward badge

A Scala wrapper around github/linguist based on GraalVM's TruffleRuby

Prerequisites

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

Installation

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

Usage

  • 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

> benchmarks/Jmh/run -wi 10 -i 5 -f1 -t4

About

A Scala wrapper around github/linguist based on GraalVM's TruffleRuby

Resources

License

Stars

Watchers

Forks

Languages