Skip to content

Instantly share code, notes, and snippets.

@eed3si9n
Forked from xuwei-k/Build.scala
Last active August 5, 2017 13:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eed3si9n/ea4ceef0c5e5c07d6e62c87bea029f88 to your computer and use it in GitHub Desktop.
Save eed3si9n/ea4ceef0c5e5c07d6e62c87bea029f88 to your computer and use it in GitHub Desktop.
sbt plugin star ranking (using Gigahorse)
name := "sbt-plugin-ranking"
scalaVersion := "2.12.3"
libraryDependencies ++= List(
"com.eed3si9n" %% "gigahorse-github" % "gigahorse0.3.1_0.2.0",
"com.eed3si9n" %% "gigahorse-okhttp" % "0.3.1")
package sbt_plugin_ranking
import gigahorse._, support.okhttp.Gigahorse
import gigahorse.github.Github
import scala.concurrent._, duration._
object Main extends App{
val repo = """https:\/\/github.com\/([a-zA-Z0-9_\-]+)\/([a-zA-Z0-9_\-]+)""".r
val url = "http://www.scala-sbt.org/release/docs/Community-Plugins.html"
val html = io.Source.fromURL(url).mkString
val repoList = repo.findAllIn(html).map{case repo(user,name) => user -> name }.toList.distinct
val client = Github.localConfigClient
Gigahorse.withHttp { http =>
val promises = repoList map { case (u,r) =>
http.run(client(Github.repo(u, r)), Github.asRepo)
}
val info = for {
p <- promises
} yield Await.result(p, 1.minutes)
info.sortBy(_.watchers_count).reverse foreach{ repo =>
println("- " + repo.html_url.get + " " + repo.watchers_count.get)}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment