Created
June 28, 2014 06:47
-
-
Save xuwei-k/9e1d63e6f0ba8f938a11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.11.1" | |
libraryDependencies += "com.github.xuwei-k" %% "ghscala" % "0.2.11" | |
libraryDependencies += "com.github.xuwei-k" %% "httpz-native" % "0.2.11" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httpz._, native._ | |
object Main { | |
final case class Repo(owner: String, name: String) | |
val repositories = ( | |
Repo("slick", "slick") :: | |
Repo("mauricio", "postgresql-async") :: | |
Repo("squeryl", "squeryl") :: | |
Repo("scalikejdbc", "scalikejdbc") :: | |
Repo("twitter", "querulous") :: | |
Repo("aselab", "scala-activerecord") :: | |
Repo("fwbrasil", "activate") :: | |
Repo("jonifreeman", "sqltyped") :: | |
Repo("sorm", "sorm") :: | |
Repo("scalikejdbc", "scalikejdbc-async") :: | |
Repo("jpersson", "prequel") :: | |
Repo("lucidsoftware", "relate") :: | |
Repo("cbmi", "dataexpress") :: | |
Repo("p3t0r", "scala-sql-dsl") :: | |
Repo("SimpleFinance", "jdub") :: | |
Repo("mybatis", "scala") :: | |
Repo("chochos", "scalasql") :: | |
Repo("Synesso", "scweery") :: | |
Repo("takezoe", "mirage-scala") :: | |
Repo("akr4", "shirahae-sql") :: | |
Nil | |
) | |
val action: Action[List[(Int, String)]] = { | |
import scalaz._, std.list._, syntax.traverse._ | |
repositories.map(repo => | |
ghscala.Github.repo(repo.owner, repo.name) | |
).sequenceU.map{ | |
_.map{ | |
repo => repo.watchers -> repo.name | |
}.sortBy(_._1).reverse | |
} | |
} | |
def main(args: Array[String]): Unit = { | |
val config = args match { | |
case Array(user, pass) => | |
Request.auth(user, pass) | |
case _ => | |
scalaz.Endo.idEndo[Request] | |
} | |
action.interpretWith(config).fold( | |
throw _, identity | |
).foreach(println) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment