Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Set the heap size of 128-256mb when running in docker. | lazy val root = (project in file(".")).settings(
name := "scalactic",
version := "scalactic-200520-ecr",
scalaVersion := "2.13.1",
libraryDependencies ++= Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3"
),
fork := false,
packageName in Docker := "artima/scalactic-website",
maintainer in Docker := "Artima Inc.",
dockerExposedPorts ++= Seq(9000),
dockerUpdateLatest := true
//classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat // Added in sbt 1.3 (https://www.scala-sbt.org/1.x/docs/sbt-1.3-Release-Notes.html), but still not working, so we fall back to sbt 1.2.
).enablePlugins(PlayScala, JavaServerAppPackaging, DockerPlugin)
| lazy val root = (project in file(".")).settings(
name := "scalactic",
version := "scalactic-200521-ecr",
scalaVersion := "2.13.1",
libraryDependencies ++= Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3"
),
fork := false,
packageName in Docker := "artima/scalactic-website",
maintainer in Docker := "Artima Inc.",
dockerExposedPorts ++= Seq(9000),
dockerUpdateLatest := true,
javaOptions in Universal ++= Seq(
// -J params will be added as jvm parameters
"-J-Xmx256m",
"-J-Xms128m"
)
//classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat // Added in sbt 1.3 (https://www.scala-sbt.org/1.x/docs/sbt-1.3-Release-Notes.html), but still not working, so we fall back to sbt 1.2.
).enablePlugins(PlayScala, JavaServerAppPackaging, DockerPlugin)
|
Update configuration to record version 0.0.6 | name := "lib-reference-scala"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
version := "0.0.5"
| name := "lib-reference-scala"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
version := "0.0.6"
|
Update configuration to record version 0.1.16 | name := "lib-reference-scala"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.3" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
version := "0.1.15"
| name := "lib-reference-scala"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.3" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
version := "0.1.16"
|
Increase version after 0.1.3 release. | package me.tfeng.sbt.plugins
object Versions {
val project = "0.1.3"
val avro = "1.7.7"
val dustjs = "2.4.0-1"
val sbtEclipse = "2.5.0"
val sbtWeb = "1.1.0"
}
| package me.tfeng.sbt.plugins
object Versions {
val project = "0.1.4-SNAPSHOT"
val avro = "1.7.7"
val dustjs = "2.4.0-1"
val sbtEclipse = "2.5.0"
val sbtWeb = "1.1.0"
}
|
Change getStringByField to getBinaryByField, for retrieving an array of bytes | package com.orendainx.hortonworks.trucking.topology.nifi
import com.typesafe.scalalogging.Logger
import org.apache.nifi.storm.{NiFiDataPacket, NiFiDataPacketBuilder, StandardNiFiDataPacket}
import org.apache.storm.tuple.Tuple
import scala.collection.JavaConverters._
/**
* @author Edgar Orendain <edgar@orendainx.com>
*/
class ByteArrayToNiFiPacket extends NiFiDataPacketBuilder with Serializable {
private lazy val logger = Logger(this.getClass)
override def createNiFiDataPacket(tuple: Tuple): NiFiDataPacket = {
val newAttributes = Map("processed" -> "true").asJava
new StandardNiFiDataPacket(tuple.getValueByField("data").asInstanceOf[Array[Byte]], newAttributes)
}
}
| package com.orendainx.hortonworks.trucking.topology.nifi
import com.typesafe.scalalogging.Logger
import org.apache.nifi.storm.{NiFiDataPacket, NiFiDataPacketBuilder, StandardNiFiDataPacket}
import org.apache.storm.tuple.Tuple
import scala.collection.JavaConverters._
/**
* @author Edgar Orendain <edgar@orendainx.com>
*/
class ByteArrayToNiFiPacket extends NiFiDataPacketBuilder with Serializable {
private lazy val logger = Logger(this.getClass)
override def createNiFiDataPacket(tuple: Tuple): NiFiDataPacket = {
val newAttributes = Map("processed" -> "true").asJava
new StandardNiFiDataPacket(tuple.getBinaryByField("data"), newAttributes)
}
}
|
Update scala-js to 0.6.20 to fix 2.13.0-M3 | addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.12")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.19")
| addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.12")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22")
|
Update play-test, routes-compiler to 2.7.9 | import sbt._
object Dependencies {
object Versions {
val play = "2.7.3"
val playJson = "2.7.4"
val specs2 = "4.6.0"
val enumeratum = "1.5.13"
}
val playTest = Seq(
"com.typesafe.play" %% "play-test" % Versions.play % Test)
val playRoutesCompiler = Seq(
"com.typesafe.play" %% "routes-compiler" % Versions.play)
val playJson = Seq(
"com.typesafe.play" %% "play-json" % Versions.playJson % "provided")
val yaml = Seq(
"org.yaml" % "snakeyaml" % "1.27")
val enumeratum = Seq(
"com.beachape" %% "enumeratum" % Versions.enumeratum % Test)
val test = Seq(
"org.specs2" %% "specs2-core" % Versions.specs2 % "test",
"org.specs2" %% "specs2-mock" % Versions.specs2 % "test")
}
| import sbt._
object Dependencies {
object Versions {
val play = "2.7.9"
val playJson = "2.7.4"
val specs2 = "4.6.0"
val enumeratum = "1.5.13"
}
val playTest = Seq(
"com.typesafe.play" %% "play-test" % Versions.play % Test)
val playRoutesCompiler = Seq(
"com.typesafe.play" %% "routes-compiler" % Versions.play)
val playJson = Seq(
"com.typesafe.play" %% "play-json" % Versions.playJson % "provided")
val yaml = Seq(
"org.yaml" % "snakeyaml" % "1.27")
val enumeratum = Seq(
"com.beachape" %% "enumeratum" % Versions.enumeratum % Test)
val test = Seq(
"org.specs2" %% "specs2-core" % Versions.specs2 % "test",
"org.specs2" %% "specs2-mock" % Versions.specs2 % "test")
}
|
Update SLF4J bridging to check if the Slf4jBridgeHandler is already installed | package com.twitter.inject.logging
import com.twitter.inject.Logging
import org.slf4j.LoggerFactory
import org.slf4j.bridge.SLF4JBridgeHandler
object Slf4jBridgeUtility extends Logging {
private[inject] def attemptSlf4jBridgeHandlerInstallation(): Unit = {
if (canInstallBridgeHandler) {
SLF4JBridgeHandler.removeHandlersForRootLogger()
SLF4JBridgeHandler.install()
info("org.slf4j.bridge.SLF4JBridgeHandler installed.")
}
}
/* Private */
private def canInstallBridgeHandler: Boolean = {
// We do not want to attempt to install the bridge handler if the JDK14LoggerFactory
// exists on the classpath. See: http://www.slf4j.org/legacy.html#jul-to-slf4j
try {
Class.forName("org.slf4j.impl.JDK14LoggerFactory", false, this.getClass.getClassLoader)
LoggerFactory.getLogger(this.getClass).warn("Detected [org.slf4j.impl.JDK14LoggerFactory] on classpath. SLF4JBridgeHandler cannot be installed, see: http://www.slf4j.org/legacy.html#jul-to-slf4j")
false
} catch {
case e: ClassNotFoundException =>
true
}
}
}
| package com.twitter.inject.logging
import com.twitter.inject.Logging
import org.slf4j.LoggerFactory
import org.slf4j.bridge.SLF4JBridgeHandler
object Slf4jBridgeUtility extends Logging {
private[inject] def attemptSlf4jBridgeHandlerInstallation(): Unit = {
if (!SLF4JBridgeHandler.isInstalled && canInstallBridgeHandler) {
SLF4JBridgeHandler.removeHandlersForRootLogger()
SLF4JBridgeHandler.install()
info("org.slf4j.bridge.SLF4JBridgeHandler installed.")
}
}
/* Private */
private def canInstallBridgeHandler: Boolean = {
// We do not want to attempt to install the bridge handler if the JDK14LoggerFactory
// exists on the classpath. See: http://www.slf4j.org/legacy.html#jul-to-slf4j
try {
Class.forName("org.slf4j.impl.JDK14LoggerFactory", false, this.getClass.getClassLoader)
LoggerFactory.getLogger(this.getClass).warn("Detected [org.slf4j.impl.JDK14LoggerFactory] on classpath. SLF4JBridgeHandler cannot be installed, see: http://www.slf4j.org/legacy.html#jul-to-slf4j")
false
} catch {
case e: ClassNotFoundException =>
true
}
}
}
|
Remove unnecessary text output 1. Remove first 4 lines of welcome message, and the last 2 lines of auto-generated ":quit". | package com.lunatech.lunabot
import scala.sys.process._
import scala.io._
import java.io._
/**
* scala REPL process
*/
object REPLproc {
var respOut = ""
var respErr = ""
/**
* Start a scala REPL process, write Scala code string to STDIN of it, and read from STDOUT and STDERR.
* @param code String, Scala code to be executed.
* @return String, scala REPL response, STDERR after STDOUT.
* @example val responseLinesOfString = REPLproc.run(scalaCodeString)
* @todo Remove the 2,3 lines of welcome message, and the last line of auto-generated ":quit".
* @todo TODO: seperate STDOUT and STDERR to allow different coloring.
*/
def run (code: String): String = {
val cmd = Seq("scala") // Uses Seq here to allow possible command options later
val process = Process (cmd)
val io = new ProcessIO (
in => {new PrintStream(in).println(code); in.close},
out => {respOut = Source.fromInputStream(out).getLines.mkString("\n"); out.close}, // TODO: Remove line 2,3 of welcome message, and the last line of auto-generated ":quit".
err => {respErr = Source.fromInputStream(err).getLines.mkString("\n"); err.close})
process.run(io).exitValue // Wait until the process exit, otherwise respOut and respErr won't get output yet.
respOut + respErr // TODO: seperate STDOUT and STDERR to allow different coloring.
}
}
| package com.lunatech.lunabot
import scala.sys.process._
import scala.io._
import java.io._
/**
* scala REPL process
*/
object REPLproc {
var respOut = ""
var respErr = ""
/**
* Start a scala REPL process, write Scala code string to STDIN of it, and read from STDOUT and STDERR.
* @param code String, Scala code to be executed.
* @return String, scala REPL response, STDERR after STDOUT.
* @example val responseLinesOfString = REPLproc.run(scalaCodeString)
* @todo Make REPL persistent process, using :reset to clean up before each session.
* @todo Seperate STDOUT and STDERR to allow different coloring.
*/
def run (code: String): String = {
val cmd = Seq("scala") // Uses Seq here to allow possible command options later
val process = Process (cmd)
val io = new ProcessIO (
in => {new PrintStream(in).println(code); in.close},
out => {respOut = Source.fromInputStream(out).getLines.toArray.drop(4).dropRight(2).mkString("\n"); out.close}, // Remove first 4 lines of welcome message, and the last 2 lines of auto-generated ":quit".
err => {respErr = Source.fromInputStream(err).getLines.mkString("\n"); err.close})
process.run(io).exitValue // Wait until the process exits, otherwise respOut and respErr won't get output yet.
respOut + respErr // TODO: seperate STDOUT and STDERR to allow different coloring.
}
}
|
Use lazy and transient initialization in keyword extractor. | package com.microsoft.partnercatalyst.fortis.spark.transforms.topic
import com.microsoft.partnercatalyst.fortis.spark.transforms.Tag
import org.apache.commons.collections4.trie.PatriciaTrie
import scala.collection.mutable.ListBuffer
@SerialVersionUID(100L)
class KeywordExtractor(keyWords: Seq[String]) extends Serializable {
private val wordTokenizer = """\b""".r
private val keywordTrie = new PatriciaTrie[Unit]()
private val originalCase = Map[String, String](keyWords.map(s => (s.toLowerCase, s)): _*)
originalCase.keys.foreach(keywordTrie.put(_, ()))
def extractKeywords(text: String): List[Tag] = {
def findMatches(segment: Seq[String]): Iterable[String] = {
val sb = new StringBuilder()
val result = ListBuffer[String]()
val it = segment.iterator
var prefix = ""
while (it.hasNext && !keywordTrie.prefixMap(prefix).isEmpty) {
prefix = sb.append(it.next()).mkString
if (keywordTrie.containsKey(prefix)) {
result.append(originalCase(prefix))
}
}
result
}
val tokens = wordTokenizer.split(text.toLowerCase).toSeq
tokens.tails.flatMap(findMatches(_).map(Tag(_, 1))).toList
}
} | package com.microsoft.partnercatalyst.fortis.spark.transforms.topic
import com.microsoft.partnercatalyst.fortis.spark.transforms.Tag
import org.apache.commons.collections4.trie.PatriciaTrie
import scala.collection.mutable.ListBuffer
@SerialVersionUID(100L)
class KeywordExtractor(keywords: Seq[String]) extends Serializable {
@transient private lazy val wordTokenizer = """\b""".r
@transient private lazy val keywordTrie = initializeTrie(keywords)
def extractKeywords(text: String): List[Tag] = {
def findMatches(segment: Seq[String]): Iterable[String] = {
val sb = new StringBuilder()
val result = ListBuffer[String]()
val it = segment.iterator
var prefix = ""
while (it.hasNext && !keywordTrie.prefixMap(prefix).isEmpty) {
prefix = sb.append(it.next()).mkString
Option(keywordTrie.get(prefix)).foreach(result.append(_))
}
result
}
val tokens = wordTokenizer.split(text.toLowerCase).toSeq
tokens.tails.flatMap(findMatches(_).map(Tag(_, 1))).toList
}
private def initializeTrie(keywords: Seq[String]): PatriciaTrie[String] = {
val trie = new PatriciaTrie[String]()
keywords.foreach(k => trie.put(k.toLowerCase, k))
trie
}
} |
Add investigative error handling to test | package repositories.fileupload
import play.api.libs.iteratee.Iteratee
import repositories.CollectionNames
import testkit.MongoRepositorySpec
class FileUploadRepositorySpec extends MongoRepositorySpec {
override val collectionName: String = CollectionNames.FILE_UPLOAD
lazy val repository: FileUploadMongoRepository = new FileUploadMongoRepository()
"add" must {
"store a file with contentType" in {
val testContent = "Test contents".toCharArray.map(_.toByte)
val testContentType = "application/pdf"
val id = repository.add(testContentType, testContent).futureValue
val retrievedFile = repository.retrieve(id).futureValue
retrievedFile.contentType mustBe testContentType
retrievedFile.fileContents.run(Iteratee.consume[Array[Byte]]()).futureValue mustBe testContent
}
}
"retrieve" must {
"retrieve a file by id" in {
val testContent = "Test contents".toCharArray.map(_.toByte)
val testContentType = "application/pdf"
val id = repository.add(testContentType, testContent).futureValue
val retrievedFile = repository.retrieve(id).futureValue
retrievedFile.contentType mustBe testContentType
retrievedFile.fileContents.run(Iteratee.consume[Array[Byte]]()).futureValue mustBe testContent
}
}
}
| package repositories.fileupload
import play.api.Logger
import play.api.libs.iteratee.Iteratee
import repositories.CollectionNames
import testkit.MongoRepositorySpec
import scala.util.{ Failure, Success, Try }
class FileUploadRepositorySpec extends MongoRepositorySpec {
override val collectionName: String = CollectionNames.FILE_UPLOAD
lazy val repository: FileUploadMongoRepository = new FileUploadMongoRepository()
"add" must {
"store a file with contentType" in {
val testContent = "Test contents".toCharArray.map(_.toByte)
val testContentType = "application/pdf"
Try {
val failedFut = repository.add(testContentType, testContent).failed.futureValue
Logger.error("FAILED FUT = " + failedFut.getStackTrace.mkString("\n"))
} match {
case Success(_) => Logger.error("SUCCESS.... WTF?")
case Failure(ex: Throwable) => Logger.error("EXCEPTION STACK = " + ex.getStackTrace.mkString("\n"))
}
/*
val retrievedFile = repository.retrieve(id).futureValue
retrievedFile.contentType mustBe testContentType
retrievedFile.fileContents.run(Iteratee.consume[Array[Byte]]()).futureValue mustBe testContent
*/
}
}
"retrieve" must {
"retrieve a file by id" in {
val testContent = "Test contents".toCharArray.map(_.toByte)
val testContentType = "application/pdf"
val id = repository.add(testContentType, testContent).futureValue
val retrievedFile = repository.retrieve(id).futureValue
retrievedFile.contentType mustBe testContentType
retrievedFile.fileContents.run(Iteratee.consume[Array[Byte]]()).futureValue mustBe testContent
}
}
}
|
Add support for gzip transfer encoding. | import _root_.controllers._
import bali.Module
import bali.scala.make
import config.ConfigModule
import play.api.ApplicationLoader.Context
import play.api._
import play.api.routing.Router
import router.Routes
final class MainApplicationLoader extends ApplicationLoader {
override def load(context: Context): Application = new MainComponents(context).application
}
final class MainComponents(context: Context)
extends BuiltInComponentsFromContext(context)
with AssetsComponents
with NoHttpFiltersComponents {
lazy val module: MainModule = make[MainModule]
import module._
override lazy val router: Router = new Routes(
Assets_1 = assets,
GameController_0 = gameController,
errorHandler = httpErrorHandler,
)
}
@Module
trait MainModule extends ConfigModule with ControllerModule
| import _root_.controllers._
import bali.Module
import bali.scala.make
import config.ConfigModule
import play.api.ApplicationLoader.Context
import play.api._
import play.api.mvc.EssentialFilter
import play.api.routing.Router
import play.filters.HttpFiltersComponents
import play.filters.gzip.GzipFilterComponents
import router.Routes
final class MainApplicationLoader extends ApplicationLoader {
override def load(context: Context): Application = new MainComponents(context).application
}
final class MainComponents(context: Context)
extends BuiltInComponentsFromContext(context)
with AssetsComponents
with GzipFilterComponents
with HttpFiltersComponents {
override def httpFilters: Seq[EssentialFilter] = {
Seq(csrfFilter, gzipFilter, securityHeadersFilter, allowedHostsFilter)
}
lazy val module: MainModule = make[MainModule]
import module._
override lazy val router: Router = new Routes(
Assets_1 = assets,
GameController_0 = gameController,
errorHandler = httpErrorHandler,
)
}
@Module
trait MainModule extends ConfigModule with ControllerModule
|
Make default hsd/rdr scale 20 nmi | package se.gigurra.leavu3.datamodel
import se.gigurra.heisenberg.MapData._
import se.gigurra.heisenberg.{Schema, Parsed}
case class RadarDisplayScale(source: SourceData = Map.empty) extends SafeParsed[RadarDisplayScale.type] {
val azimuth = math.max(parse(schema.azimuth).toDegrees * 2.0, 0.1)
val distance = math.max(parse(schema.distance), 10)
}
object RadarDisplayScale extends Schema[RadarDisplayScale] {
val azimuth = required[Float]("azimuth", default = 0)
val distance = required[Float]("distance", default = 0)
}
| package se.gigurra.leavu3.datamodel
import se.gigurra.heisenberg.MapData._
import se.gigurra.heisenberg.{Parsed, Schema}
import se.gigurra.leavu3.lmath.UnitConversions
case class RadarDisplayScale(source: SourceData = Map.empty)
extends SafeParsed[RadarDisplayScale.type]
with UnitConversions {
val azimuth = math.max(parse(schema.azimuth).toDegrees * 2.0, 0.1)
val distance = math.max(parse(schema.distance), 20 * nmi_to_m)
}
object RadarDisplayScale extends Schema[RadarDisplayScale] {
val azimuth = required[Float]("azimuth", default = 0)
val distance = required[Float]("distance", default = 0)
}
|
Rename function - It doesn't really 'generate' an element, so let's make its purpose clearer | package com.softwaremill.react.kafka
import akka.stream.actor.{ActorPublisher, ActorPublisherMessage}
import kafka.consumer.{ConsumerTimeoutException, KafkaConsumer}
import scala.util.{Failure, Success, Try}
private[kafka] class KafkaActorPublisher(consumer: KafkaConsumer) extends ActorPublisher[String] {
val iterator = consumer.iterator()
def generateElement() = {
Try(iterator.next().message()).map(bytes => Some(new String(bytes))).recover {
// We handle timeout exceptions as normal 'end of the queue' cases
case _: ConsumerTimeoutException => None
}
}
override def receive = {
case ActorPublisherMessage.Request(_) => read()
case ActorPublisherMessage.Cancel | ActorPublisherMessage.SubscriptionTimeoutExceeded => cleanupResources()
}
def read() {
if (totalDemand < 0 && isActive) {
println(totalDemand)
onError(new IllegalStateException("3.17: Overflow"))
}
else {
var maybeMoreElements = true
while (isActive && totalDemand > 0 && maybeMoreElements) {
generateElement() match {
case Success(None) => maybeMoreElements = false // No more elements
case Success(valueOpt) =>
valueOpt.foreach(element => onNext(element))
maybeMoreElements = true
case Failure(ex) => onError(ex)
}
}
}
}
private def cleanupResources() {
consumer.close()
}
} | package com.softwaremill.react.kafka
import akka.stream.actor.{ActorPublisher, ActorPublisherMessage}
import kafka.consumer.{ConsumerTimeoutException, KafkaConsumer}
import scala.util.{Failure, Success, Try}
private[kafka] class KafkaActorPublisher(consumer: KafkaConsumer) extends ActorPublisher[String] {
val iterator = consumer.iterator()
def tryFetchingNextElement() = {
Try(iterator.next().message()).map(bytes => Some(new String(bytes))).recover {
// We handle timeout exceptions as normal 'end of the queue' cases
case _: ConsumerTimeoutException => None
}
}
override def receive = {
case ActorPublisherMessage.Request(_) => read()
case ActorPublisherMessage.Cancel | ActorPublisherMessage.SubscriptionTimeoutExceeded => cleanupResources()
}
def read() {
if (totalDemand < 0 && isActive) {
println(totalDemand)
onError(new IllegalStateException("3.17: Overflow"))
}
else {
var maybeMoreElements = true
while (isActive && totalDemand > 0 && maybeMoreElements) {
tryFetchingNextElement() match {
case Success(None) => maybeMoreElements = false // No more elements
case Success(valueOpt) =>
valueOpt.foreach(element => onNext(element))
maybeMoreElements = true
case Failure(ex) => onError(ex)
}
}
}
}
private def cleanupResources() {
consumer.close()
}
} |
Add simple replacement syntax $..$ in the query. | package jp.sf.amateras.solr.scala
class QueryTemplate(query: String) {
def merge(params: Map[String, Any]): String = {
var result = query
params.foreach { case (key, value) =>
result = result.replaceAll("%" + key + "%", "\"" + QueryTemplate.escape(value.toString) + "\"")
}
result
}
}
object QueryTemplate {
private lazy val specialCharacters =
Set('+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\')
private def escape(value: String): String =
value.toString.map { c =>
c match {
case _ if specialCharacters.contains(c) => Seq('\\', '\\', c)
case _ => Seq(c)
}
}.flatten.mkString
} | package jp.sf.amateras.solr.scala
class QueryTemplate(query: String) {
def merge(params: Map[String, Any]): String = {
var result = query
params.foreach { case (key, value) =>
result = result.replaceAll("%" + key + "%", "\"" + QueryTemplate.escape(value.toString) + "\"")
}
params.foreach { case (key, value) =>
result = result.replaceAll("$" + key + "$", "\"" + value.toString + "\"")
}
result
}
}
object QueryTemplate {
private lazy val specialCharacters =
Set('+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\')
private def escape(value: String): String =
value.toString.map { c =>
c match {
case _ if specialCharacters.contains(c) => Seq('\\', '\\', c)
case _ => Seq(c)
}
}.flatten.mkString
} |
Define ActorLink and ActorPath alias | package akkaviz
import org.scalajs.dom._
import org.scalajs.dom.raw.Element
package object frontend {
implicit class RichElement(elem: Element) {
def onClick(f: () => Any): Unit = {
elem.addEventListener("click", { (e: Event) => f() }, true)
}
def onEnter(f: () => Any): Unit = {
elem.addEventListener("keydown", { (e: KeyboardEvent) =>
val enterKeyCode = 13
if (e.keyCode == enterKeyCode)
f()
}, true)
}
}
}
| package akkaviz
import org.scalajs.dom._
import org.scalajs.dom.raw.Element
package object frontend {
implicit class RichElement(elem: Element) {
def onClick(f: () => Any): Unit = {
elem.addEventListener("click", { (e: Event) => f() }, true)
}
def onEnter(f: () => Any): Unit = {
elem.addEventListener("keydown", { (e: KeyboardEvent) =>
val enterKeyCode = 13
if (e.keyCode == enterKeyCode)
f()
}, true)
}
}
type ActorPath = String
case class ActorLink(from: ActorPath, to: ActorPath)
}
|
Add simple example with return and mutations | object SimpleReturn {
def example0: Int = {
return 11
}
def example1: Int = {
return 0
1
}
def example2(x: Int): Int = {
val a = if (x > 0) { return 1 } else { 2 }
3
}
def example3(cond: Boolean): Boolean = {
val a = if (cond) { return true } else { 1 }
false
}
def example4: Boolean = {
val x: Int = return false
true
}
def example5(cond: Boolean) : Int = {
val x: Int = if (cond) return 100 else { 5 }
x
}
def tests() = {
assert(example0 == 11)
assert(example1 == 0)
assert(example2(10) == 1)
assert(example2(-10) == 3)
assert(example3(true))
assert(!example3(false))
assert(!example4)
assert(example5(true) == 100)
assert(example5(false) == 5)
}
}
| object SimpleReturn {
def example0: Int = {
return 11
}
def example1: Int = {
return 0
1
}
def example2(x: Int): Int = {
val a = if (x > 0) { return 1 } else { 2 }
3
}
def example3(cond: Boolean): Boolean = {
val a = if (cond) { return true } else { 1 }
false
}
def example4: Boolean = {
val x: Int = return false
true
}
def example5(cond: Boolean) : Int = {
val x: Int = if (cond) return 100 else { 5 }
x
}
def example6(x: Int): Int = {
require(x < 100)
var y = x
y += 1
if (x == 50) { y += 1; return y }
else y += 2
y
}
def tests() = {
assert(example0 == 11)
assert(example1 == 0)
assert(example2(10) == 1)
assert(example2(-10) == 3)
assert(example3(true))
assert(!example3(false))
assert(!example4)
assert(example5(true) == 100)
assert(example5(false) == 5)
assert(example6(50) == 52)
assert(example6(42) == 45)
}
}
|
Add compilation test for `derives Reusability` | package japgolly.scalajs.react.core
import japgolly.scalajs.react._
import scala.annotation.nowarn
sealed trait Compilation3Test {
import CompilationTest._
import Compilation3Test._
sealed trait TestComponentBuilder {
val step1 = ScalaComponent.builder[Int]("")
step1.renderBackend[B3b]
step1.backend[B3b](new B3b(_)).renderBackend
}
// Ensure that the ScalaJsReactConfig.Defaults trait contains a default value for every config method
class ScalaJsReactConfigDefaults extends ScalaJsReactConfig.Defaults
}
@nowarn
object Compilation3Test {
import japgolly.scalajs.react.vdom.html_<^._
import CompilationTest._
class B3b($: BackendScope[Int, Unit])(using i: Imp) {
def render: VdomNode = 123
}
}
| package japgolly.scalajs.react.core
import japgolly.scalajs.react._
import japgolly.univeq.UnivEq
import scala.annotation.nowarn
import scala.util.NotGiven
sealed trait Compilation3Test {
import CompilationTest._
import Compilation3Test._
sealed trait TestComponentBuilder {
val step1 = ScalaComponent.builder[Int]("")
step1.renderBackend[B3b]
step1.backend[B3b](new B3b(_)).renderBackend
}
// Ensure that the ScalaJsReactConfig.Defaults trait contains a default value for every config method
class ScalaJsReactConfigDefaults extends ScalaJsReactConfig.Defaults
// Reusability derives
locally {
case class Mono(a: Int) derives Reusability, UnivEq
implicitly[Reusability[Mono]]
case class Poly[+A](a: A) derives Reusability, UnivEq
implicitly[Reusability[Poly[Int]]]
implicitly[NotGiven[Reusability[Poly[B3b]]]]
}
}
@nowarn
object Compilation3Test {
import japgolly.scalajs.react.vdom.html_<^._
import CompilationTest._
class B3b($: BackendScope[Int, Unit])(using i: Imp) {
def render: VdomNode = 123
}
}
|
Update overloaded ctor to receive Parser and Formatter | package ccf.transport.http
import java.io.IOException
import java.net.URL
import ccf.transport.json.{JsonFormatter, JsonParser}
class HttpConnection(url: URL, timeoutMillis: Int, http: Http) extends Connection {
private val formatter = JsonFormatter
private val parser = JsonParser
def this(url: URL, timeoutMillis: Int) = this(url, timeoutMillis, new HttpImpl(timeoutMillis))
def send(request: Request): Option[Response] = try {
http.post(requestUrl(request), formatter.format(request)) { parser.parse }
} catch {
case e: IOException => throw new ConnectionException(e.toString)
}
private def requestUrl(request: Request) = new URL(url, request.header("type").getOrElse(requestTypeMissing))
private def requestTypeMissing = throw new InvalidRequestException("Request header \"type\" missing")
}
| package ccf.transport.http
import java.io.IOException
import java.net.URL
import ccf.transport.json.{JsonFormatter, JsonParser}
class HttpConnection(url: URL, timeoutMillis: Int, http: Http, parser: Parser, formatter: Formatter) extends Connection {
def this(url: URL, timeoutMillis: Int) = this(url, timeoutMillis, new HttpImpl(timeoutMillis), JsonParser, JsonFormatter)
def send(request: Request): Option[Response] = try {
http.post(requestUrl(request), formatter.format(request)) { parser.parse }
} catch {
case e: IOException => throw new ConnectionException(e.toString)
}
private def requestUrl(request: Request) = new URL(url, request.header("type").getOrElse(requestTypeMissing))
private def requestTypeMissing = throw new InvalidRequestException("Request header \"type\" missing")
}
|
Add relation t_report_template and t_report_template_history. | package jp.ijufumi.openreports.model
import org.joda.time.DateTime
import scalikejdbc.WrappedResultSet
import skinny.orm.SkinnyCRUDMapper
import skinny.orm.feature.OptimisticLockWithVersionFeature
case class TReportTemplate(templateId: Long,
fileName: String,
filePath: String,
createdAt: DateTime,
updatedAt: DateTime,
versions: Long)
object TReportTemplate
extends SkinnyCRUDMapper[TReportTemplate]
with OptimisticLockWithVersionFeature[TReportTemplate] {
override def tableName = "t_report_template"
override def defaultAlias = createAlias("rep_temp")
override def primaryKeyFieldName = "templateId"
override def lockVersionFieldName: String = "versions"
override def extract(
rs: WrappedResultSet,
n: scalikejdbc.ResultName[TReportTemplate]): TReportTemplate =
new TReportTemplate(
templateId = rs.get(n.templateId),
fileName = rs.get(n.fileName),
filePath = rs.get(n.filePath),
createdAt = rs.get(n.createdAt),
updatedAt = rs.get(n.updatedAt),
versions = rs.get(n.versions)
)
}
| package jp.ijufumi.openreports.model
import org.joda.time.DateTime
import scalikejdbc.WrappedResultSet
import scalikejdbc.interpolation.SQLSyntax
import skinny.orm.SkinnyCRUDMapper
import skinny.orm.feature.OptimisticLockWithVersionFeature
case class TReportTemplate(templateId: Long,
fileName: String,
filePath: String,
createdAt: DateTime,
updatedAt: DateTime,
versions: Long,
history: Seq[TReportTemplateHistory] = Seq.empty)
object TReportTemplate
extends SkinnyCRUDMapper[TReportTemplate]
with OptimisticLockWithVersionFeature[TReportTemplate] {
override def tableName = "t_report_template"
override def defaultAlias = createAlias("rep_temp")
override def primaryKeyFieldName = "templateId"
override def lockVersionFieldName: String = "versions"
override def extract(
rs: WrappedResultSet,
n: scalikejdbc.ResultName[TReportTemplate]): TReportTemplate =
new TReportTemplate(
templateId = rs.get(n.templateId),
fileName = rs.get(n.fileName),
filePath = rs.get(n.filePath),
createdAt = rs.get(n.createdAt),
updatedAt = rs.get(n.updatedAt),
versions = rs.get(n.versions)
)
lazy val history = hasMany[TReportTemplateHistory](
many = TReportTemplateHistory -> TReportTemplateHistory.defaultAlias,
on = (t, h) => SQLSyntax.eq(t.field("templatId"), h.field("templateId")),
merge = (t, history) => t.copy(history = history)
).includes[TReportTemplateHistory](
(t, h) => t.map(m => m.copy(history = h))
)
}
|
Add NanoHTTPD to play with | package doc.jockey.horse
import org.scalatest.WordSpec
class StringsInPatternMatchingSpec extends WordSpec {
implicit class MySContext(val sc: StringContext) {
// this will not work, because the compiler thinks that s is special
case class s(args: Any*) {
def unapplySeq(s: String): Option[Seq[String]] = {
val regexp = sc.parts.mkString("(.+)").r
regexp.unapplySeq(s)
}
}
object url {
def unapplySeq(s: String): Option[Seq[String]] = {
val regexp = sc.parts.mkString("(.+)").r
regexp.unapplySeq(s)
}
}
val url2 = sc.parts.mkString("(.+)").r
}
"We can pattern match in interpolated Strings" in {
def matcher: PartialFunction[String, String] = {
case url2"this ${a} is a simple ${b}" => s"Matched: $a, $b"
case url"/dj/$a/$b" => s"Matched: $a, $b"
case x => "Did not match anything"
}
assert(matcher("this sentence is a simple string") === "Matched: sentence, string")
assert(matcher("/dj/investment/StockAnalyser") === "Matched: investment, StockAnalyser")
}
"We can pattern match in interpolated Strings inside Tim's HTTP DSL" in {
case class GET(x: String)
def matcher: PartialFunction[GET, String] = {
case GET(url"/trade/$tradeID/message/$messageID") => s"Matched: $tradeID, $messageID" //processTradeMEssage(tradeId, messageId)
case x => "It fucked up"
}
assert(matcher(GET("/trade/123/message/456")) === "Matched: 123, 456")
}
} | package doc.jockey.horse
import org.scalatest.WordSpec
class StringsInPatternMatchingSpec extends WordSpec {
implicit class PatternMatchableUrlAdapter(val sc: StringContext) {
val url = sc.parts.mkString("(.+)").r
}
"We can pattern match in interpolated Strings" in {
def matcher: PartialFunction[String, String] = {
case url"this ${a} is a simple ${b}" => s"Matched: $a, $b"
case url"/dj/$a/$b" => s"Matched: $a, $b"
case x => "Did not match anything"
}
assert(matcher("this sentence is a simple string") === "Matched: sentence, string")
assert(matcher("/dj/investment/StockAnalyser") === "Matched: investment, StockAnalyser")
}
"We can pattern match in interpolated Strings inside Tim's HTTP DSL" in {
case class GET(x: String)
def matcher: PartialFunction[GET, String] = {
case GET(url"/trade/$tradeID/message/$messageID") => s"Matched: $tradeID, $messageID" //processTradeMEssage(tradeId, messageId)
case x => "It fucked up"
}
assert(matcher(GET("/trade/123/message/456")) === "Matched: 123, 456")
}
} |
Add logic to parse QueryExtension request. | package com.tuvistavie.xserver.protocol
import akka.actor.IO
import com.typesafe.scalalogging.slf4j.Logging
trait Request
object Request extends Logging {
import IO._
def getRequest(opCode: Int)(implicit endian: java.nio.ByteOrder, socket: SocketHandle): Iteratee[Request] = {
for {
header <- take(3)
iterator = header.iterator
data = iterator.getByte
requestLength = iterator.getShort
} yield {
logger.debug(s"handling request with opcode ${opCode} and length ${requestLength}")
new Request {}
}
}
}
| package com.tuvistavie.xserver.protocol
import akka.actor.IO
import com.typesafe.scalalogging.slf4j.Logging
import com.tuvistavie.xserver.backend.util.{ ExtendedByteIterator, Conversions }
abstract class Request (
val opCode: Int
)
trait RequestGenerator {
def parseRequest(length: Int, data: Int)(implicit endian: java.nio.ByteOrder): IO.Iteratee[Request]
}
object Request extends Logging {
import IO._
import request._
def getRequest(opCode: Int)(implicit endian: java.nio.ByteOrder, socket: SocketHandle): Iteratee[Request] = {
for {
header <- take(3)
iterator = header.iterator
data = iterator.getByte
requestLength = iterator.getShort
request <- generators(opCode).parseRequest(requestLength, data)
} yield {
logger.debug(s"handling request with opcode ${opCode} and length ${requestLength}")
request
}
}
val generators: Map[Int, RequestGenerator] = Map(
98 -> QueryExtension
)
}
package request {
import ExtendedByteIterator._
import Conversions._
import IO._
case object BadRequest extends Request(0)
case class QueryExtension (
val name: String
) extends Request(98)
object QueryExtension extends RequestGenerator {
override def parseRequest(length: Int, data: Int)(implicit endian: java.nio.ByteOrder) = {
for {
request <- take(length)
iterator = request.iterator
n = iterator.getShort.toInt
_ = iterator.skip(2)
name = iterator.getString(n)
_ = iterator.skip(n.padding)
} yield {
QueryExtension(name)
}
}
}
}
|
Update JDA to 3.3 (two minor versions newer) | name := "haruko"
version := "1.0"
scalaVersion := "2.11.8"
enablePlugins(PlayScala)
enablePlugins(BuildInfoPlugin)
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion)
buildInfoPackage := "haruko"
resolvers ++= Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
Resolver.jcenterRepo,
Resolver.sonatypeRepo("public")
)
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test,
"com.jsuereth" %% "scala-arm" % "2.0",
"org.feijoas" %% "mango" % "0.13",
"net.dv8tion" % "JDA" % "3.1.1_220",
"org.pac4j" % "play-pac4j" % "3.0.0",
"org.pac4j" % "pac4j-oauth" % "2.0.0",
"com.typesafe.play" %% "play-slick" % "2.0.0",
//"com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
"net.ruippeixotog" %% "scala-scraper" % "2.0.0-RC2"
)
| name := "haruko"
version := "1.0"
scalaVersion := "2.11.8"
enablePlugins(PlayScala)
enablePlugins(BuildInfoPlugin)
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion)
buildInfoPackage := "haruko"
resolvers ++= Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
Resolver.jcenterRepo,
Resolver.sonatypeRepo("public")
)
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test,
"com.jsuereth" %% "scala-arm" % "2.0",
"org.feijoas" %% "mango" % "0.13",
"net.dv8tion" % "JDA" % "3.3.1_284",
"org.pac4j" % "play-pac4j" % "3.0.0",
"org.pac4j" % "pac4j-oauth" % "2.0.0",
"com.typesafe.play" %% "play-slick" % "2.0.0",
//"com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
"net.ruippeixotog" %% "scala-scraper" % "2.0.0-RC2"
)
|
Remove migrate plugin. Code is already migrated. | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0") // 2.0.0-RC1 available
//addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0")
//addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.1")
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.8.3")
addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.5.1")
addSbtPlugin("org.scala-sbt" % "sbt-dependency-tree" % "1.7.0-RC2")
| addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0") // 2.0.0-RC1 available
//addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0")
//addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.1")
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.8.3")
addSbtPlugin("org.scala-sbt" % "sbt-dependency-tree" % "1.7.0-RC2")
|
Upgrade SBT IDE project generators | resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Spray Repository" at "http://repo.spray.cc/"
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.5")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.1")
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0")
// For Sonatype publishing
//resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
//addSbtPlugin("com.jsuereth" % "xsbt-gpg-plugin" % "0.6")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.3")
| resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Spray Repository" at "http://repo.spray.cc/"
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.5")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
// For Sonatype publishing
//resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
//addSbtPlugin("com.jsuereth" % "xsbt-gpg-plugin" % "0.6")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.3")
|
Update configuration to record version 0.1.17 | name := "apibuilder-validation"
organization := "io.flow"
scalaVersion in ThisBuild := "2.12.4"
crossScalaVersions := Seq("2.12.4", "2.11.12")
version := "0.1.16"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.6.8",
"org.scalatest" %% "scalatest" % "3.0.4" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| name := "apibuilder-validation"
organization := "io.flow"
scalaVersion in ThisBuild := "2.12.4"
crossScalaVersions := Seq("2.12.4", "2.11.12")
version := "0.1.17"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.6.8",
"org.scalatest" %% "scalatest" % "3.0.4" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Add Shutdown for requesting an actor to shutdown | package ccf.session
import ccf.transport.{Request, Response}
trait Message {
def send(s: Session): (Session, Option[Response])
protected def sendRequest(request: Session => Request, session: Session): Option[Response] = session.connection.send(request(session))
}
case class Join(channelId: ChannelId) extends Message {
def send(s: Session): (Session, Option[Response]) = if (!s.channels(channelId)) {
(s.next(s.channels + channelId), sendRequest(JoinRequest(channelId), s))
} else { (s, None) }
}
case class Part(channelId: ChannelId) extends Message {
def send(s: Session): (Session, Option[Response]) = if (s.channels(channelId)) {
(s.next(s.channels - channelId), sendRequest(PartRequest(channelId), s))
} else { (s, None) }
}
| package ccf.session
import ccf.transport.{Request, Response}
case object Shutdown
trait Message {
def send(s: Session): (Session, Option[Response])
protected def sendRequest(request: Session => Request, session: Session): Option[Response] = session.connection.send(request(session))
}
case class Join(channelId: ChannelId) extends Message {
def send(s: Session): (Session, Option[Response]) = if (!s.channels(channelId)) {
(s.next(s.channels + channelId), sendRequest(JoinRequest(channelId), s))
} else { (s, None) }
}
case class Part(channelId: ChannelId) extends Message {
def send(s: Session): (Session, Option[Response]) = if (s.channels(channelId)) {
(s.next(s.channels - channelId), sendRequest(PartRequest(channelId), s))
} else { (s, None) }
}
|
Add shouldBeStatic field for SimpleUseAugmenters | package ch.usi.inf.l3.sana.ooj.ast.augmenters
import ch.usi.inf.l3.sana
import sana.tiny.ast.SimpleUseTree
import sana.tiny.symbols.Symbol
trait AugmentedSimpleUseTree {
def tree: SimpleUseTree
def enclosing: Option[Symbol] =
tree.attributes.get('enclosing).map(_.asInstanceOf[Symbol])
def enclosing_=(enclosing: Symbol): Unit =
tree.attributes = tree.attributes + ('enclosing -> enclosing)
}
| package ch.usi.inf.l3.sana.ooj.ast.augmenters
import ch.usi.inf.l3.sana
import sana.tiny.ast.SimpleUseTree
import sana.tiny.symbols.Symbol
trait AugmentedSimpleUseTree {
def tree: SimpleUseTree
def enclosing: Option[Symbol] =
tree.attributes.get('enclosing).map(_.asInstanceOf[Symbol])
def enclosing_=(enclosing: Symbol): Unit =
tree.attributes = tree.attributes + ('enclosing -> enclosing)
def shouldBeStatic: Boolean =
tree.attributes.get('shouldBeStatic)
.map(_.asInstanceOf[Boolean]).getOrElse(false)
def shouldBeStatic_=(shouldBeStatic: Boolean): Unit =
tree.attributes = tree.attributes + ('shouldBeStatic -> shouldBeStatic)
}
|
Update configuration to record version 0.4.25 | import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.12"
crossScalaVersions := Seq("2.11.12")
version := "0.4.24"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
filters,
"com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
"org.scalatestplus" %% "play" % "1.4.0" % "test"
),
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
credentials += Credentials(
"Artifactory Realm",
"flow.artifactoryonline.com",
System.getenv("ARTIFACTORY_USERNAME"),
System.getenv("ARTIFACTORY_PASSWORD")
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.12"
crossScalaVersions := Seq("2.11.12")
version := "0.4.25"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
filters,
"com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
"org.scalatestplus" %% "play" % "1.4.0" % "test"
),
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
credentials += Credentials(
"Artifactory Realm",
"flow.artifactoryonline.com",
System.getenv("ARTIFACTORY_USERNAME"),
System.getenv("ARTIFACTORY_PASSWORD")
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Update configuration to record version 0.1.97 | import com.github.retronym.SbtOneJar._
import sbt.Credentials
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.12.6"
version := "0.1.96"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"io.flow" %% "lib-util" % "0.1.0",
"io.flow" %% "apibuilder-validation" % "0.2.1",
"com.typesafe.play" %% "play-json" % "2.6.10",
"com.ning" % "async-http-client" % "1.9.40",
"org.scalatest" %% "scalatest" % "3.0.5" % Test
)
)
resolvers += "Artifactory" at "https://flow.jfrog.io/flow/libs-release/"
credentials += Credentials(
"Artifactory Realm",
"flow.jfrog.io",
System.getenv("ARTIFACTORY_USERNAME"),
System.getenv("ARTIFACTORY_PASSWORD")
)
publishTo := {
val host = "https://flow.jfrog.io/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import com.github.retronym.SbtOneJar._
import sbt.Credentials
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.12.6"
version := "0.1.97"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"io.flow" %% "lib-util" % "0.1.0",
"io.flow" %% "apibuilder-validation" % "0.2.1",
"com.typesafe.play" %% "play-json" % "2.6.10",
"com.ning" % "async-http-client" % "1.9.40",
"org.scalatest" %% "scalatest" % "3.0.5" % Test
)
)
resolvers += "Artifactory" at "https://flow.jfrog.io/flow/libs-release/"
credentials += Credentials(
"Artifactory Realm",
"flow.jfrog.io",
System.getenv("ARTIFACTORY_USERNAME"),
System.getenv("ARTIFACTORY_PASSWORD")
)
publishTo := {
val host = "https://flow.jfrog.io/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Remove unneeded yield in for expression. | /* ------------------- sse-jmx ------------------- *\
* Licensed under the Apache License, Version 2.0. *
* Author: Spiros Tzavellas *
\* ----------------------------------------------- */
package com.tzavellas.sse.jmx
import scala.collection.mutable.{HashSet, SynchronizedSet}
import javax.management.{ObjectName, InstanceNotFoundException}
/**
* Tracks MBean registrations.
*
* @see [[unregisterAll]]
*/
trait MBeanRegistrationTracker extends MBeanRegistrationSupport {
private val registered = new HashSet[ObjectName] with SynchronizedSet[ObjectName]
abstract override def registerMBean(mbean: AnyRef, name: ObjectName, behavior: IfAlreadyExists.Enum = IfAlreadyExists.Fail) {
super.registerMBean(mbean, name, behavior)
registered += name
}
abstract override def unregisterMBean(name: ObjectName, ignore: Boolean = false) {
super.unregisterMBean(name)
registered -= name
}
/**
* Unregister all the MBeans that have been registered using this instance.
*
* @see [[registerMBean]]
*/
def unregisterAll() {
for (name <- registered) yield {
try { unregisterMBean(name) }
catch { case e: InstanceNotFoundException => }
}
}
} | /* ------------------- sse-jmx ------------------- *\
* Licensed under the Apache License, Version 2.0. *
* Author: Spiros Tzavellas *
\* ----------------------------------------------- */
package com.tzavellas.sse.jmx
import scala.collection.mutable.{HashSet, SynchronizedSet}
import javax.management.{ObjectName, InstanceNotFoundException}
/**
* Tracks MBean registrations.
*
* @see [[unregisterAll]]
*/
trait MBeanRegistrationTracker extends MBeanRegistrationSupport {
private val registered = new HashSet[ObjectName] with SynchronizedSet[ObjectName]
abstract override def registerMBean(mbean: AnyRef, name: ObjectName, behavior: IfAlreadyExists.Enum = IfAlreadyExists.Fail) {
super.registerMBean(mbean, name, behavior)
registered += name
}
abstract override def unregisterMBean(name: ObjectName, ignore: Boolean = false) {
super.unregisterMBean(name)
registered -= name
}
/**
* Unregister all the MBeans that have been registered using this instance.
*
* @see [[registerMBean]]
*/
def unregisterAll() {
for (name <- registered) {
try { unregisterMBean(name) }
catch { case e: InstanceNotFoundException => }
}
}
} |
Fix wrong placement of constructor due to IntelliJ's code rearranging | package com.github.dkanellis.skyspark.scala.api.algorithms.bnl
import javax.annotation.concurrent.ThreadSafe
import com.github.dkanellis.skyspark.scala.api.algorithms.{Point, SkylineAlgorithm}
import org.apache.spark.rdd.RDD
/**
* A MapReduce based, block-nested loop algorithm (MR-BNL).
* <p>
* First we do the division job of the points to <Flag, Point> and then we merge the local skylines together and
* calculate the total skyline set.
* <p>
* For more information read <i>Adapting Skyline Computation to the MapReduce Framework: Algorithms and Experiments</i>
* by <i>Boliang Zhang, Shuigeng Zhou, Jihong Guan</i>
*
* @param divider The Division part of the algorithm
* @param merger The Merging part of the algorithm
*/
@ThreadSafe
class BlockNestedLoop private[bnl](private val divider: Divider, private val merger: Merger) extends SkylineAlgorithm {
def this() = this(new BnlAlgorithm)
override def computeSkylinePoints(points: RDD[Point]): RDD[Point] = {
require(!points.isEmpty)
val localSkylinesWithFlags = divider.divide(points)
merger.merge(localSkylinesWithFlags)
}
private def this(bnlAlgorithm: BnlAlgorithm) = this(new Divider(bnlAlgorithm), new Merger(bnlAlgorithm))
}
| package com.github.dkanellis.skyspark.scala.api.algorithms.bnl
import javax.annotation.concurrent.ThreadSafe
import com.github.dkanellis.skyspark.scala.api.algorithms.{Point, SkylineAlgorithm}
import org.apache.spark.rdd.RDD
/**
* A MapReduce based, block-nested loop algorithm (MR-BNL).
* <p>
* First we do the division job of the points to <Flag, Point> and then we merge the local skylines together and
* calculate the total skyline set.
* <p>
* For more information read <i>Adapting Skyline Computation to the MapReduce Framework: Algorithms and Experiments</i>
* by <i>Boliang Zhang, Shuigeng Zhou, Jihong Guan</i>
*
* @param divider The Division part of the algorithm
* @param merger The Merging part of the algorithm
*/
@ThreadSafe
class BlockNestedLoop private[bnl](private val divider: Divider, private val merger: Merger) extends SkylineAlgorithm {
private def this(bnlAlgorithm: BnlAlgorithm) = this(new Divider(bnlAlgorithm), new Merger(bnlAlgorithm))
def this() = this(new BnlAlgorithm)
override def computeSkylinePoints(points: RDD[Point]): RDD[Point] = {
require(!points.isEmpty)
val localSkylinesWithFlags = divider.divide(points)
merger.merge(localSkylinesWithFlags)
}
}
|
Update configuration to record version 0.1.34 | import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.1.33"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.13",
"com.ning" % "async-http-client" % "1.9.40",
"org.scalatest" %% "scalatest" % "3.0.1" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.1.34"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.13",
"com.ning" % "async-http-client" % "1.9.40",
"org.scalatest" %% "scalatest" % "3.0.1" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Change to github dependencies using https | val franklin_heisenberg_bridge = Project(id = "franklin-heisenberg-bridge", base = file("."))
.settings(
organization := "se.gigurra",
version := getVersion,
scalaVersion := "2.11.7",
scalacOptions ++= Seq("-feature", "-unchecked", "-deprecation"),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"org.mockito" % "mockito-core" % "1.10.19" % "test"
),
resolvers += "Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases/"
)
.dependsOn(uri("git://github.com/GiGurra/franklin.git#0.1.10"))
.dependsOn(uri("git://github.com/GiGurra/heisenberg.git#0.2.6"))
def getVersion: String = {
val v = scala.util.Properties.envOrNone("FRANKLIN_HEISENBERG_BRIDGE_VERSION").getOrElse {
println(s"No 'FRANKLIN_HEISENBERG_BRIDGE_VERSION' defined - defaulting to SNAPSHOT")
"SNAPSHOT"
}
println(s"Building Franklin Heisenberg Bridge v. $v")
v
}
| val franklin_heisenberg_bridge = Project(id = "franklin-heisenberg-bridge", base = file("."))
.settings(
organization := "se.gigurra",
version := getVersion,
scalaVersion := "2.11.7",
scalacOptions ++= Seq("-feature", "-unchecked", "-deprecation"),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"org.mockito" % "mockito-core" % "1.10.19" % "test"
),
resolvers += "Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases/"
)
.dependsOn(uri("https://github.com/GiGurra/franklin.git#0.1.10"))
.dependsOn(uri("https://github.com/GiGurra/heisenberg.git#0.2.6"))
def getVersion: String = {
val v = scala.util.Properties.envOrNone("FRANKLIN_HEISENBERG_BRIDGE_VERSION").getOrElse {
println(s"No 'FRANKLIN_HEISENBERG_BRIDGE_VERSION' defined - defaulting to SNAPSHOT")
"SNAPSHOT"
}
println(s"Building Franklin Heisenberg Bridge v. $v")
v
}
|
Revert "sbt plugin version bumps" | // Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.url("heroku-sbt-plugin-releases",
url("https://dl.bintray.com/heroku/sbt-plugins/"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.heroku" % "sbt-heroku" % "0.3.0")
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.7")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.2")
| // Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.url("heroku-sbt-plugin-releases",
url("https://dl.bintray.com/heroku/sbt-plugins/"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.heroku" % "sbt-heroku" % "0.1.6")
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.2")
|
Update sbt-scalajs, scalajs-compiler, ... to 1.11.0 | scalacOptions += "-deprecation"
libraryDependencies += "org.slf4j" % "slf4j-nop" % "2.0.1"
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")
| scalacOptions += "-deprecation"
libraryDependencies += "org.slf4j" % "slf4j-nop" % "2.0.1"
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.11.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")
|
Update sbt-softwaremill-browser-test-js, ... to 2.0.5 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.8.0")
val sbtSoftwareMillVersion = "2.0.4"
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-browser-test-js" % sbtSoftwareMillVersion)
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21")
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.1")
| addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.8.0")
val sbtSoftwareMillVersion = "2.0.5"
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-browser-test-js" % sbtSoftwareMillVersion)
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21")
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.1")
|
Update mdoc, sbt-mdoc to 2.3.3 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.5")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0")
val sbtSoftwareMillVersion = "2.0.9"
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-browser-test-js" % sbtSoftwareMillVersion)
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2")
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.1")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
| addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.5")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0")
val sbtSoftwareMillVersion = "2.0.9"
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion)
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-browser-test-js" % sbtSoftwareMillVersion)
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.3")
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.1")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
|
Revert sbteclipse-plugin to v2.5.0. Eclipse was continually building the workspace, that's fixed when using v2.5.0. The error 'object index is not a member of package views.html' is still present in Application.scala regardless of the eclipse plugin version used. | // Comment to get more information during initialization
logLevel := Level.Warn
// Resolvers
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.url("heroku-sbt-plugin-releases",
url("https://dl.bintray.com/heroku/sbt-plugins/"))(Resolver.ivyStylePatterns)
// Sbt plugins
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.3")
addSbtPlugin("com.vmunier" % "sbt-play-scalajs" % "0.2.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
addSbtPlugin("com.heroku" % "sbt-heroku" % "0.3.4")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "3.0.0")
| // Comment to get more information during initialization
logLevel := Level.Warn
// Resolvers
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.url("heroku-sbt-plugin-releases",
url("https://dl.bintray.com/heroku/sbt-plugins/"))(Resolver.ivyStylePatterns)
// Sbt plugins
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.3")
addSbtPlugin("com.vmunier" % "sbt-play-scalajs" % "0.2.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
addSbtPlugin("com.heroku" % "sbt-heroku" % "0.3.4")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
|
Update test: the problem is already fixed in master | import api._
object Test {
def f(implicit x: Int): Int = x * x
def main(args: Array[String]): Unit = {
implicit val x: Int = 10
assert(args(0).reflect == "args(0)")
assert(args( 0 ).reflect == "args( 0 )")
assert(args( 0 /* ignore */).reflect == "args( 0 /* ignore */)")
assert(f.reflect == "f")
assert((f).reflect == "f")
assert( { f }.reflect == "f")
assert( { f; f }.reflect == "f")
}
}
| import api._
object Test {
def f(implicit x: Int): Int = x * x
def main(args: Array[String]): Unit = {
implicit val x: Int = 10
assert(args(0).reflect == "args(0)")
assert(args( 0 ).reflect == "args( 0 )")
assert(args( 0 /* ignore */).reflect == "args( 0 /* ignore */)")
assert(f.reflect == "f")
assert((f).reflect == "f")
assert( { f }.reflect == "{ f }")
assert( { f; f }.reflect == "{ f; f }")
}
}
|
DELETE should not accept a JSON body | package core.generator
import core.Util
private[generator] object GeneratorUtil {
def isJsonDocumentMethod(verb: String): Boolean = {
verb != "GET"
}
// TODO: Remove wrapper
def namedParametersInPath(path: String) = Util.namedParametersInPath(path)
/**
* Format into a multi-line comment w/ a set number of spaces for
* leading indentation
*/
def formatComment(comment: String, numberSpaces: Int = 0): String = {
val maxLineLength = 80 - 2 - numberSpaces
val sb = new StringBuilder()
var currentWord = new StringBuilder()
comment.split(" ").foreach { word =>
if (word.length + currentWord.length >= maxLineLength) {
if (!currentWord.isEmpty) {
if (!sb.isEmpty) {
sb.append("\n")
}
sb.append((" " * numberSpaces)).append("#").append(currentWord.toString)
}
currentWord = new StringBuilder()
}
currentWord.append(" ").append(word)
}
if (!currentWord.isEmpty) {
if (!sb.isEmpty) {
sb.append("\n")
}
sb.append((" " * numberSpaces)).append("#").append(currentWord.toString)
}
sb.toString
}
}
| package core.generator
import core.Util
private[generator] object GeneratorUtil {
def isJsonDocumentMethod(verb: String): Boolean = {
verb != "GET" && verb != "DELETE"
}
// TODO: Remove wrapper
def namedParametersInPath(path: String) = Util.namedParametersInPath(path)
/**
* Format into a multi-line comment w/ a set number of spaces for
* leading indentation
*/
def formatComment(comment: String, numberSpaces: Int = 0): String = {
val maxLineLength = 80 - 2 - numberSpaces
val sb = new StringBuilder()
var currentWord = new StringBuilder()
comment.split(" ").foreach { word =>
if (word.length + currentWord.length >= maxLineLength) {
if (!currentWord.isEmpty) {
if (!sb.isEmpty) {
sb.append("\n")
}
sb.append((" " * numberSpaces)).append("#").append(currentWord.toString)
}
currentWord = new StringBuilder()
}
currentWord.append(" ").append(word)
}
if (!currentWord.isEmpty) {
if (!sb.isEmpty) {
sb.append("\n")
}
sb.append((" " * numberSpaces)).append("#").append(currentWord.toString)
}
sb.toString
}
}
|
Implement Implicit Class with Extension Method | package slick.util
/**
* An iterator on top of a data source which does not offer a hasNext()
* method without doing a next()
*/
trait ReadAheadIterator[+T] extends BufferedIterator[T] {
private[this] var state = 0 // 0: no data, 1: cached, 2: finished
private[this] var cached: T = null.asInstanceOf[T]
protected[this] final def finished(): T = {
state = 2
null.asInstanceOf[T]
}
/** Return a new value or call finished() */
protected def fetchNext(): T
def head: T = {
update()
if(state == 1) cached
else throw new NoSuchElementException("head on empty iterator")
}
private[this] def update() {
if(state == 0) {
cached = fetchNext()
if(state == 0) state = 1
}
}
def hasNext: Boolean = {
update()
state == 1
}
def next(): T = {
update()
if(state == 1) {
state = 0
cached
} else throw new NoSuchElementException("next on empty iterator");
}
}
| package slick.util
/**
* An iterator on top of a data source which does not offer a hasNext()
* method without doing a next()
*/
trait ReadAheadIterator[+T] extends BufferedIterator[T] {
private[this] var state = 0 // 0: no data, 1: cached, 2: finished
private[this] var cached: T = null.asInstanceOf[T]
protected[this] final def finished(): T = {
state = 2
null.asInstanceOf[T]
}
/** Return a new value or call finished() */
protected def fetchNext(): T
def head: T = {
update()
if(state == 1) cached
else throw new NoSuchElementException("head on empty iterator")
}
private[this] def update() {
if(state == 0) {
cached = fetchNext()
if(state == 0) state = 1
}
}
def hasNext: Boolean = {
update()
state == 1
}
def next(): T = {
update()
if(state == 1) {
state = 0
cached
} else throw new NoSuchElementException("next on empty iterator");
}
}
object ReadAheadIterator {
/** Feature implemented in Scala library 2.12 this maintains functionality for 2.11 */
implicit class headOptionReverseCompatibility[T](readAheadIterator: ReadAheadIterator[T]){
def headOption : Option[T] = if (readAheadIterator.hasNext) Some(readAheadIterator.head) else None
}
}
|
Fix "Class javax.annotation.Nullable not found" | name := "no-carrier"
version := "1.0"
scalaVersion := "2.11.5"
mainClass := Some("com.getbootstrap.no_carrier.Main")
resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)
libraryDependencies += "com.jcabi" % "jcabi-github" % "0.24"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.2"
libraryDependencies += "org.specs2" %% "specs2" % "2.3.12" % "test"
scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "–Xlint", "-encoding", "utf8")
scalacOptions in Test ++= Seq("-Yrangepos")
// parallelExecution in Test := false
Revolver.settings
| name := "no-carrier"
version := "1.0"
scalaVersion := "2.11.5"
mainClass := Some("com.getbootstrap.no_carrier.Main")
resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)
libraryDependencies += "com.jcabi" % "jcabi-github" % "0.24"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.2"
libraryDependencies += "org.specs2" %% "specs2" % "2.3.12" % "test"
// Because jcabi-github:
libraryDependencies += "com.google.code.findbugs" % "annotations" % "2.0.1"
scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "–Xlint", "-encoding", "utf8")
scalacOptions in Test ++= Seq("-Yrangepos")
// parallelExecution in Test := false
Revolver.settings
|
Add FEST and MOCKITO librairies | name := """reactive-elasticsearch-play"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
libraryDependencies ++= Seq(
"net.lingala.zip4j" % "zip4j" % "1.3.2",
"org.testng" % "testng" % "6.8.8",
"com.google.inject" % "guice" % "3.0",
"org.elasticsearch" % "elasticsearch" % "1.5.1",
"org.apache.tika" % "tika-core" % "1.7",
"org.apache.tika" % "tika-parsers" % "1.7")
initialize := {
val _ = initialize.value
if (sys.props("java.specification.version") != "1.8")
sys.error("Java 8 is required for this project.")
} | name := """reactive-elasticsearch-play"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
libraryDependencies ++= Seq(
"org.testng" % "testng" % "6.8.8",
"org.mockito" % "mockito-all" % "1.9.5",
"org.easytesting" % "fest-assert-core" % "2.0M10",
"com.google.inject" % "guice" % "3.0",
"org.elasticsearch" % "elasticsearch" % "1.5.1",
"net.lingala.zip4j" % "zip4j" % "1.3.2",
"org.apache.tika" % "tika-core" % "1.7",
"org.apache.tika" % "tika-parsers" % "1.7")
initialize := {
val _ = initialize.value
if (sys.props("java.specification.version") != "1.8")
sys.error("Java 8 is required for this project.")
} |
Build a judge suggestion api | package frmr.scyig.webapp.api
import frmr.scyig.db._
import frmr.scyig.webapp.auth.AuthenticationHelpers._
import net.liftweb.common._
import net.liftweb.http._
import net.liftweb.http.rest._
import net.liftweb.json._
import net.liftweb.json.JsonDSL._
import net.liftweb.util.Helpers._
import net.liftweb.util.CanResolveAsync.resolveFuture
import scala.concurrent.ExecutionContext.Implicits.global
import slick.jdbc.MySQLProfile.api._
object SuggestionApi extends RestHelper {
serve {
case Get("api" :: "v1" :: "competition" :: AsInt(competitionId) :: "team-suggestions" :: Nil, req) if currentUserId.is > 0 =>
val nameQuery = S.param("q").openOr("")
val query = Teams.to[List]
.filter(_.name startsWith nameQuery)
.filter(_.competitionId === competitionId)
.result
DB.run(query).map { teams =>
val teamObjs = teams.map { team =>
("display" -> team.name) ~
("value" -> team.id)
}
JsonResponse(teamObjs)
}
}
}
| package frmr.scyig.webapp.api
import frmr.scyig.db._
import frmr.scyig.webapp.auth.AuthenticationHelpers._
import net.liftweb.common._
import net.liftweb.http._
import net.liftweb.http.rest._
import net.liftweb.json._
import net.liftweb.json.JsonDSL._
import net.liftweb.util.Helpers._
import net.liftweb.util.CanResolveAsync.resolveFuture
import scala.concurrent.ExecutionContext.Implicits.global
import slick.jdbc.MySQLProfile.api._
object SuggestionApi extends RestHelper {
serve {
case Get("api" :: "v1" :: "competition" :: AsInt(competitionId) :: "team-suggestions" :: Nil, req) if currentUserId.is > 0 =>
val nameQuery = S.param("q").openOr("")
val query = Teams.to[List]
.filter(_.name startsWith nameQuery)
.filter(_.competitionId === competitionId)
.result
DB.run(query).map { teams =>
val teamObjs = teams.map { team =>
("display" -> team.name) ~
("value" -> team.id)
}
JsonResponse(teamObjs)
}
case Get("api" :: "v1" :: "competition" :: AsInt(competitionId) :: "judge-suggestions" :: Nil, req) if currentUserId.is > 0 =>
val nameQuery = S.param("q").openOr("")
val query = Judges.to[List]
.filter(_.name startsWith nameQuery)
.filter(_.competitionId === competitionId)
.result
DB.run(query).map { judges =>
val judgeObjs = judges.map { judge =>
("display" -> judge.name) ~
("value" -> judge.id)
}
JsonResponse(judgeObjs)
}
}
}
|
Update sbt-scalajs, scalajs-compiler to 0.6.27 | resolvers += Classpaths.sbtPluginReleases
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.10")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.26")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0")
| resolvers += Classpaths.sbtPluginReleases
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.10")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0")
|
Update dependency scala to v2.13.5 | scalaVersion := "2.13.4"
scalacOptions ++= Seq(
"-Ywarn-unused"
)
| scalaVersion := "2.13.5"
scalacOptions ++= Seq(
"-Ywarn-unused"
)
|
Build the context and find the fit of each call-with statement. | package lore
import lore.ast._
import lore.parser.{FileParser, FpExpressionParser}
import scala.io.Source
object Lore {
def testCalculation(): Unit = {
val source = Source.fromFile("examples/calculation.lore").getLines.mkString
val parser = new FpExpressionParser()
val expression = parser.parseExpression(source)
val result = ExprAlgebra.evaluate(ExprAlgebra.evalAlgebra)(expression)
println("FP result: " + result)
}
def main(args: Array[String]): Unit = {
// A new line is added at the end so the last statement has a closing newline.
val source = Source.fromFile("examples/concat.lore").getLines.filter(_.trim.nonEmpty).mkString("\n") + "\n"
println(source)
val parser = new FileParser()
val elements = parser.parse(source)
println()
println("Elements: ")
elements.foreach(println)
}
}
| package lore
import lore.ast._
import lore.exceptions.FunctionNotFoundException
import lore.execution.Context
import lore.parser.{FileParser, FpExpressionParser}
import scala.io.Source
object Lore {
def testCalculation(): Unit = {
val source = Source.fromFile("examples/calculation.lore").getLines.mkString
val parser = new FpExpressionParser()
val expression = parser.parseExpression(source)
val result = ExprAlgebra.evaluate(ExprAlgebra.evalAlgebra)(expression)
println("FP result: " + result)
}
def main(args: Array[String]): Unit = {
// A new line is added at the end so the last statement has a closing newline.
val source = Source.fromFile("examples/concat.lore").getLines.filter(_.trim.nonEmpty).mkString("\n") + "\n"
println(source)
val parser = new FileParser()
val elements = parser.parse(source)
println()
println("Elements: ")
elements.foreach(println)
val context = Context.build(elements)
println()
println("Function fit for each call statement:")
context.calls.foreach { call =>
val multiFunction = context.multiFunctions.getOrElse(call.functionName, throw FunctionNotFoundException(call.functionName))
val fit = multiFunction.fit(call.argumentType)
println(fit)
}
}
}
|
Update nscplugin, sbt-scala-native, ... to 0.4.5 in master | addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
| addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.5")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
Upgrade gatling-build-plugin 2.6.0 to compile with Scala 2.13.3 | resolvers += Resolver.bintrayIvyRepo("gatling", "sbt-plugins")
resolvers += Resolver.jcenterRepo
addSbtPlugin("io.gatling" % "gatling-build-plugin" % "2.5.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.5")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.0")
addSbtPlugin("net.aichler" % "sbt-jupiter-interface" % "0.7.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.10")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.21")
| resolvers += Resolver.bintrayIvyRepo("gatling", "sbt-plugins")
resolvers += Resolver.jcenterRepo
addSbtPlugin("io.gatling" % "gatling-build-plugin" % "2.6.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.5")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.0")
addSbtPlugin("net.aichler" % "sbt-jupiter-interface" % "0.7.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.10")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.21")
|
Add test for fallback modifier. | package k2b6s9j.boatcraft.test.api.registry
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import k2b6s9j.boatcraft.api.registry.ModifierRegistry
import k2b6s9j.boatcraft.test.api.traits.examples._
import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import scala.collection.JavaConversions._
@RunWith(classOf[JUnitRunner])
class SingleModifierRegistryTest extends FlatSpec with Matchers with BeforeAndAfter
{
before
{
ModifierRegistry addModifier ExampleModifier
}
"A Modifier" should "be added to the registered Modifiers map." in
{
ModifierRegistry.modifiers.toMap should contain("test", ExampleModifier)
}
it should "be returned when searched by name." in
{
ModifierRegistry getModifier "test" shouldBe ExampleModifier
}
it should "be returned when searched by ItemStack." in
{
val stack = new ItemStack(Blocks.bedrock)
stack.stackTagCompound = new NBTTagCompound
stack.stackTagCompound setString ("modifier", "test")
ModifierRegistry getModifier stack shouldBe ExampleModifier
}
}
| package k2b6s9j.boatcraft.test.api.registry
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import k2b6s9j.boatcraft.api.registry.ModifierRegistry
import k2b6s9j.boatcraft.test.api.traits.examples._
import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import scala.collection.JavaConversions._
import k2b6s9j.boatcraft.core.materials.Empty
@RunWith(classOf[JUnitRunner])
class SingleModifierRegistryTest extends FlatSpec with Matchers with BeforeAndAfter
{
before
{
ModifierRegistry addModifier ExampleModifier
}
"A Modifier" should "be added to the registered Modifiers map." in
{
ModifierRegistry.modifiers.toMap should contain("test", ExampleModifier)
}
it should "be returned when searched by name." in
{
ModifierRegistry getModifier "test" shouldBe ExampleModifier
}
it should "be returned when searched by ItemStack." in
{
val stack = new ItemStack(Blocks.bedrock)
stack.stackTagCompound = new NBTTagCompound
stack.stackTagCompound setString ("modifier", "test")
ModifierRegistry getModifier stack shouldBe ExampleModifier
}
it should "fallback to an Empty modifier if no modifier is defined." in {
val stack = new ItemStack(Blocks.bedrock)
ModifierRegistry getModifier stack shouldBe Empty
}
}
|
Fix searches starting with ":" | package ophir.search
import ophir.model.Def
import ophir.db.DefRepo
import ophir.parser.SigParser
object Search {
type Result = Either[String, Iterator[Def]]
private val mixedRegex = """^([^\:]+)\:(.+)$""".r
def find(query: String): Result = query match {
case mixedRegex(text, tpe) => MixedEngine find (text, tpe)
case tpe if tpe contains "=>" => TypeEngine find tpe
case text => TextEngine find text
}
object TextEngine {
def find(text: String): Result =
tokenize(text).right map DefRepo.findByTokens
def tokenize(text: String): Either[String, List[String]] = Def nameToTokens text match {
case Nil => Left("Empty text")
case tokens => Right(tokens)
}
}
object TypeEngine {
def find(tpe: String): Result =
normalize(tpe).right map DefRepo.findBySig
def normalize(tpe: String): Either[String, String] =
SigParser(tpe).right map (_.normalize.toString)
}
object MixedEngine {
def find(text: String, tpe: String): Result = for {
tokens <- (TextEngine tokenize text).right
normalized <- (TypeEngine normalize tpe).right
} yield DefRepo.findByTokensAndSig(tokens, normalized)
}
}
| package ophir.search
import ophir.model.Def
import ophir.db.DefRepo
import ophir.parser.SigParser
object Search {
type Result = Either[String, Iterator[Def]]
private val mixedRegex = """^([^\:]*)\:(.+)$""".r
def find(query: String): Result = query match {
case mixedRegex("", tpe) => TypeEngine find tpe
case mixedRegex(text, tpe) => MixedEngine find (text, tpe)
case tpe if tpe contains "=>" => TypeEngine find tpe
case text => TextEngine find text
}
object TextEngine {
def find(text: String): Result =
tokenize(text).right map DefRepo.findByTokens
def tokenize(text: String): Either[String, List[String]] = Def nameToTokens text match {
case Nil => Left("Empty text")
case tokens => Right(tokens)
}
}
object TypeEngine {
def find(tpe: String): Result =
normalize(tpe).right map DefRepo.findBySig
def normalize(tpe: String): Either[String, String] =
SigParser(tpe).right map (_.normalize.toString)
}
object MixedEngine {
def find(text: String, tpe: String): Result = for {
tokens <- (TextEngine tokenize text).right
normalized <- (TypeEngine normalize tpe).right
} yield DefRepo.findByTokensAndSig(tokens, normalized)
}
}
|
Work for day two of Scala | package daytwo
/**
* Addendum leading up to day two exercises.
*/
class Scrap {
def run() {
val list = List("Guts man", "Bubble man", "Proto man")
list.foreach(man => println(man)) //anonymous functions are pretty neat
println()
list.init.foreach(man => println(man))
println()
list.tail.foreach(man => println(man))
println()
list.drop(2).foreach(man => println(man))
//and as a set...
println() //formatting
val set = Set("Spark man", "Wood man", "Dr. Light")
set.foreach(man => println(man))
println()
val powers = Map("Spark man" -> "Electricity", "Bubble man" -> "Fires Bubbles", "Guts man" -> "No idea")
println(powers.foreach(man => println(man._2)))
println() //formatting
println(list.forall(man => man.contains("man")))
println(set.forall(man => man.contains("man")))
}
}
| package daytwo
/**
* Addendum leading up to day two exercises.
*/
class Scrap {
def run() {
val list = List("Guts man", "Bubble man", "Proto man")
list.foreach(man => println(man)) //anonymous functions are pretty neat
println()
list.init.foreach(man => println(man))
println()
list.tail.foreach(man => println(man))
println()
list.drop(2).foreach(man => println(man))
//and as a set...
println() //formatting
val set = Set("Spark man", "Wood man", "Dr. Light")
set.foreach(man => println(man))
println()
val powers = Map("Spark man" -> "Electricity", "Bubble man" -> "Fires Bubbles", "Guts man" -> "No idea")
println(powers.foreach(man => println(man._2)))
println() //formatting
println(list.forall(man => man.contains("man")))
println(set.forall(man => man.contains("man")))
println(set.exists(man => man.contains("Dr")))
println()
println(stringLengthSum(list))
}
//exercise one - use foldLeft to compute the total size of a list of strings
def stringLengthSum(strings: List[String]): Int = {
strings.foldLeft(0)((sum, value) => sum + value.length)
}
}
|
Set no-cache on todaysLunches response | package controllers
import play.api._
import cache.Cached
import play.api.Play.current
import libs.concurrent.Akka
import mvc._
import play.api.libs.json._
import impl.lunchInfo._
object LunchInfo extends Controller {
def index = Action { request =>
Ok(views.html.lunchInfo.index())
}
def todaysLunches = Cached("todaysLunches", 60 * 10) {
Action { request =>
val todaysLunchesPromise = Akka.future { LunchInfoFetcher.fetchTodaysLunchInfo }
Async {
todaysLunchesPromise.map(todaysLunches => Ok(views.html.lunchInfo.todaysLunches(todaysLunches)))
}
}
}
def fetchLunchInfo = Action { request =>
/*
request.body.asJson.map { json =>
(json \ "name").asOpt[String].map { name =>
Ok("Hello " + name)
}.getOrElse {
BadRequest("Missing parameter [name]")
}
}.getOrElse {
BadRequest("Expecting Json impl")
}
*/
val json = Json.toJson(
Map("status" -> "OK")
)
Ok(json)
}
def fetchLunchInfoExample = Action { request =>
val json = Json.toJson(
Map("status" -> "OK")
)
Ok(json)
}
} | package controllers
import play.api._
import cache.Cached
import play.api.Play.current
import libs.concurrent.Akka
import mvc._
import play.api.libs.json._
import impl.lunchInfo._
object LunchInfo extends Controller {
def index = Action { request =>
Ok(views.html.lunchInfo.index())
}
def todaysLunches = Cached("todaysLunches", 60 * 10) {
Action { request =>
val todaysLunchesPromise = Akka.future { LunchInfoFetcher.fetchTodaysLunchInfo }
Async {
todaysLunchesPromise.map(todaysLunches =>
Ok(views.html.lunchInfo.todaysLunches(todaysLunches)).withHeaders(PRAGMA -> "no-cache")
)
}
}
}
def fetchLunchInfo = Action { request =>
/*
request.body.asJson.map { json =>
(json \ "name").asOpt[String].map { name =>
Ok("Hello " + name)
}.getOrElse {
BadRequest("Missing parameter [name]")
}
}.getOrElse {
BadRequest("Expecting Json impl")
}
*/
val json = Json.toJson(
Map("status" -> "OK")
)
Ok(json)
}
def fetchLunchInfoExample = Action { request =>
val json = Json.toJson(
Map("status" -> "OK")
)
Ok(json)
}
} |
Add the test to sort the fromSelectList. | /**
* Copyright 2017 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager.model
import org.scalatest.FunSuite
/**
* @author fuji-151a
*/
class KafkaVersionTest extends FunSuite {
test("testFormSelectList") {
}
}
| /**
* Copyright 2017 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager.model
import org.scalatest.FunSuite
/**
* @author fuji-151a
*/
class KafkaVersionTest extends FunSuite {
test("Sort formSelectList") {
val expected: IndexedSeq[(String,String)] = Vector(
("0.8.1.1","0.8.1.1"),
("0.8.2.0","0.8.2.0"),
("0.8.2.1","0.8.2.1"),
("0.8.2.2","0.8.2.2"),
("0.9.0.0","0.9.0.0"),
("0.9.0.1","0.9.0.1"),
("0.10.0.0","0.10.0.0"),
("0.10.0.1","0.10.0.1"),
("0.10.1.0","0.10.1.0"),
("0.10.1.1","0.10.1.1"),
("0.10.2.0","0.10.2.0"),
("0.10.2.1","0.10.2.1")
)
assertResult(expected)(KafkaVersion.formSelectList)
}
}
|
Update configuration to record version 0.0.44 | import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-lint"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.43"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.3",
"com.ning" % "async-http-client" % "1.9.38",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-lint"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.44"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.3",
"com.ning" % "async-http-client" % "1.9.38",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Update sbt-sonatype to 3.9.15 in master | addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.14")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.11.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
| addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.15")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.11.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
Update configuration to record version 0.0.15 | name := "proxy"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.enablePlugins(NewRelic)
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= Seq(
filters,
ws,
"com.jason-goodwin" %% "authentikat-jwt" % "0.4.1",
"org.yaml" % "snakeyaml" % "1.17",
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0" % "test"
)
)
val credsToUse = Option(System.getenv("ARTIFACTORY_USERNAME")) match {
case None => Credentials(Path.userHome / ".ivy2" / ".artifactory")
case _ => Credentials("Artifactory Realm","flow.artifactoryonline.com",System.getenv("ARTIFACTORY_USERNAME"),System.getenv("ARTIFACTORY_PASSWORD"))
}
lazy val commonSettings: Seq[Setting[_]] = Seq(
name <<= name("proxy-" + _),
scalacOptions += "-feature",
sources in (Compile,doc) := Seq.empty,
publishArtifact in (Compile, packageDoc) := false,
credentials += credsToUse,
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/"
)
version := "0.0.14"
| name := "proxy"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.enablePlugins(NewRelic)
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= Seq(
filters,
ws,
"com.jason-goodwin" %% "authentikat-jwt" % "0.4.1",
"org.yaml" % "snakeyaml" % "1.17",
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0" % "test"
)
)
val credsToUse = Option(System.getenv("ARTIFACTORY_USERNAME")) match {
case None => Credentials(Path.userHome / ".ivy2" / ".artifactory")
case _ => Credentials("Artifactory Realm","flow.artifactoryonline.com",System.getenv("ARTIFACTORY_USERNAME"),System.getenv("ARTIFACTORY_PASSWORD"))
}
lazy val commonSettings: Seq[Setting[_]] = Seq(
name <<= name("proxy-" + _),
scalacOptions += "-feature",
sources in (Compile,doc) := Seq.empty,
publishArtifact in (Compile, packageDoc) := false,
credentials += credsToUse,
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/"
)
version := "0.0.15"
|
Update http4s-blaze-client, http4s-circe to 0.20.6 | scalacOptions := Seq(
"-deprecation"
)
// For MimeLoader plugin. Dogfooding and hoping it doesn't clash with
// our other sbt plugins.
libraryDependencies ++= List(
"com.eed3si9n" %% "treehugger" % "0.4.3",
"io.circe" %% "circe-generic" % "0.11.1",
"org.http4s" %% "http4s-blaze-client" % "0.20.4",
"org.http4s" %% "http4s-circe" % "0.20.4",
)
// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.2.0"
| scalacOptions := Seq(
"-deprecation"
)
// For MimeLoader plugin. Dogfooding and hoping it doesn't clash with
// our other sbt plugins.
libraryDependencies ++= List(
"com.eed3si9n" %% "treehugger" % "0.4.3",
"io.circe" %% "circe-generic" % "0.11.1",
"org.http4s" %% "http4s-blaze-client" % "0.20.6",
"org.http4s" %% "http4s-circe" % "0.20.6",
)
// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.2.0"
|
Speed up assembly by disabling assembly for projects that don't need it | import com.socrata.sbtplugins.StylePlugin.StyleKeys._
import sbt.Keys._
import sbt._
object BuildSettings {
def buildSettings: Seq[Setting[_]] =
spray.revolver.RevolverPlugin.Revolver.settings ++
Defaults.itSettings ++
Seq(
// TODO: enable coverage minimum
scoverage.ScoverageSbtPlugin.ScoverageKeys.coverageFailOnMinimum := false,
// TODO: enable style checks
styleCheck in Test := {},
styleCheck in Compile := {},
scalaVersion := "2.10.4",
resolvers += "velvia maven" at "http://dl.bintray.com/velvia/maven"
)
def projectSettings(assembly: Boolean = false): Seq[Setting[_]] =
buildSettings
}
| import com.socrata.sbtplugins.StylePlugin.StyleKeys._
import sbt.Keys._
import sbt._
import sbtassembly.AssemblyKeys
object BuildSettings {
def buildSettings: Seq[Setting[_]] =
spray.revolver.RevolverPlugin.Revolver.settings ++
Defaults.itSettings ++
Seq(
// TODO: enable coverage minimum
scoverage.ScoverageSbtPlugin.ScoverageKeys.coverageFailOnMinimum := false,
// TODO: enable style checks
styleCheck in Test := {},
styleCheck in Compile := {},
scalaVersion := "2.10.4",
resolvers += "velvia maven" at "http://dl.bintray.com/velvia/maven"
)
def projectSettings(assembly: Boolean = false): Seq[Setting[_]] =
buildSettings ++
(if (!assembly) Seq(AssemblyKeys.assembly := file(".")) else Nil)
}
|
Update sbt-scalajs, scalajs-compiler to 1.0.1 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.6")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
// addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
| addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.6")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.1")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
// addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
|
Update configuration to record version 0.0.69 | import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.68"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.4",
"com.ning" % "async-http-client" % "1.9.39",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.69"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.4",
"com.ning" % "async-http-client" % "1.9.39",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Add super calls to trait initialization test) | trait A {
var str = ""
str = "a"
val s = str += 'A'
str += '1'
}
trait B extends A {
str += 'b'
override val s = str += 'B'
str += '2'
}
class D extends A {
str += 'd'
override val s = str += 'D'
str += '3'
}
object Test extends D with B {
// should only have 2 fields
str += 'E'
def main(args: Array[String]) = assert(str == "aA1dD3bB2E4")
str += '4'
}
| trait A {
var str = ""
str = "a"
val s = str += 'A'
str += '1'
}
trait B extends A {
str += 'b'
override val s = str += 'B'
str += '2'
}
class D(sup: =>String) extends A {
str += 'd'
override val s = str += 'D'
str += '3'
}
object Test extends D({Test.str += "Z"; Test.str}) with B {
// should only have 2 fields
str += 'E'
def main(args: Array[String]) = assert(str == "aA1dD3bB2E4", str)
str += '4'
}
|
Increment version from 0.0.9 => 0.0.10 | import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-lint"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.7"
version := "0.0.9"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.4.6",
"com.ning" % "async-http-client" % "1.9.32",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-lint"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.7"
version := "0.0.10"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.4.6",
"com.ning" % "async-http-client" % "1.9.32",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Modify build for toolxit-bibtex. Still not working :( | package root
import com.typesafe.sbt.osgi.OsgiKeys
import sbt._
import Keys._
import org.openmole.buildsystem.OMKeys._
object ThirdParties extends Defaults {
lazy val dir = file("third-parties")
lazy val iceTar = OsgiProject("com.ice.tar") settings (bundleType := Set("core"))
lazy val toolxitBibtexMacros = OsgiProject("toolxit.bibtex.macros", "toolxit.bibtex/macros") settings (
bundleType := Set("core"),
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _)
)
lazy val toolxitBibtex = OsgiProject("toolxit.bibtex.core", "toolxit.bibtex/core", exports = Seq("toolxit.bibtex.*"), buddyPolicy = Some("global"), imports = Seq("*")) dependsOn (toolxitBibtexMacros) settings (
bundleType := Set("core"),
OsgiKeys.importPackage := Seq("*"),
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % "1.0.3",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.3",
"org.freemarker" % "freemarker" % "2.3.19",
Libraries.slf4j
)
)
}
| package root
import com.typesafe.sbt.osgi.OsgiKeys
import sbt._
import Keys._
import org.openmole.buildsystem.OMKeys._
object ThirdParties extends Defaults {
lazy val dir = file("third-parties")
lazy val iceTar = OsgiProject("com.ice.tar") settings (bundleType := Set("core"))
lazy val toolxitBibtexMacros = OsgiProject("toolxit.bibtex.macros", "toolxit.bibtex/macros") settings (
// bundleType := Set("core"),
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _)
)
lazy val toolxitBibtex = OsgiProject("toolxit.bibtex.core", "toolxit.bibtex/core", exports = Seq("toolxit.bibtex.*"), imports = Seq("*"), privatePackages = Seq("!scala.*", "*")) dependsOn (toolxitBibtexMacros) settings (
// bundleType := Set("core"),
OsgiKeys.importPackage := Seq("*"),
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % "1.0.3",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.3",
"org.freemarker" % "freemarker" % "2.3.19",
Libraries.slf4j
)
)
}
|
Update sbt-scalajs, scalajs-compiler, ... to 1.9.0 | addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
resolvers += Classpaths.sbtPluginReleases
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
// cross-compiling
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
| addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
resolvers += Classpaths.sbtPluginReleases
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
// cross-compiling
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")
|
Add a local val to lifted try to make sure owners are still legal. | object Test {
def raise(x: Int) = { throw new Exception(s"$x"); 0 }
def handle: Throwable => Int = { case ex: Exception => ex.getMessage().toInt }
val x = try raise(1) catch handle
def foo(x: Int) = {
val y = try raise(x) catch handle
y
}
foo(try 3 catch handle)
def main(args: Array[String]): Unit = {
assert(x == 1)
assert(foo(2) == 2)
assert(foo(try raise(3) catch handle) == 3)
Tr.foo
}
}
object Tr {
def fun(a: Int => Unit) = a(2)
def foo: Int = {
var s = 1
s = try {fun(s = _); 3} catch{ case ex: Throwable => s = 4; 5 }
s
}
}
| object Test {
def raise(x: Int) = { throw new Exception(s"$x"); 0 }
def handle: Throwable => Int = { case ex: Exception => ex.getMessage().toInt }
val x = try raise(1) catch handle
def foo(x: Int) = {
val y = try raise(x) catch handle
y
}
foo(try 3 catch handle)
def main(args: Array[String]): Unit = {
assert(x == 1)
assert(foo(2) == 2)
assert(foo(try raise(3) catch handle) == 3)
Tr.foo
}
}
object Tr {
def fun(a: Int => Unit) = a(2)
def foo: Int = {
var s = 1
s = try {fun(s = _); 3} catch{ case ex: Throwable => val x = 4; s = x; 5 }
s
}
}
|
Implement a simple plugin system for game logic. | package controllers
import play.api._
import play.api.mvc._
object Plugin extends Controller {
def route(path: String) : Action[AnyContent] = Action {
Ok("Done")
}
}
| package controllers
import org.mozilla.javascript.Context
import org.mozilla.javascript.Function
import org.mozilla.javascript.Scriptable
import play.api._
import play.api.mvc._
// FIXME: Move GamePlugin and its related classes, traits and objects to beyond package.
private trait GamePlugin {
// FIXME: Pass request parameters along with path and
// make it possible to return the result asynchronously.
def handle(path: String): String
}
// FIXME: Handle script errors.
private object GamePlugin {
def apply(): GamePlugin = {
// FIXME: Don't hardcode plugin source code here.
val source = "function handle(path) { return 'Hello ' + path; }"
val cx: Context = Context.enter()
try {
val scope: Scriptable = cx.initStandardObjects()
cx.evaluateString(scope, source, "source", 1, null)
// FIXME: Don't hardcode the name of handler function.
// FIXME: handler might be Scriptable.NOT_FOUND if there is no function named "handle".
// Also, it might not be an instance of Function.
val handler = scope.get("handle", scope).asInstanceOf[Function]
new GamePluginImpl(scope, handler)
} finally {
Context.exit()
}
}
private class GamePluginImpl(scope: Scriptable, handler: Function) extends GamePlugin {
def handle(path: String): String = {
val cx: Context = Context.enter()
try {
val args: Array[AnyRef] = Array(path)
val result = handler.call(cx, scope, scope, args)
result.toString
} finally {
Context.exit()
}
}
}
}
object Plugin extends Controller {
private val gamePlugin: GamePlugin = GamePlugin()
def route(path: String) : Action[AnyContent] = Action { request =>
val result = gamePlugin.handle(request.path)
Ok(result)
}
}
|
Return 422 on invalid encoding for url/form encoded | package handlers
import javax.inject.{Inject, Singleton}
import controllers.ServerProxyDefinition
import io.apibuilder.validation.FormData
import lib.{ProxyRequest, ResolvedToken, Route}
import play.api.mvc.Result
import scala.concurrent.{ExecutionContext, Future}
/**
* Converts url form encodes into a JSON body, then
* delegates processing to the application json handler
*/
@Singleton
class UrlFormEncodedHandler @Inject() (
applicationJsonHandler: ApplicationJsonHandler
) extends Handler {
override def process(
definition: ServerProxyDefinition,
request: ProxyRequest,
route: Route,
token: ResolvedToken
)(
implicit ec: ExecutionContext
): Future[Result] = {
val newBody = FormData.parseEncodedToJsObject(
request.bodyUtf8.getOrElse {
// TODO: Return 422 on invalid content herek
sys.error(s"Request[${request.requestId}] Failed to serialize body as string for ContentType.UrlFormEncoded")
}
)
applicationJsonHandler.processJson(
definition,
request,
route,
token,
newBody
)
}
}
| package handlers
import javax.inject.{Inject, Singleton}
import controllers.ServerProxyDefinition
import io.apibuilder.validation.FormData
import lib.{ProxyRequest, ResolvedToken, Route}
import play.api.mvc.Result
import scala.concurrent.{ExecutionContext, Future}
/**
* Converts url form encodes into a JSON body, then
* delegates processing to the application json handler
*/
@Singleton
class UrlFormEncodedHandler @Inject() (
applicationJsonHandler: ApplicationJsonHandler
) extends Handler {
override def process(
definition: ServerProxyDefinition,
request: ProxyRequest,
route: Route,
token: ResolvedToken
)(
implicit ec: ExecutionContext
): Future[Result] = {
request.bodyUtf8 match {
case None => Future.successful(
request.responseUnprocessableEntity(
"Url form encoded requests must contain body encoded in ;UTF-8'"
)
)
case Some(body) => {
applicationJsonHandler.processJson(
definition,
request,
route,
token,
FormData.parseEncodedToJsObject(body)
)
}
}
}
}
|
Add type annotations on provider values | package providers
import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits._
import util.WithTiming._
import models.{LocationWithWeather, Location}
trait WeatherFetchStrategies {
this: Providers =>
def provider(name: String): Location => Future[LocationWithWeather] = { location =>
providers(name).getLocationWithWeather(location) withTiming
}
val smhi = provider("smhi")
val yr = provider("yr")
val firstCompleted: Location => Future[LocationWithWeather] = { location =>
val weatherF = providers.values.map(_.getLocationWithWeather(location) withTiming)
Future.firstCompletedOf(weatherF)
}
val withRecovery: Location => Future[LocationWithWeather] = { location =>
smhi(location).recoverWith {
case _ => yr(location)
}
}
val all: Location => Future[LocationWithWeather] = { location =>
Future.sequence(
providers.values
.map(f => f.getLocationWithWeather(location) withTiming))
.map(l => l.tail.fold[LocationWithWeather](l.head)(_ merge _)
)
}
}
| package providers
import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits._
import util.WithTiming._
import models.{LocationWithWeather, Location}
trait WeatherFetchStrategies {
this: Providers =>
def provider(name: String): Location => Future[LocationWithWeather] = { location =>
providers(name).getLocationWithWeather(location) withTiming
}
val smhi: (Location) => Future[LocationWithWeather] = provider("smhi")
val yr: (Location) => Future[LocationWithWeather] = provider("yr")
val firstCompleted: Location => Future[LocationWithWeather] = { location =>
yr(location)
??? //Todo add instructions
}
val withRecovery: Location => Future[LocationWithWeather] = { location =>
??? //Todo add instructions
}
val all: Location => Future[LocationWithWeather] = { location =>
??? //Todo add instructions
}
}
|
Update configuration to record version 0.1.9 | name := "lib-reference-scala"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.2" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
version := "0.1.8"
| name := "lib-reference-scala"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.2" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
version := "0.1.9"
|
Add `-release 11` for J11 compatibility | import org.nlogo.build.{ NetLogoExtension, ExtensionDocumentationPlugin }
enablePlugins(NetLogoExtension, ExtensionDocumentationPlugin)
version := "2.0.1"
isSnapshot := true
netLogoVersion := "6.2.2"
netLogoExtName := "palette"
netLogoClassManager := "PaletteExtension"
javaSource in Compile := baseDirectory.value / "src" / "main"
javacOptions ++= Seq("-g", "-Xlint:deprecation", "-Xlint:all", "-Xlint:-serial", "-Xlint:-path", "-encoding", "us-ascii")
scalaVersion := "2.12.12"
scalaSource in Test := baseDirectory.value / "src" / "test"
scalacOptions ++= Seq("-deprecation", "-unchecked", "-Xfatal-warnings", "-feature", "-encoding", "us-ascii")
| import org.nlogo.build.{ NetLogoExtension, ExtensionDocumentationPlugin }
enablePlugins(NetLogoExtension, ExtensionDocumentationPlugin)
version := "2.0.1"
isSnapshot := true
netLogoVersion := "6.2.2"
netLogoExtName := "palette"
netLogoClassManager := "PaletteExtension"
javaSource in Compile := baseDirectory.value / "src" / "main"
javacOptions ++= Seq("-g", "-Xlint:deprecation", "-Xlint:all", "-Xlint:-serial", "-Xlint:-path", "-encoding", "us-ascii", "--release", "11")
scalaVersion := "2.12.12"
scalaSource in Test := baseDirectory.value / "src" / "test"
scalacOptions ++= Seq("-deprecation", "-unchecked", "-Xfatal-warnings", "-feature", "-encoding", "us-ascii", "-release", "11")
|
Increment version from 0.0.29 => 0.0.30 | import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.7"
crossScalaVersions := Seq("2.11.7")
version := "0.0.29"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
"org.scalatest" %% "scalatest" % "2.2.6" % "test",
"org.scalatestplus" %% "play" % "1.4.0" % "test"
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.7"
crossScalaVersions := Seq("2.11.7")
version := "0.0.30"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
"org.scalatest" %% "scalatest" % "2.2.6" % "test",
"org.scalatestplus" %% "play" % "1.4.0" % "test"
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Fix error log messages. Throwable should be the first parameter. | package com.softwaremill.react.kafka
import akka.actor.ActorLogging
import akka.stream.actor.{ActorSubscriber, ActorSubscriberMessage, RequestStrategy}
import kafka.producer.KafkaProducer
private[kafka] class KafkaActorSubscriber[T](
val producer: KafkaProducer[T],
props: ProducerProperties[T],
requestStrategyProvider: () => RequestStrategy
)
extends ActorSubscriber with ActorLogging {
override protected val requestStrategy = requestStrategyProvider()
def receive = {
case ActorSubscriberMessage.OnNext(element) =>
processElement(element.asInstanceOf[T])
case ActorSubscriberMessage.OnError(ex) =>
handleError(ex)
case ActorSubscriberMessage.OnComplete =>
stop()
case "close_producer" => producer.close()
}
private def processElement(element: T) = {
producer.send(props.encoder.toBytes(element), props.partitionizer(element))
}
private def handleError(ex: Throwable) = {
log.error("Stopping Kafka subscriber due to fatal error.", ex)
stop()
}
def stop() = {
cleanupResources()
context.stop(self)
}
def cleanupResources(): Unit = producer.close()
} | package com.softwaremill.react.kafka
import akka.actor.ActorLogging
import akka.stream.actor.{ActorSubscriber, ActorSubscriberMessage, RequestStrategy}
import kafka.producer.KafkaProducer
private[kafka] class KafkaActorSubscriber[T](
val producer: KafkaProducer[T],
props: ProducerProperties[T],
requestStrategyProvider: () => RequestStrategy
)
extends ActorSubscriber with ActorLogging {
override protected val requestStrategy = requestStrategyProvider()
def receive = {
case ActorSubscriberMessage.OnNext(element) =>
processElement(element.asInstanceOf[T])
case ActorSubscriberMessage.OnError(ex) =>
handleError(ex)
case ActorSubscriberMessage.OnComplete =>
stop()
case "close_producer" => producer.close()
}
private def processElement(element: T) = {
producer.send(props.encoder.toBytes(element), props.partitionizer(element))
}
private def handleError(ex: Throwable) = {
log.error(ex, "Stopping Kafka subscriber due to fatal error.")
stop()
}
def stop() = {
cleanupResources()
context.stop(self)
}
def cleanupResources(): Unit = producer.close()
}
|
Update http4s-blaze-client, http4s-circe to 0.20.12 | scalacOptions := Seq(
"-deprecation"
)
// For MimeLoader plugin. Dogfooding and hoping it doesn't clash with
// our other sbt plugins.
libraryDependencies ++= List(
"com.eed3si9n" %% "treehugger" % "0.4.4",
"io.circe" %% "circe-generic" % "0.12.3",
"org.http4s" %% "http4s-blaze-client" % "0.20.11",
"org.http4s" %% "http4s-circe" % "0.20.11",
)
// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.2.4"
| scalacOptions := Seq(
"-deprecation"
)
// For MimeLoader plugin. Dogfooding and hoping it doesn't clash with
// our other sbt plugins.
libraryDependencies ++= List(
"com.eed3si9n" %% "treehugger" % "0.4.4",
"io.circe" %% "circe-generic" % "0.12.3",
"org.http4s" %% "http4s-blaze-client" % "0.20.12",
"org.http4s" %% "http4s-circe" % "0.20.12",
)
// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.2.4"
|
Migrate from Cloudbees repo to OSS | // Comment to get more information during initialization
logLevel := Level.Warn
//resolvers += "Local Repository" at "http://localhost:8090/publish"
// Enable it for Play 2.0.3
resolvers += "Typesafe releases" at "http://repo.typesafe.com/typesafe/releases"
resolvers += Resolver.file("Local Ivy Repository", file(Path.userHome.absolutePath+"/.ivy2/local"))(Resolver.ivyStylePatterns)
resolvers += Resolver.url("Play2war plugin snapshot", url("http://repository-play-war.forge.cloudbees.com/snapshot/"))(Resolver.ivyStylePatterns)
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.1-RC2"))
//addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")
addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "0.9-SNAPSHOT")
| // Comment to get more information during initialization
logLevel := Level.Warn
//resolvers += "Local Repository" at "http://localhost:8090/publish"
// Enable it for Play 2.0.3
resolvers += "Typesafe releases" at "http://repo.typesafe.com/typesafe/releases"
resolvers += Resolver.file("Local Ivy Repository", file(Path.userHome.absolutePath+"/.ivy2/local"))(Resolver.ivyStylePatterns)
resolvers += Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.1-RC2"))
//addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")
addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "0.9-SNAPSHOT")
|
Rename domain of Spray Repo | resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Spray Repository" at "http://repo.spray.cc/"
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.2")
addSbtPlugin("com.github.gseitz" % "sbt-protobuf" % "0.3.3")
| resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Spray Repository" at "http://repo.spray.io/"
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.2")
addSbtPlugin("com.github.gseitz" % "sbt-protobuf" % "0.3.3")
|
Make main() load a simple REPL for playing with the parser | package org.moe
object Moe {
def main (args: Array[String]): Unit = {
println("Hello World")
}
} | package org.moe
import org.moe.ast._
import org.moe.parser._
import org.moe.interpreter._
import org.moe.runtime._
object Moe {
object REPL {
def evalLine(line: String) = {
try {
val nodes = List(MoeParsers.parseFromEntry(line))
val ast = CompilationUnitNode(
ScopeNode(
StatementsNode(nodes)
)
)
val result = Interpreter.eval(Runtime.getRootEnv, ast)
println(result.toString)
}
catch {
case e: Exception => System.err.println(e)
}
}
}
def main (args: Array[String]): Unit = {
var ok = true
print("> ")
while (ok) {
val line = readLine()
ok = line != null
if (ok) {
REPL.evalLine(line)
print("> ")
}
}
}
}
|
Put that module in the right namespace | package uk.ac.wellcome.finatra.modules
import javax.inject.Singleton
import com.google.inject.Provides
import com.twitter.inject.TwitterModule
import uk.ac.wellcome.models.aws.DynamoConfig
object DynamoConfigModule extends TwitterModule {
private val tableName =
flag[String]("aws.dynamo.tableName", "", "Name of the DynamoDB table")
@Singleton
@Provides
def providesDynamoConfig(): DynamoConfig =
DynamoConfig(table = tableName())
}
| package uk.ac.wellcome.storage.dynamo
import javax.inject.Singleton
import com.google.inject.Provides
import com.twitter.inject.TwitterModule
import uk.ac.wellcome.models.aws.DynamoConfig
object DynamoConfigModule extends TwitterModule {
private val tableName =
flag[String]("aws.dynamo.tableName", "", "Name of the DynamoDB table")
@Singleton
@Provides
def providesDynamoConfig(): DynamoConfig =
DynamoConfig(table = tableName())
}
|
Read unsafe from char array | package bloomfilter
trait CanGetDataFrom[-From] {
def getLong(from: From, offset: Int): Long
def getByte(from: From, offset: Int): Byte
}
object CanGetDataFrom {
implicit object CanGetDataFromByteArray extends CanGetDataFrom[Array[Byte]] {
override def getLong(buf: Array[Byte], offset: Int): Long = {
(buf(offset + 7).toLong << 56) |
((buf(offset + 6) & 0xffL) << 48) |
((buf(offset + 5) & 0xffL) << 40) |
((buf(offset + 4) & 0xffL) << 32) |
((buf(offset + 3) & 0xffL) << 24) |
((buf(offset + 2) & 0xffL) << 16) |
((buf(offset + 1) & 0xffL) << 8) |
buf(offset) & 0xffL
}
override def getByte(from: Array[Byte], offset: Int): Byte = {
from(offset)
}
}
}
| package bloomfilter
import com.github.ghik.silencer.silent
import scala.concurrent.util.Unsafe.{instance => unsafe}
trait CanGetDataFrom[-From] {
def getLong(from: From, offset: Int): Long
def getByte(from: From, offset: Int): Byte
}
object CanGetDataFrom {
implicit object CanGetDataFromByteArray extends CanGetDataFrom[Array[Byte]] {
override def getLong(buf: Array[Byte], offset: Int): Long = {
(buf(offset + 7).toLong << 56) |
((buf(offset + 6) & 0xffL) << 48) |
((buf(offset + 5) & 0xffL) << 40) |
((buf(offset + 4) & 0xffL) << 32) |
((buf(offset + 3) & 0xffL) << 24) |
((buf(offset + 2) & 0xffL) << 16) |
((buf(offset + 1) & 0xffL) << 8) |
buf(offset) & 0xffL
}
override def getByte(from: Array[Byte], offset: Int): Byte = {
from(offset)
}
}
@silent
implicit object CanGetDataFromArrayChar extends CanGetDataFrom[Array[Char]] {
override def getLong(from: Array[Char], offset: Int): Long = {
unsafe.getLong(from, offset)
}
override def getByte(from: Array[Char], offset: Int): Byte = {
unsafe.getByte(from, offset)
}
}
}
|
Add unit test to ensure the worker actor is stopped. | package com.mindcandy.waterfall.actor
import org.specs2.specification.After
import akka.testkit.TestKit
import org.specs2.time.NoTimeConversions
import akka.actor.ActorSystem
import org.specs2.SpecificationLike
import akka.testkit.TestProbe
import akka.actor.ActorRef
import akka.actor.Props
import scala.util.Success
import com.mindcandy.waterfall.actor.DropWorker.RunDrop
import com.mindcandy.waterfall.actor.DropSupervisor.JobResult
class DropWorkerSpec extends TestKit(ActorSystem("DropWorkerSpec")) with SpecificationLike with After with NoTimeConversions {
override def is = s2"""
DropWorker should
run a drop and return success $runDrop
"""
override def after: Any = TestKit.shutdownActorSystem(system)
def runDrop = {
val dropUID = "test1"
val probe: TestProbe = TestProbe()
val actor: ActorRef = system.actorOf(DropWorker.props)
val request = RunDrop(dropUID, TestWaterfallDropFactory.getDropByUID(dropUID).get)
probe.send(actor, request)
probe.expectMsgClass(classOf[JobResult]).result must_== Success()
}
} | package com.mindcandy.waterfall.actor
import org.specs2.specification.After
import akka.testkit.TestKit
import org.specs2.time.NoTimeConversions
import akka.actor.{Terminated, ActorSystem, ActorRef, Props}
import org.specs2.SpecificationLike
import akka.testkit.TestProbe
import scala.util.Success
import com.mindcandy.waterfall.actor.DropWorker.RunDrop
import com.mindcandy.waterfall.actor.DropSupervisor.JobResult
import scala.concurrent.duration._
class DropWorkerSpec extends TestKit(ActorSystem("DropWorkerSpec")) with SpecificationLike with After with NoTimeConversions {
override def is = s2"""
DropWorker should
run a drop and return success $runDrop
stop after running a job $stopActor
"""
override def after: Any = TestKit.shutdownActorSystem(system)
def runDrop = {
val dropUID = "test1"
val probe: TestProbe = TestProbe()
val actor: ActorRef = system.actorOf(DropWorker.props)
val request = RunDrop(dropUID, TestWaterfallDropFactory.getDropByUID(dropUID).get)
probe.send(actor, request)
probe.expectMsgClass(classOf[JobResult]).result must_== Success()
}
def stopActor = {
val dropUID = "test1"
val probe: TestProbe = TestProbe()
val actor: ActorRef = system.actorOf(DropWorker.props)
val request = RunDrop(dropUID, TestWaterfallDropFactory.getDropByUID(dropUID).get)
probe.watch(actor)
probe.send(actor, request)
probe.expectMsgClass(classOf[JobResult])
probe.expectTerminated(actor, FiniteDuration(5, SECONDS)) match {
case Terminated(actor) => success
case _ => failure
}
}
} |
Increment version from 0.0.28 => 0.0.29 | import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.7"
crossScalaVersions := Seq("2.11.7")
version := "0.0.28"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
"org.scalatest" %% "scalatest" % "2.2.6" % "test"
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.7"
crossScalaVersions := Seq("2.11.7")
version := "0.0.29"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
"org.scalatest" %% "scalatest" % "2.2.6" % "test"
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Add some pimps for files | package object nimrod {
implicit def stringPimps(s : String) = new {
def %(args : AnyRef*) = String.format(s,args:_*)
def ls = new java.io.File(s).list()
}
def set(key : String, value : String) {
System.setProperty(key,value)
}
def get(key : String) = System.getProperty(key)
}
| import java.io.File
package object nimrod {
implicit def stringPimps(s : String) = new {
def %(args : AnyRef*) = String.format(s,args:_*)
def ls = new java.io.File(s).list()
}
implicit def filePimps(f : File) = new {
def ls = f.list()
def path = f.getCanonicalPath()
}
def set(key : String, value : String) {
System.setProperty(key,value)
}
def get(key : String) = System.getProperty(key)
}
|
Test multiplex client with failed server upgrades | package com.twitter.finagle.http
import com.twitter.finagle
import com.twitter.finagle.Service
import com.twitter.finagle.liveness.FailureDetector
import com.twitter.util.Future
/**
* This is really a HTTP/1.x test suite because the server only speaks HTTP/1.x
*/
class ClientFailHttp2UpgradeTest extends AbstractHttp1EndToEndTest {
def implName: String = "http/2 client, http/1.1 server"
def clientImpl(): finagle.Http.Client =
finagle.Http.client.withHttp2.configured(FailureDetector.Param(FailureDetector.NullConfig))
def serverImpl(): finagle.Http.Server = finagle.Http.server
def featureImplemented(feature: Feature): Boolean = feature != NoBodyMessage
test("Upgrade counters are not incremented") {
val client = nonStreamingConnect(Service.mk { _: Request =>
Future.value(Response())
})
await(client(Request("/")))
assert(!statsRecv.counters.contains(Seq("server", "upgrade", "success")))
assert(statsRecv.counters(Seq("client", "upgrade", "success")) == 0)
await(client.close())
}
}
| package com.twitter.finagle.http
import com.twitter.finagle
import com.twitter.finagle.{Http, Service}
import com.twitter.finagle.liveness.FailureDetector
import com.twitter.util.Future
/**
* This is really a HTTP/1.x test suite because the server only speaks HTTP/1.x
*/
abstract class ClientFailHttp2UpgradeTest extends AbstractHttp1EndToEndTest {
def isMultiplexCodec: Boolean
def implName: String = {
val base = if (isMultiplexCodec) "multiplex" else "classic"
base + " http/2 client, http/1.1 server"
}
def clientImpl(): finagle.Http.Client =
finagle.Http.client.withHttp2
.configured(FailureDetector.Param(FailureDetector.NullConfig))
.configured(Http.H2ClientImpl(Some(isMultiplexCodec)))
def serverImpl(): finagle.Http.Server = finagle.Http.server
def featureImplemented(feature: Feature): Boolean = feature != NoBodyMessage
test("Upgrade counters are not incremented") {
val client = nonStreamingConnect(Service.mk { _: Request =>
Future.value(Response())
})
await(client(Request("/")))
assert(!statsRecv.counters.contains(Seq("server", "upgrade", "success")))
assert(statsRecv.counters(Seq("client", "upgrade", "success")) == 0)
await(client.close())
}
}
class ClassicClientFailHttp2UpgradeTest extends ClientFailHttp2UpgradeTest {
def isMultiplexCodec: Boolean = false
}
class MultiplexClientFailHttp2UpgradeTest extends ClientFailHttp2UpgradeTest {
def isMultiplexCodec: Boolean = true
}
|
Update configuration to record version 0.0.88 | import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.87"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.8",
"com.ning" % "async-http-client" % "1.9.39",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-build"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.88"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.8",
"com.ning" % "async-http-client" % "1.9.39",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Support non-ISO8859-1 filename in Content-Disposition header | package protocols
import akka.NotUsed
import akka.stream.scaladsl.Source
import models.cfs.Block._
import play.api.http._
import play.api.libs.MimeTypes
import play.api.mvc._
import play.utils.UriEncoding
/**
* @author zepeng.li@gmail.com
*/
trait HttpDownloadable {
def size: Long
def name: String
def whole: Source[BLK, NotUsed]
}
trait HttpDownloadResult extends HeaderNames with Status {
def send(
file: HttpDownloadable,
name: HttpDownloadable => String = _.name,
inline: Boolean = false
): Result = {
val result = Result(
ResponseHeader(OK),
HttpEntity.Streamed(
file.whole,
Some(file.size),
contentTypeOf(file)
)
)
if (inline) result
else {
val encoded = UriEncoding.encodePathSegment(name(file), "utf-8")
result.withHeaders(
CONTENT_DISPOSITION -> s"""attachment; filename="$encoded" """
)
}
}
def contentTypeOf(inode: HttpDownloadable): Option[String] = {
MimeTypes.forFileName(inode.name).orElse(Some(ContentTypes.BINARY))
}
}
object HttpDownloadResult extends HttpDownloadResult | package protocols
import java.nio.charset.StandardCharsets
import akka.NotUsed
import akka.stream.scaladsl.Source
import models.cfs.Block._
import play.api.http._
import play.api.libs.MimeTypes
import play.api.mvc._
import play.utils.UriEncoding
/**
* @author zepeng.li@gmail.com
*/
trait HttpDownloadable {
def size: Long
def name: String
def whole: Source[BLK, NotUsed]
}
trait HttpDownloadResult extends HeaderNames with Status {
def send(
file: HttpDownloadable,
name: HttpDownloadable => String = _.name,
inline: Boolean = false
): Result = {
val result = Result(
ResponseHeader(OK),
HttpEntity.Streamed(
file.whole,
Some(file.size),
contentTypeOf(file)
)
)
val encoded = UriEncoding.encodePathSegment(name(file), StandardCharsets.UTF_8)
result.withHeaders(
CONTENT_DISPOSITION -> {
val dispositionType = if (inline) "inline" else "attachment"
s"""$dispositionType; filename="$name"; filename*=utf-8''$encoded"""
}
)
}
def contentTypeOf(inode: HttpDownloadable): Option[String] = {
MimeTypes.forFileName(inode.name).orElse(Some(ContentTypes.BINARY))
}
}
object HttpDownloadResult extends HttpDownloadResult |
Update mdoc, sbt-mdoc to 2.2.12 | addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.8.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.4")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.11" )
| addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.8.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.4")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.12" )
|
Handle stackoverflows when trying to print the maximal constraint | package dotty.tools.dotc
package core
import Contexts._
import config.Printers.{default, typr}
trait ConstraintRunInfo { self: Run =>
private var maxSize = 0
private var maxConstraint: Constraint | Null = _
def recordConstraintSize(c: Constraint, size: Int): Unit =
if (size > maxSize) {
maxSize = size
maxConstraint = c
}
def printMaxConstraint()(using Context): Unit =
val printer = if (ctx.settings.YdetailedStats.value) default else typr
if maxSize > 0 then
printer.println(s"max constraint = ${maxConstraint.nn.show}\nsize = $maxSize")
protected def reset(): Unit = maxConstraint = null
}
| package dotty.tools.dotc
package core
import Contexts._
import config.Printers.{default, typr}
trait ConstraintRunInfo { self: Run =>
private var maxSize = 0
private var maxConstraint: Constraint | Null = _
def recordConstraintSize(c: Constraint, size: Int): Unit =
if (size > maxSize) {
maxSize = size
maxConstraint = c
}
def printMaxConstraint()(using Context): Unit =
if maxSize > 0 then
val printer = if ctx.settings.YdetailedStats.value then default else typr
printer.println(s"max constraint size: $maxSize")
try printer.println(s"max constraint = ${maxConstraint.nn.show}")
catch case ex: StackOverflowError => printer.println("max constraint cannot be printed due to stack overflow")
protected def reset(): Unit = maxConstraint = null
}
|
Set project version to 0.0.7-BETA | import sbt._
import sbt.Keys._
import android.Keys._
import android.Plugin._
object Build extends android.AutoBuild
{
lazy val main = Project( "toolbelt", file( "." ) )
.settings( buildAar: _* )
.settings(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.android.support" % "support-v4" % "20.0.0",
"com.github.japgolly.android" % "svg-android" % "2.0.6"
),
name := "Toolbelt",
organization := "com.taig.android",
scalaVersion := "2.11.2",
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-language:dynamics",
"-language:implicitConversions",
"-language:reflectiveCalls"
),
version := "0.0.6-BETA",
libraryProject in Android := true,
minSdkVersion in Android := "10",
targetSdkVersion in Android := "19"
)
} | import sbt._
import sbt.Keys._
import android.Keys._
import android.Plugin._
object Build extends android.AutoBuild
{
lazy val main = Project( "toolbelt", file( "." ) )
.settings( buildAar: _* )
.settings(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.android.support" % "support-v4" % "20.0.0",
"com.github.japgolly.android" % "svg-android" % "2.0.6"
),
name := "Toolbelt",
organization := "com.taig.android",
scalaVersion := "2.11.2",
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-language:dynamics",
"-language:implicitConversions",
"-language:reflectiveCalls"
),
version := "0.0.7-BETA",
libraryProject in Android := true,
minSdkVersion in Android := "10",
targetSdkVersion in Android := "19"
)
} |
Update sbt-scalajs, scalajs-compiler, ... to 1.10.1 | addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
addSbtPlugin("ohnosequences" % "sbt-github-release" % "0.7.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
// https://github.com/ohnosequences/sbt-github-release/issues/28#issuecomment-426086656
libraryDependencies += "com.sun.activation" % "javax.activation" % "1.2.0"
| addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
addSbtPlugin("ohnosequences" % "sbt-github-release" % "0.7.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
// https://github.com/ohnosequences/sbt-github-release/issues/28#issuecomment-426086656
libraryDependencies += "com.sun.activation" % "javax.activation" % "1.2.0"
|
Use nio collectors to safely close stream. | package scala.meta.internal.io
import java.net.URI
import java.nio.charset.Charset
import java.nio.file.FileVisitOption
import scala.meta.io._
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.SimpleFileVisitor
object PlatformFileIO {
def readAllBytes(uri: URI): Array[Byte] =
InputStreamIO.readBytes(uri.toURL.openStream())
def readAllBytes(path: AbsolutePath): Array[Byte] =
Files.readAllBytes(path.toNIO)
def slurp(path: AbsolutePath, charset: Charset): String =
scala.io.Source.fromFile(path.toFile)(scala.io.Codec(charset)).mkString
def listFiles(path: AbsolutePath): ListFiles =
new ListFiles(path, Option(path.toFile.list()).toList.flatten.map(RelativePath.apply))
def isFile(path: AbsolutePath): Boolean =
Files.isRegularFile(path.path)
def isDirectory(path: AbsolutePath): Boolean =
Files.isDirectory(path.path)
def listAllFilesRecursively(root: AbsolutePath): ListFiles = {
import scala.collection.JavaConverters._
val relativeFiles = Files
.walk(root.toNIO)
.iterator()
.asScala
.collect {
case path if Files.isRegularFile(path) =>
RelativePath(root.path.relativize(path))
}
.toSeq
new ListFiles(root, relativeFiles)
}
}
| package scala.meta.internal.io
import java.net.URI
import java.nio.charset.Charset
import java.nio.file.FileVisitOption
import scala.meta.io._
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.SimpleFileVisitor
import java.util.stream.Collectors
object PlatformFileIO {
def readAllBytes(uri: URI): Array[Byte] =
InputStreamIO.readBytes(uri.toURL.openStream())
def readAllBytes(path: AbsolutePath): Array[Byte] =
Files.readAllBytes(path.toNIO)
def slurp(path: AbsolutePath, charset: Charset): String =
scala.io.Source.fromFile(path.toFile)(scala.io.Codec(charset)).mkString
def listFiles(path: AbsolutePath): ListFiles =
new ListFiles(path, Option(path.toFile.list()).toList.flatten.map(RelativePath.apply))
def isFile(path: AbsolutePath): Boolean =
Files.isRegularFile(path.path)
def isDirectory(path: AbsolutePath): Boolean =
Files.isDirectory(path.path)
def listAllFilesRecursively(root: AbsolutePath): ListFiles = {
import scala.collection.JavaConverters._
val relativeFiles = Files
.walk(root.toNIO)
.collect(Collectors.toList[Path])
.asScala
.collect {
case path if Files.isRegularFile(path) =>
RelativePath(root.path.relativize(path))
}
new ListFiles(root, relativeFiles)
}
}
|
Upgrade sbt-scoverage plugin to version 1.6.1 | // Comment to get more information during initialization
logLevel := Level.Warn
// https://github.com/scoverage/sbt-scoverage/releases
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
// https://github.com/scoverage/sbt-coveralls/releases
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
// https://github.com/codacy/sbt-codacy-coverage/releases
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.15")
// https://github.com/scalameta/scalafmt
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0")
| // Comment to get more information during initialization
logLevel := Level.Warn
// https://github.com/scoverage/sbt-scoverage/releases
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
// https://github.com/scoverage/sbt-coveralls/releases
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
// https://github.com/codacy/sbt-codacy-coverage/releases
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.15")
// https://github.com/scalameta/scalafmt
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0")
|
Sort and add cjwelborn and welbornprod to the list | package io.github.bamos
object Whitelist {
val users = Seq(
"adius",
"adobe-research",
"ajn123",
"bamos",
"bryangarza",
"cmusatyalab",
"darksigma",
"docker",
"jebes",
"HackathonHackers",
"hamiltont",
"ObeliskIsHuge",
"rhema",
"snowplow",
"tejasmanohar",
"themattman",
"VT-Magnum-Research",
"WalnutiQ",
"zmughal",
"geotrellis",
"twitter",
"github",
"facebook",
"etsy",
"square",
"amplab",
"fnothaft",
"bigdatagenomics",
"homebrew",
"puppetlabs",
"rails",
"google",
"okfn",
"humblesoftware",
"ecomfe",
"mozilla",
"spine",
"jez",
"haskell",
"coreos",
"scotty-web",
"vishnuravi",
"cimpress-mcp",
"creativecommons",
"cc-archive"
).map(_.toLowerCase)
}
| package io.github.bamos
object Whitelist {
val users = Seq(
"HackathonHackers",
"ObeliskIsHuge",
"VT-Magnum-Research",
"WalnutiQ",
"adius",
"adobe-research",
"ajn123",
"amplab",
"bamos",
"bigdatagenomics",
"bryangarza",
"cc-archive",
"cimpress-mcp",
"cjwelborn",
"cmusatyalab",
"coreos",
"creativecommons",
"darksigma",
"docker",
"ecomfe",
"etsy",
"facebook",
"fnothaft",
"geotrellis",
"github",
"google",
"hamiltont",
"haskell",
"homebrew",
"humblesoftware",
"jebes",
"jez",
"mozilla",
"okfn",
"puppetlabs",
"rails",
"rhema",
"scotty-web",
"snowplow",
"spine",
"square",
"tejasmanohar",
"themattman",
"twitter",
"vishnuravi",
"welbornprod",
"zmughal"
).map(_.toLowerCase)
}
|
Update configuration to record version 0.4.6 | import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.11"
crossScalaVersions := Seq("2.11.11")
version := "0.4.5"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
filters,
"com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
"org.scalatestplus" %% "play" % "1.4.0" % "test"
),
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
credentials += Credentials(
"Artifactory Realm",
"flow.artifactoryonline.com",
System.getenv("ARTIFACTORY_USERNAME"),
System.getenv("ARTIFACTORY_PASSWORD")
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import play.PlayImport.PlayKeys._
name := "lib-play"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.11"
crossScalaVersions := Seq("2.11.11")
version := "0.4.6"
lazy val root = project
.in(file("."))
.enablePlugins(PlayScala)
.settings(
libraryDependencies ++= Seq(
ws,
filters,
"com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
"org.scalatestplus" %% "play" % "1.4.0" % "test"
),
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
credentials += Credentials(
"Artifactory Realm",
"flow.artifactoryonline.com",
System.getenv("ARTIFACTORY_USERNAME"),
System.getenv("ARTIFACTORY_PASSWORD")
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Build now inlcludes resources in classpath | name := "DissolveStructExample"
organization := "ch.ethz.dalab"
version := "0.1-SNAPSHOT"
scalaVersion := "2.10.4"
libraryDependencies += "ch.ethz.dalab" %% "dissolvestruct" % "0.1-SNAPSHOT"
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.3.0"
libraryDependencies += "org.apache.spark" %% "spark-mllib" % "1.3.0"
resolvers += "IESL Release" at "http://dev-iesl.cs.umass.edu/nexus/content/groups/public"
libraryDependencies += "cc.factorie" % "factorie" % "1.0"
libraryDependencies += "com.github.scopt" %% "scopt" % "3.3.0"
resolvers += Resolver.sonatypeRepo("public")
test in assembly := {}
| name := "DissolveStructExample"
organization := "ch.ethz.dalab"
version := "0.1-SNAPSHOT"
scalaVersion := "2.10.4"
libraryDependencies += "ch.ethz.dalab" %% "dissolvestruct" % "0.1-SNAPSHOT"
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.3.0"
libraryDependencies += "org.apache.spark" %% "spark-mllib" % "1.3.0"
resolvers += "IESL Release" at "http://dev-iesl.cs.umass.edu/nexus/content/groups/public"
libraryDependencies += "cc.factorie" % "factorie" % "1.0"
libraryDependencies += "com.github.scopt" %% "scopt" % "3.3.0"
resolvers += Resolver.sonatypeRepo("public")
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Resource
test in assembly := {}
|
Update sbt-scalajs, scalajs-compiler, ... to 1.10.1 | scalacOptions += "-deprecation"
libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.7.36"
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")
| scalacOptions += "-deprecation"
libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.7.36"
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")
|
Upgrade deps to support Scala 2.12.0 | package llsm
import sbt._
import sbtcatalysts.CatalystsPlugin.autoImport._
object Dependencies {
// Versions for libraries and packages
// Package -> version
val versions = Map[String, String](
"scalac" -> "2.11.8",
"cats" -> "0.8.0",
"kind-projector" -> "0.9.2",
"iteratee" -> "0.7.0",
"scalacheck" -> "1.13.3",
"scalatest" -> "3.0.0"
)
// library definitions and links to their versions
// Note that one version may apply to more than one library.
// Library name -> version key, org, library
val libraries = Map[String, (String, String, String)](
"iteratee-core" -> ("iteratee", "io.iteratee", "iteratee-core"),
"iteratee-files" -> ("iteratee", "io.iteratee", "iteratee-files")
)
// compiler plugins definitions and links to their versions
// Note that one version may apply to more than one plugin.
// Library name -> version key, org, librar, crossVersion
val scalacPlugins = Map[String, (String, String, String, CrossVersion)](
)
// Some helper methods to combine libraries
}
| package llsm
import sbt._
import sbtcatalysts.CatalystsPlugin.autoImport._
object Dependencies {
// Versions for libraries and packages
// Package -> version
val versions = Map[String, String](
"scalac" -> "2.11.8",
"cats" -> "0.8.1",
"kind-projector" -> "0.9.3",
"iteratee" -> "0.7.1",
"scalacheck" -> "1.13.4",
"scalatest" -> "3.0.1"
)
// library definitions and links to their versions
// Note that one version may apply to more than one library.
// Library name -> version key, org, library
val libraries = Map[String, (String, String, String)](
"iteratee-core" -> ("iteratee", "io.iteratee", "iteratee-core"),
"iteratee-files" -> ("iteratee", "io.iteratee", "iteratee-files")
)
// compiler plugins definitions and links to their versions
// Note that one version may apply to more than one plugin.
// Library name -> version key, org, librar, crossVersion
val scalacPlugins = Map[String, (String, String, String, CrossVersion)](
)
// Some helper methods to combine libraries
}
|
Update fs2-core, fs2-io to 1.0.4 | package quasar.project
object Versions {
val algebraVersion = "1.0.1"
val argonautVersion = "6.2.3"
val catsEffectVersion = "1.3.0"
val disciplineVersion = "0.7.2"
val jawnVersion = "0.14.2"
val jawnfs2Version = "0.14.2"
val matryoshkaVersion = "0.18.3"
val monocleVersion = "1.5.0"
val pathyVersion = "0.2.13"
val refinedVersion = "0.9.5"
val scodecBitsVersion = "1.1.2"
val scalacheckVersion = "1.14.0"
val scalazVersion = "7.2.27"
val scalazStreamVersion = "0.8.6a"
val scoptVersion = "3.7.1"
val shapelessVersion = "2.3.3"
val simulacrumVersion = "0.16.0"
val specsVersion = "4.3.6"
val spireVersion = "0.16.1"
val akkaVersion = "2.5.1"
val fs2Version = "1.0.2"
val slf4sVersion = "1.7.25"
}
| package quasar.project
object Versions {
val algebraVersion = "1.0.1"
val argonautVersion = "6.2.3"
val catsEffectVersion = "1.3.0"
val disciplineVersion = "0.7.2"
val jawnVersion = "0.14.2"
val jawnfs2Version = "0.14.2"
val matryoshkaVersion = "0.18.3"
val monocleVersion = "1.5.0"
val pathyVersion = "0.2.13"
val refinedVersion = "0.9.5"
val scodecBitsVersion = "1.1.2"
val scalacheckVersion = "1.14.0"
val scalazVersion = "7.2.27"
val scalazStreamVersion = "0.8.6a"
val scoptVersion = "3.7.1"
val shapelessVersion = "2.3.3"
val simulacrumVersion = "0.16.0"
val specsVersion = "4.3.6"
val spireVersion = "0.16.1"
val akkaVersion = "2.5.1"
val fs2Version = "1.0.4"
val slf4sVersion = "1.7.25"
}
|
Add test for the division by zero error | package lila.openingexplorer
import org.specs2.mutable._
import chess.Color
class EntryTest extends Specification {
"entries" should {
"not contain low rated games" in {
val patzerGame = new GameRef("patzer00", Some(Color.White), SpeedGroup.Classical, 456)
Entry.empty.withGameRef(patzerGame) mustEqual Entry.empty
}
"count total games" in {
val g1 = new GameRef("g0000001", Some(Color.Black), SpeedGroup.Bullet, 2001)
val g2 = new GameRef("g0000002", None, SpeedGroup.Bullet, 2002)
Entry.empty.totalGames mustEqual 0
Entry.fromGameRef(g1).totalGames mustEqual 1
Entry.fromGameRef(g1).withGameRef(g2).totalGames mustEqual 2
}
}
}
| package lila.openingexplorer
import org.specs2.mutable._
import chess.Color
class EntryTest extends Specification {
"entries" should {
"not contain low rated games" in {
val patzerGame = new GameRef("patzer00", Some(Color.White), SpeedGroup.Classical, 456)
Entry.empty.withGameRef(patzerGame) mustEqual Entry.empty
}
"count total games" in {
val g1 = new GameRef("g0000001", Some(Color.Black), SpeedGroup.Bullet, 2001)
val g2 = new GameRef("g0000002", None, SpeedGroup.Bullet, 2002)
Entry.empty.totalGames mustEqual 0
Entry.fromGameRef(g1).totalGames mustEqual 1
Entry.fromGameRef(g1).withGameRef(g2).totalGames mustEqual 2
}
"show an average rating 0 if empty" in {
Entry.empty.averageRating(Entry.allGroups) mustEqual 0
}
}
}
|
Update configuration to record version 0.0.34 | import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-lint"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.33"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.2",
"com.ning" % "async-http-client" % "1.9.38",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
| import com.github.retronym.SbtOneJar._
oneJarSettings
name := "api-lint"
organization := "io.flow"
scalaVersion in ThisBuild := "2.11.8"
version := "0.0.34"
exportJars := true
lazy val root = project
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.5.2",
"com.ning" % "async-http-client" % "1.9.38",
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
publishTo := {
val host = "https://flow.artifactoryonline.com/flow"
if (isSnapshot.value) {
Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
} else {
Some("Artifactory Realm" at s"$host/libs-release-local")
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.