Don't you repeat yourself across projects? I'm sure you do. This library aims at providing useful and used code snippets and patterns.
Usage:
libraryDependencies += "net.dericbourg.daily-utils" %% "scala-lib" % "0.1.8"
import net.dericbourg.daily.utils.scala.lib.AutoCloseableExtensions.use
use(db.getConnection()) { connection =>
connection.prepareStatement("select 1")
...
} // connection.close() is called there
Usage:
libraryDependencies += "net.dericbourg.daily-utils" %% "typesafe-config" % "0.1.8"
import net.dericbourg.daily.utils.typesafe.config._
import com.typesafe.config.Config
val config: Config = ???
val timeout = config.getLongOption("some.timeout.value").getOrElse(1000)
Usage:
libraryDependencies += "net.dericbourg.daily-utils" %% "twitter-utils" % "0.1.8"
import net.dericbourg.daily.utils.twitter.utils.TwitterConverters._
val twitterFuture = com.twitter.util.future.Future("Hello world!")
val scalaFuture = twitterFuture.asScala
import net.dericbourg.daily.utils.twitter.utils.TwitterConverters._
val scalaFuture = scala.concurrent.Future("Hello world!")
val twitterFuture = scalaFuture.asTwitter
import net.dericbourg.daily.utils.twitter.utils.TwitterConverters._
val twitterTry = com.twitter.util.Try {
whatever()
}
val scalaTry = twitterTry.asScala
import net.dericbourg.daily.utils.twitter.utils.TwitterConverters._
val scalaTry = scala.util.Try {
whatever()
}
val twitterTry = scalaTry.asTwitter
Usage:
libraryDependencies += "net.dericbourg.daily-utils" %% "twitter-test-future" % "0.1.8" % Test
Scalatest provides the trait ScalaFutures
to test Future results. Here is the same for Twitter Futures:
import com.twitter.util.Future
import net.dericbourg.daily.utils.twitter.future.TwitterFutures
class SomeTest extends YourBaseClass with TwitterFutures {
"Your test" should "work" in {
val future = Future("OK")
whenReady(future) { value =>
value should be("OK")
}
}
}