package ch.usi.inf.l3.sana.ooj.eval

import ch.usi.inf.l3.sana
import sana.tiny.symbols.Symbol
import sana.tiny.ast.Expr
import sana.calcj.ast.LiteralApi

trait Value
case class ExprValue(value: Expr) extends Value
case class LiteralValue(value: LiteralApi) extends Value

trait Env {
  protected val bindings: Map[Symbol, Value]

  def bind(symbol: Symbol, value: Value): Env = {
    val newBindings = bindings + (symbol -> value)
    create(newBindings)
  }

  protected def defines(symbol: Symbol): Boolean =
    bindings.contains(symbol)

  def getValue(symbol: Symbol): Option[Value] =
    bindings.get(symbol)

  def unbind(symbol: Symbol): Env = {
    val newBindings = bindings - symbol
    create(newBindings)
  }

  protected def create(bindings: Map[Symbol, Value]): Env
}

object Env {
  private class EnvImpl(
      protected val bindings: Map[Symbol, Value]) extends Env {
    protected def create(bindings: Map[Symbol, Value]): Env =
      new EnvImpl(bindings)
  }

  def apply(bindings: Map[Symbol, Value]): Env =
    new EnvImpl(bindings)

  def emptyEnv: Env =
    apply(Map.empty)
}

package ch.usi.inf.l3.sana.ooj.eval

import ch.usi.inf.l3.sana
import sana.tiny.symbols.Symbol
import sana.tiny.ast.Expr
import sana.calcj.ast.LiteralApi

trait Value
case class ExprValue(value: Expr) extends Value
case class LiteralValue(value: LiteralApi) extends Value

trait Env {
  protected val bindings: Map[Symbol, Value]

  def bind(symbol: Symbol, value: Value): Env = {
    val newBindings = bindings + (symbol -> value)
    create(newBindings)
  }

  protected def defines(symbol: Symbol): Boolean =
    bindings.contains(symbol)

  def getValue(symbol: Symbol): Option[Value] =
    bindings.get(symbol)

  def unbind(symbol: Symbol): Env = {
    val newBindings = bindings - symbol
    create(newBindings)
  }

  protected def create(bindings: Map[Symbol, Value]): Env

  override def hashCode: Int = bindings.hashCode
  override def equals(other: Any): Boolean = other match {
    case null      =>
      false
    case that: Env =>
      bindings == that.bindings
    case _         =>
      false
  }
}

object Env {
  private class EnvImpl(
      protected val bindings: Map[Symbol, Value]) extends Env {
    protected def create(bindings: Map[Symbol, Value]): Env =
      new EnvImpl(bindings)
  }

  def apply(bindings: Map[Symbol, Value]): Env =
    new EnvImpl(bindings)

  def emptyEnv: Env =
    apply(Map.empty)
}

Implement hashCode and equals for Env

Implement hashCode and equals for Env


package nimrod.util

import org.mapdb.DB
import scala.collection.JavaConversions._
import java.lang.Integer

/**
 * An implementation of a counter that is disk-based and increments (and is thread-safe)
 */
class DiskCounter[A](sorted : Boolean = false, db : DB = DiskCounter.createDB()) {
  private val theMap = if(sorted) {
    db.getTreeMap[A,Integer]("map")
  } else {
    db.getHashMap[A,Integer]("map")
  }

  def inc(key : A) = {
    // First check if there is a value by trying to put 1
    var v = theMap.putIfAbsent(key,1)
    if(v != null) {
      // Guess there was, let's try to increment this value
      while(!theMap.replace(key,v,v+1)) {
        // Nope, changed again, reread the map
        v = theMap.get(key)
      }
    }
  }
  def get(key : A) : Int = theMap.get(key).intValue
  def values : Iterator[(A,Int)] = theMap.iterator.map {
    case (x,y) => (x,y.intValue)
  }
}

object DiskCounter {
  def createDB(cacheSize : Int = 65536) = org.mapdb.DBMaker.newTempFileDB().cacheSize(cacheSize).make()
  def closeDB(db : DB) = db.close
}

package nimrod.util

import org.mapdb.DB
import scala.collection.JavaConversions._
import java.lang.Integer

/**
 * An implementation of a counter that is disk-based and increments (and is thread-safe)
 */
class DiskCounter[A](sorted : Boolean = false, db : DB = DiskCounter.createDB()) {
  private val name = math.abs(math.random * 1000000000).toString
  private val theMap = if(sorted) {
    db.getTreeMap[A,Integer](name)
  } else {
    db.getHashMap[A,Integer](name)
  }

  def inc(key : A) = {
    // First check if there is a value by trying to put 1
    var v = theMap.putIfAbsent(key,1)
    if(v != null) {
      // Guess there was, let's try to increment this value
      while(!theMap.replace(key,v,v+1)) {
        // Nope, changed again, reread the map
        v = theMap.get(key)
      }
    }
  }
  def get(key : A) : Int = theMap.get(key).intValue
  def values : Iterator[(A,Int)] = theMap.iterator.map {
    case (x,y) => (x,y.intValue)
  }
}

object DiskCounter {
  def createDB(cacheSize : Int = 65536) = org.mapdb.DBMaker.newTempFileDB().cacheSize(cacheSize).make()
  def closeDB(db : DB) = db.close
}

Fix bug in disk counter

Fix bug in disk counter


import slick.jdbc.PostgresProfile.api._
import com.liyaos.forklift.slick.SqlMigration

object M126 {
  RFMigrations.migrations = RFMigrations.migrations :+ SqlMigration(126)(List(
    sqlu"""
    DELETE FROM access_control_rules WHERE subject_type = 'ALL' AND object_type = 'SCENE' AND action_type = 'VIEW';
    """
  ))
}

import slick.jdbc.PostgresProfile.api._
import com.liyaos.forklift.slick.SqlMigration

object M126 {
  RFMigrations.migrations = RFMigrations.migrations :+ SqlMigration(126)(List(
    sqlu"""
    DELETE FROM access_control_rules WHERE subject_type = 'ALL' AND object_type = 'SCENE' AND
      (action_type = 'VIEW' OR action_type = 'DOWNLOAD');
    """
  ))
}

Update access control rule migration

Update access control rule migration


package ch.usi.inf.l3.sana.ooj.types

import ch.usi.inf.l3.sana
import sana.ooj.symbols.SymbolUtils

trait TypeUtils {
  def objectClassType: ClassTypeApi = {
    val qual            = SymbolUtils.packageName(SymbolUtils.objectClassSymbol)
    val name            = SymbolUtils.objectClassSymbol.name
    ClassType(qual, name, Set.empty)
  }
}

object TypeUtils extends TypeUtils

package ch.usi.inf.l3.sana.ooj.types

import ch.usi.inf.l3.sana
import sana.ooj.names.StdNames

trait TypeUtils {
  def objectClassType: ClassTypeApi = {
    val qual            = {
      val java = StdNames.JAVA_PACKAGE_NAME.asString
      val lang = StdNames.LANG_PACKAGE_NAME.asString
      s"$java.$lang"
    }
    val name            = StdNames.OBJECT_TYPE_NAME
    ClassType(qual, name, Set.empty)
  }
}

object TypeUtils extends TypeUtils

Remove mutual dependency btwn Object type & symbol


package me.flygare

import com.datastax.spark.connector.cql.CassandraConnector
import org.apache.spark.{SparkConf, SparkContext}

trait SparkConnection {
  val conf = new SparkConf(true)
    .setMaster("local[*]")
    .set("spark.cassandra.connection.host", "127.0.0.1")
    .set("spark.cassandra.auth.username", "cassandra")
    .set("spark.cassandra.auth.password", "cassandra")

  val sc = new SparkContext("spark://127.0.0.1:7077", "test", conf)

  val connector = CassandraConnector(sc.getConf)
  var session = connector.openSession()
  session.execute("CREATE KEYSPACE test WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1 };")
  session.execute("CREATE TABLE IF NOT EXISTS test.kv(id INT PRIMARY KEY, ts timestamp);")
}

package me.flygare

import com.datastax.spark.connector.cql.CassandraConnector
import org.apache.spark.{SparkConf, SparkContext}

trait SparkConnection {
  val conf = new SparkConf(true)
    .setMaster("local[*]")
    .set("spark.cassandra.connection.host", "192.168.0.200")
    .set("spark.cassandra.auth.username", "cassandra")
    .set("spark.cassandra.auth.password", "cassandra")

  val sc = new SparkContext("spark://192.168.0.200:7077", "test", conf)

  val connector = CassandraConnector(sc.getConf)
  var session = connector.openSession()
  session.execute("CREATE KEYSPACE test WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1 };")
  session.execute("CREATE TABLE IF NOT EXISTS test.kv(id INT PRIMARY KEY, ts timestamp);")
}

Update spark settings with ip

Update spark settings with ip


lazy val root = (project in file(".")).enablePlugins(SbtWeb)

libraryDependencies ++= Seq(
  "org.webjars.bower" % "bootstrap-sass" % "3.3.6",
  "org.webjars" %% "webjars-play" % "2.4.0-1"
)

lazy val root = (project in file(".")).enablePlugins(SbtWeb)

libraryDependencies ++= Seq(
  "org.webjars.bower" % "bootstrap-sass" % "3.3.6",
  "org.webjars" %% "webjars-play" % "2.6.2"
)

Upgrade Play in scripted test

Upgrade Play in scripted test


object Main extends App {
  def time[R](block: => R): R = {
    val t0 = System.nanoTime()
    val result = block    // call-by-name
    val t1 = System.nanoTime()
    println("Elapsed time: " + (t1 - t0) / 1E9 + "s")
    result
  }

  val n = args(0).toInt

  val h_i = ZeroHamiltonian.construct(n)
  val h_f = RandomIsing.construct(n)
  val t = 3.0
  val iter = 1000
  val ninstal = 3

  val result = time { Algorithm.withInstallments(h_i, h_f, t, iter, ninstal) }

  println(result)
}

object Main extends App {
  def time[R](block: => R): R = {
    val t0 = System.nanoTime()
    val result = block    // call-by-name
    val t1 = System.nanoTime()
    println("Elapsed time is " + (t1 - t0) / 1E9 + "seconds")
    result
  }

  val n = args(0).toInt

  val h_i = time { ZeroHamiltonian.construct(n) }
  val h_f = time { RandomIsing.construct(n) }
  val t = 3.0
  val iter = 1000
  val ninstal = 3

  val result = time { Algorithm.withInstallments(h_i, h_f, t, iter, ninstal) }

  println(result)
}

Convert to MATLAB format timings

Convert to MATLAB format timings


import scala.quoted.*

object MatchTest {
  inline def test[T](inline obj: T): Unit = ${testImpl('obj)}

  def testImpl[T](objExpr: Expr[T])(using qctx: Quotes, t: Type[T]): Expr[Unit] = {
    import qctx.reflect.*

    val obj = objExpr.asTerm

    val cases = obj.tpe.typeSymbol.children.map { child =>
      val subtype = TypeIdent(child)
      val bind = Symbol.newBind(Symbol.spliceOwner, "c", Flags.EmptyFlags, subtype.tpe)
      CaseDef(Bind(bind, Typed(Ref(bind), subtype)), None, '{()}.asTerm)
    }
    val result = Match(obj, cases)
    println(result.show(using Printer.TreeAnsiCode))
    result.asExprOf[Unit]
  }
}

import scala.quoted.*

object MatchTest {
  inline def test[T](inline obj: T): Unit = ${testImpl('obj)}

  def testImpl[T](objExpr: Expr[T])(using qctx: Quotes, t: Type[T]): Expr[Unit] = {
    import qctx.reflect.*

    val obj = objExpr.asTerm

    val cases = obj.tpe.typeSymbol.children.map { child =>
      val subtype = TypeIdent(child)
      val bind = Symbol.newBind(Symbol.spliceOwner, "c", Flags.EmptyFlags, subtype.tpe)
      CaseDef(Bind(bind, Typed(Ref(bind), subtype)), None, '{()}.asTerm)
    }
    val result = Match(obj, cases)
    //println(result.show(using Printer.TreeAnsiCode))
    result.asExprOf[Unit]
  }
}

Drop println to command line in macro test


// Comment to get more information during initialization
logLevel := Level.Warn

// Resolvers
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"

// Sbt plugins

// Use Scala.js 1.x
addSbtPlugin("com.vmunier"               % "sbt-web-scalajs"           % "1.0.8")
addSbtPlugin("org.scala-js"              % "sbt-scalajs"               % "1.0.0-M3")
// If you prefer using Scala.js 0.6.x, uncomment the following plugins instead:
// addSbtPlugin("com.vmunier"               % "sbt-web-scalajs"           % "1.0.8-0.6")
// addSbtPlugin("org.scala-js"              % "sbt-scalajs"               % "0.6.23")

addSbtPlugin("com.typesafe.play"         % "sbt-plugin"                % "2.6.15")
addSbtPlugin("org.portable-scala"        % "sbt-scalajs-crossproject"  % "0.5.0")
addSbtPlugin("com.typesafe.sbt"          % "sbt-gzip"                  % "1.0.2")
addSbtPlugin("com.typesafe.sbt"          % "sbt-digest"                % "1.1.4")
addSbtPlugin("com.typesafe.sbteclipse"   % "sbteclipse-plugin"         % "5.2.4")

// Comment to get more information during initialization
logLevel := Level.Warn

// Resolvers
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"

// Sbt plugins

// Use Scala.js 0.6.x
addSbtPlugin("com.vmunier"                  % "sbt-web-scalajs"           % "1.0.8-0.6")
addSbtPlugin("org.scala-js"                 % "sbt-scalajs"               % "0.6.23")
// If you prefer using Scala.js 1.x, uncomment the following plugins instead:
// addSbtPlugin("com.vmunier"               % "sbt-web-scalajs"           % "1.0.8")
// addSbtPlugin("org.scala-js"              % "sbt-scalajs"               % "1.0.0-M3")

addSbtPlugin("com.typesafe.play"         % "sbt-plugin"                % "2.6.15")
addSbtPlugin("org.portable-scala"        % "sbt-scalajs-crossproject"  % "0.5.0")
addSbtPlugin("com.typesafe.sbt"          % "sbt-gzip"                  % "1.0.2")
addSbtPlugin("com.typesafe.sbt"          % "sbt-digest"                % "1.1.4")
addSbtPlugin("com.typesafe.sbteclipse"   % "sbteclipse-plugin"         % "5.2.4")

Use Scala.js 0.6.x because most libraries are not yet compatible with Scala.js 1.x.


package avrohugger
package format

object FieldRenamer {
  val RESERVED_WORDS: Set[String] = Set("abstract", "assert", "boolean", "break", "byte", "case", "catch",
    "char", "class", "const", "continue", "default", "do", "double",
    "else", "enum", "extends", "false", "final", "finally", "float",
    "for", "goto", "if", "implements", "import", "instanceof", "int",
    "interface", "long", "native", "new", "null", "package", "private",
    "protected", "public", "return", "short", "static", "strictfp",
    "super", "switch", "synchronized", "this", "throw", "throws",
    "transient", "true", "try", "void", "volatile", "while")

  def backtick(variable: String): String = s"`$variable`"

  def mangle(variable: String): String = s"_$$$$${variable}"

  def isMangled(fieldName: String): Boolean = RESERVED_WORDS.contains(fieldName)

  def rename(fieldName: String): String = if(isMangled(fieldName)) mangle(fieldName) else if (fieldName.endsWith("_")) backtick(fieldName) else fieldName
}

package avrohugger
package format

object FieldRenamer {
  val RESERVED_WORDS: Set[String] = Set("abstract", "assert", "boolean", "break", "byte", "case", "catch",
    "char", "class", "const", "continue", "default", "do", "double",
    "else", "enum", "extends", "false", "final", "finally", "float",
    "for", "goto", "if", "implements", "import", "instanceof", "int",
    "interface", "long", "native", "new", "null", "package", "private",
    "protected", "public", "return", "short", "static", "strictfp",
    "super", "switch", "synchronized", "this", "throw", "throws",
    "transient", "true", "try", "void", "volatile", "while")

  def backtick(variable: String): String = s"`$variable`"

  def mangle(variable: String): String = s"_${variable}"

  def isMangled(fieldName: String): Boolean = RESERVED_WORDS.contains(fieldName)

  def rename(fieldName: String): String = if(isMangled(fieldName)) mangle(fieldName) else if (fieldName.endsWith("_")) backtick(fieldName) else fieldName
}

Use a simpler mangle function

Use a simpler mangle function


import io.hydrosphere.mist.lib.MistJob

object SimpleContext extends MistJob {
  /** Contains implementation of spark job with ordinary [[org.apache.spark.SparkContext]]
    * Abstract method must be overridden
    *
    * @param parameters user parameters
    * @return result of the job
    */
  override def doStuff(parameters: Map[String, Any]): Map[String, Any] = {
    val numbers: List[BigInt] = parameters("digits").asInstanceOf[List[BigInt]]
    val rdd = context.parallelize(numbers)
    Map("result" -> rdd.map(x => x * 2).collect())
  }
}

import io.hydrosphere.mist.lib.MistJob

object SimpleContext extends MistJob {
  /** Contains implementation of spark job with ordinary [[org.apache.spark.SparkContext]]
    * Abstract method must be overridden
    *
    * @param parameters user parameters
    * @return result of the job
    */
  override def doStuff(parameters: Map[String, Any]): Map[String, Any] = {
    val numbers: List[Int] = parameters("digits").asInstanceOf[List[Int]]
    val rdd = context.parallelize(numbers)
    Map("result" -> rdd.map(x => x * 2).collect())
  }
}

Fix parameter types in examples

Fix parameter types in examples


package code
package snippet

import net.liftweb.http._
import net.liftweb.util.Helpers._

import com.hacklanta.formality.Formality
  import Formality._

import model.User

object Signup {
  import net.liftweb.sitemap._
    import Loc._

  val menu =
    Menu.i("signup") / "signup" >>
      If(
        LoginHelpers.notLoggedIn_? _,
        () => RedirectResponse("/")
      )

  val loc = menu.loc
}
class Signup {
  def form = {
    val registrationForm =
      Formality.form withField
        field[String]("#email") withField
        field[String]("#password") ajaxFormalize() onSuccess {
          case email :+: password :+: HNil =>
            LoginHelpers.logUserIn(User.create(User(email, password)))

            S.redirectTo("/")
      }

    "form" #> registrationForm.binder()
  }
}

package code
package snippet

import net.liftweb.http._
import net.liftweb.util.Helpers._

import com.hacklanta.formality.Formality
  import Formality._

import model.User

object Signup {
  import net.liftweb.sitemap._
    import Loc._

  val menu =
    Menu.i("signup") / "signup" >>
      If(
        LoginHelpers.notLoggedIn_? _,
        () => RedirectResponse("/")
      )

  val loc = menu.loc
}
class Signup {
  def form = {
    val registrationForm =
      Formality.form withField
        field[String]("#email") withField
        field[String]("#password") formalize() onSuccess {
          case email :+: password :+: HNil =>
            LoginHelpers.logUserIn(User.create(User(email, password)))

            S.redirectTo("/")
      }

    "form" #> registrationForm.binder()
  }
}

Switch signup form to not be an AJAX form.


package scalacss

import utest._
import scalacss.TestUtil._
import Defaults._
import ScalatagsCss._

object ScalatagsTest extends TestSuite {

  object MyStyles extends StyleSheet.Inline {
    import dsl._

    val input = style(
      fontWeight.bold,
      padding(0.3 ex, 2 ex)
    )

    val bootstrappy = style(addClassName("btn btn-default"))
  }

  type T = scalatags.Text.TypedTag[String]
  import scalatags.Text.all._

  override val tests = TestSuite {

    'styleTag {
      val html = MyStyles.render[T].toString()
      assertEq(html, """<style type="text/css">.ScalatagsTest_MyStyles-input {
                       |  font-weight: bold;
                       |  padding: 0.3ex 2ex;
                       |}
                       |
                       |</style>""".stripMargin)
    }

    'simple {
      val el = input(`type` := "text", MyStyles.input, value := "ah")
      val html = el.toString()
      assertEq(html, """<input type="text" class="ScalatagsTest_MyStyles-input" value="ah" />""")
    }

    'addClassName {
      val el = button(MyStyles.bootstrappy)
      val html = el.toString()
      assertEq(html, """<button class="btn btn-default"></button>""")
    }

  }
}

package scalacss

import utest._
import scalacss.TestUtil._
import Defaults._
import ScalatagsCss._

object ScalatagsTest extends TestSuite {

  object MyStyles extends StyleSheet.Inline {
    import dsl._

    val input = style(
      fontWeight.bold,
      padding(0.3 ex, 2 ex)
    )

    val required = style(
      border(thin, solid, red)
    )

    val bootstrappy = style(addClassName("btn btn-default"))
  }

  type T = scalatags.Text.TypedTag[String]
  import scalatags.Text.all._

  override val tests = TestSuite {

    'styleTag {
      val html = MyStyles.render[T].toString()
      assertEq(html, """<style type="text/css">.ScalatagsTest_MyStyles-input {
                       |  font-weight: bold;
                       |  padding: 0.3ex 2ex;
                       |}
                       |
                       |</style>""".stripMargin)
    }

    'simple {
      val el = input(`type` := "text", MyStyles.input, value := "ah")
      val html = el.toString()
      assertEq(html, """<input type="text" class="ScalatagsTest_MyStyles-input" value="ah" />""")
    }

    'addClassName {
      val el = button(MyStyles.bootstrappy)
      val html = el.toString()
      assertEq(html, """<button class="btn btn-default"></button>""")
    }

    'multipleStyles {
      val el = input(`type` := "text", MyStyles.input, MyStyles.required, value := "ah")
      val html = el.toString()
      assertEq(html, """<input type="text" class="ScalatagsTest_MyStyles-input ScalatagsTest_MyStyles-required" value="ah" />""")
    }
  }
}

Add unit test for multiple styles in scalatags


package service

import java.io.ByteArrayOutputStream

import org.scalatest.Suite

import scala.util.{Failure, Success, Try}

/**
  * Runs scalatest library test suite using the 'execute' method
  */
object ScalaTestRunner {
  val failedMarker = "FAILED"
  val failedInRuntimeMarker = "failed in runtime"
  val userClass = "UserSolution"

  def execSuite(solution: String, suiteClass: Class[Suite], solutionTrait: Class[AnyRef]): String = {
    Try {
      val solutionInstance = createSolutionInstance(solution, solutionTrait)
      execSuite(suiteClass.getConstructor(solutionTrait).newInstance(solutionInstance))
    } match {
      case Success(s) => s
      case Failure(e) => s"Test failed in runtime with error:\n${e.getMessage}'"
    }
  }

  def execSuite(suiteInstance: Suite): String = {
    val stream = new ByteArrayOutputStream

    Console.withOut(stream) {
      suiteInstance.execute(stats = true, shortstacks = true, durations = true)
    }

    stream.toString
  }

  private def createSolutionInstance(solution: String, solutionTrait: Class[AnyRef]): AnyRef = {
    import scala.reflect.runtime._
    val cm = universe.runtimeMirror(getClass.getClassLoader)
    import scala.tools.reflect.ToolBox
    val tb = cm.mkToolBox()

    val patchedSolution = solution.replaceFirst("(class [A-Za-z0-9]* )", s"class $userClass extends ${solutionTrait.getSimpleName} ")
    val dynamicCode = s"import ${solutionTrait.getName}; $patchedSolution; new $userClass"
    tb.eval(tb.parse(dynamicCode)).asInstanceOf[AnyRef]
  }
}

package service

import java.io.ByteArrayOutputStream

import org.scalatest.{run, Suite}

import scala.util.{Failure, Success, Try}

/**
  * Runs scalatest library test suite using the 'execute' method
  */
object ScalaTestRunner {
  val failedMarker = "FAILED"
  val failedInRuntimeMarker = "failed in runtime"
  val userClass = "UserSolution"

  def execSuite(solution: String, suiteClass: Class[Suite], solutionTrait: Class[AnyRef]): String = {
    Try {
      val solutionInstance = createSolutionInstance(solution, solutionTrait)
      execSuite(suiteClass.getConstructor(solutionTrait).newInstance(solutionInstance))
    } match {
      case Success(s) => s
      case Failure(e) => s"Test failed in runtime with error:\n${e.getMessage}'"
    }
  }

  def execSuite(suiteInstance: Suite): String = {
    val stream = new ByteArrayOutputStream

    Console.withOut(stream) {
      suiteInstance.execute(color = false)
    }

    stream.toString
  }

  private def createSolutionInstance(solution: String, solutionTrait: Class[AnyRef]): AnyRef = {
    import scala.reflect.runtime._
    val cm = universe.runtimeMirror(getClass.getClassLoader)
    import scala.tools.reflect.ToolBox
    val tb = cm.mkToolBox()

    val patchedSolution = solution.replaceFirst("(class [A-Za-z0-9]* )", s"class $userClass extends ${solutionTrait.getSimpleName} ")
    val dynamicCode = s"import ${solutionTrait.getName}; $patchedSolution; new $userClass"
    tb.eval(tb.parse(dynamicCode)).asInstanceOf[AnyRef]
  }
}

Add "Write Whole Class" submission: improving the report output by removing color characters which can't be treated correctly in html


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.14.1",
  "org.http4s" %% "http4s-ember-client" % "0.23.10",
  "org.http4s" %% "http4s-circe" % "0.23.10",
)

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.14.1",
  "org.http4s" %% "http4s-ember-client" % "0.23.11",
  "org.http4s" %% "http4s-circe" % "0.23.11",
)

Update http4s-circe, http4s-ember-client to 0.23.11 in series/0.22


import sbt._
import sbt.Keys._
import android.Keys._
import android.Plugin._

object Build extends android.AutoBuild
{
	lazy val main = Project( "toolbelt", file( "." ) )
		.settings( androidBuildAar: _* )
		.settings(
			libraryDependencies ++= Seq(
				"com.android.support" % "appcompat-v7" % "21.0.0",
				"com.github.japgolly.android" % "svg-android" % "2.0.6",
				"com.jpardogo.materialtabstrip" % "library" % "1.0.5",
				"org.scala-lang" % "scala-reflect" % scalaVersion.value
			),
			name := "Toolbelt",
			organization := "com.taig.android",
			publishArtifact in ( Compile, packageDoc ) := false,
			scalaVersion := "2.11.4",
			scalacOptions ++= Seq(
				"-deprecation",
				"-feature",
				"-language:dynamics",
				"-language:existentials",
				"-language:implicitConversions",
				"-language:reflectiveCalls"
			),
			// @see https://github.com/pfn/android-sdk-plugin/issues/88
			sourceGenerators in Compile <<= ( sourceGenerators in Compile ) ( generators => Seq( generators.last ) ),
			version := "0.3.15-BETA",
			minSdkVersion in Android := "10",
			platformTarget in Android := "android-21",
			targetSdkVersion in Android := "21"
		)
}

import sbt._
import sbt.Keys._
import android.Keys._
import android.Plugin._

object Build extends android.AutoBuild
{
	lazy val main = Project( "toolbelt", file( "." ) )
		.settings( androidBuildAar: _* )
		.settings(
			libraryDependencies ++= Seq(
				"com.android.support" % "appcompat-v7" % "21.0.0",
				"com.github.japgolly.android" % "svg-android" % "2.0.6",
				"com.jpardogo.materialtabstrip" % "library" % "1.0.5",
				"org.scala-lang" % "scala-reflect" % scalaVersion.value
			),
			name := "Toolbelt",
			organization := "com.taig.android",
			publishArtifact in ( Compile, packageDoc ) := false,
			scalaVersion := "2.11.4",
			scalacOptions ++= Seq(
				"-deprecation",
				"-feature",
				"-language:dynamics",
				"-language:existentials",
				"-language:implicitConversions",
				"-language:reflectiveCalls"
			),
			// @see https://github.com/pfn/android-sdk-plugin/issues/88
			sourceGenerators in Compile <<= ( sourceGenerators in Compile ) ( generators => Seq( generators.last ) ),
			version := "0.3.16-BETA",
			minSdkVersion in Android := "10",
			platformTarget in Android := "android-21",
			targetSdkVersion in Android := "21"
		)
}

Set project version to 0.3.16-BETA

Set project version to 0.3.16-BETA


resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1")

resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.2")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")

// cross-compiling
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject"      % "0.6.0")
addSbtPlugin("org.scala-js"       % "sbt-scalajs"                   % "0.6.28")

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1")

resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.2")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")

// cross-compiling
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject"      % "0.6.0")
addSbtPlugin("org.scala-js"       % "sbt-scalajs"                   % "0.6.29")

Update sbt-scalajs, scalajs-compiler to 0.6.29


addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.1")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.2")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")

Update play-ahc-ws, play-specs2, sbt-plugin to 2.8.2


addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.1.12")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.1.14")

Upgrade to sbt-jmh plugin to use latest JMH v1.8.0


latestVersion in ThisBuild := "0.7.0"
latestBinaryCompatibleVersion in ThisBuild := Some("0.7.0")
unreleasedModuleNames in ThisBuild := Set("ciris-cats-effect")

latestVersion in ThisBuild := "0.7.1"
latestBinaryCompatibleVersion in ThisBuild := Some("0.7.1")
unreleasedModuleNames in ThisBuild := Set()

Set latest version to 0.7.1

Set latest version to 0.7.1


package io.aigar.game

import io.aigar.game._
import com.github.jpbetz.subspace._

/**
 * Game holds the logic for an individual game being played
 * (e.g. the ranked game or a private test game).
 */
object Game {
  final val RankedGameId = 0
  final val PlayersInRankedGame = 15
}

class Game(val id: Int, playersInGame: Int) {
  val grid = new Grid(playersInGame * Grid.WidthPerPlayer, playersInGame * Grid.HeightPerPlayer)
  val players = createPlayers(playersInGame)
  var tick = 0

  def update(deltaSeconds: Float) {
    players.foreach { _.update(deltaSeconds) }

    tick += 1
  }

  def state = {
    //TODO really implement and update spec to add tests
    serializable.GameState(
        id,
        tick,
        players.map(_.state).toList,
        serializable.Food(List(serializable.Position(5,5)), List[serializable.Position](), List[serializable.Position]()),
        grid.state,
        List[serializable.Position]()
      )
  }

  def createPlayers(playersInGame: Int) = {
    val ids = 1 to playersInGame

    ids.map { new Player(_, spawnPosition) }
  }

  def spawnPosition = {
    grid.randomPosition
  }
}

package io.aigar.game

import io.aigar.game._
import com.github.jpbetz.subspace._

/**
 * Game holds the logic for an individual game being played
 * (e.g. the ranked game or a private test game).
 */
object Game {
  final val RankedGameId = 0
  final val PlayersInRankedGame = 15
}

class Game(val id: Int, playersInGame: Int) {
  val grid = new Grid(playersInGame * Grid.WidthPerPlayer, playersInGame * Grid.HeightPerPlayer)
  val players = createPlayers
  var tick = 0

  def update(deltaSeconds: Float) {
    players.foreach { _.update(deltaSeconds) }

    tick += 1
  }

  def state = {
    //TODO really implement and update spec to add tests
    serializable.GameState(
        id,
        tick,
        players.map(_.state).toList,
        serializable.Food(List(serializable.Position(5,5)), List[serializable.Position](), List[serializable.Position]()),
        grid.state,
        List[serializable.Position]()
      )
  }

  def createPlayers = {
    val ids = 1 to playersInGame

    ids.map { new Player(_, spawnPosition) }
  }

  def spawnPosition = {
    grid.randomPosition
  }
}

Remove unnecessary param to method

[cr] Remove unnecessary param to method


name := "lib-apidoc-json-validation"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.14"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.8",
      "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")
  }
}

name := "lib-apidoc-json-validation"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.15"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.8",
      "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")
  }
}

autocommit: Update configuration to record version 0.0.15


import com.tuplejump.sbt.yeoman.Yeoman

name := """art-app"""

version := "1.1-FINAL"

// Only used to be picked up from the jenkins build script to emit the webserver port.
javaOptions in run += "-Dhttp.port=9085"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa,
  javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
  "org.hibernate" % "hibernate-entitymanager" % "4.3.8.Final",
  "com.heroku.sdk" % "heroku-jdbc" % "0.1.1",
  "mysql" % "mysql-connector-java" % "5.1.34",
  "commons-io" % "commons-io" % "2.4",
  cache,
  javaWs
)

// Generates one big JAR file with all libraries. Prevents having a too long classpath string (which is an issue on windows)
enablePlugins(ClasspathJarPlugin)

Yeoman.yeomanSettings ++ Yeoman.withTemplates

// Activate dependency injected controllers and not static controllers.
// This is a new function since play framework 2.4
routesGenerator := InjectedRoutesGenerator

// Required since play framework 2.4 to prevent classpath errors in
// production distribution of the application.
PlayKeys.externalizeResources := false

import com.tuplejump.sbt.yeoman.Yeoman

name := """art-app"""

version := "1.1-FINAL"

// Only used to be picked up from the jenkins build script to emit the webserver port.
javaOptions in run += "-Dhttp.port=9085"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa,
  javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
  "org.hibernate" % "hibernate-entitymanager" % "4.3.8.Final",
  "com.heroku.sdk" % "heroku-jdbc" % "0.1.1",
  "mysql" % "mysql-connector-java" % "5.1.34",
  "commons-io" % "commons-io" % "2.4",
  cache,
  javaWs
)

// Generates one big JAR file with all libraries. Prevents having a too long classpath string (which is an issue on windows)
enablePlugins(ClasspathJarPlugin)

Yeoman.yeomanSettings ++ Yeoman.withTemplates

// Disable Grunt execution for Heroku deployment
Yeoman.forceGrunt := false

// Activate dependency injected controllers and not static controllers.
// This is a new function since play framework 2.4
routesGenerator := InjectedRoutesGenerator

// Required since play framework 2.4 to prevent classpath errors in
// production distribution of the application.
PlayKeys.externalizeResources := false

Disable Grunt run for Heroku Deyployment


name := "management"

organization := "com.gu"

version := "4.0-SNAPSHOT"

libraryDependencies += "org.slf4j" % "slf4j-api" % "1.6.1"

libraryDependencies += "javax.servlet" % "servlet-api" % "2.4" % "provided"

libraryDependencies += "org.specs2" %% "specs2" % "1.2" % "test"

publishTo <<= (version) { version: String =>
    val publishType = if (version.endsWith("SNAPSHOT")) "snapshots" else "releases"
    Some(
        Resolver.file(
            "guardian github " + publishType,
            file(System.getProperty("user.home") + "/guardian.github.com/maven/repo-" + publishType)
        )
    )
}

import java.util.jar._

name := "management"

organization := "com.gu"

// try adding "in ThisBuild" here
version := "4.0-SNAPSHOT"

libraryDependencies += "org.slf4j" % "slf4j-api" % "1.6.1"

libraryDependencies += "javax.servlet" % "servlet-api" % "2.4" % "provided"

libraryDependencies += "org.specs2" %% "specs2" % "1.2" % "test"

packageOptions <+= (version, name) map { (v, n) =>
  Package.ManifestAttributes(
    Attributes.Name.IMPLEMENTATION_VERSION -> v,
    Attributes.Name.IMPLEMENTATION_TITLE -> n,
    Attributes.Name.IMPLEMENTATION_VENDOR -> "guardian.co.uk"
  )
}

publishTo <<= (version) { version: String =>
    val publishType = if (version.endsWith("SNAPSHOT")) "snapshots" else "releases"
    Some(
        Resolver.file(
            "guardian github " + publishType,
            file(System.getProperty("user.home") + "/guardian.github.com/maven/repo-" + publishType)
        )
    )
}

Set MANIFEST.MF attributes for management jar


package edu.umd.mith.hathi

import java.io.File
import scalaz._, Scalaz._

/** Represents a set of metadata files and a data set.
  */
class Collection(val metadataBase: File, datasetBase: File) extends Dataset(datasetBase)
  with MetadataJson {
  def volume(htid: Htid): Throwable \/ Volume = for {
    metadataFile <- isFile(new File(metadataBase, s"${ htid.toFileName }.json"))
    metadataJson <- contents(metadataFile)
    metadata <- parseVolumeMetadata(htid)(metadataJson)
    pages <- pages(htid)
  } yield Volume(metadata, pages)
}

package edu.umd.mith.hathi

import java.io.File
import scalaz._, Scalaz._

/** Represents a set of metadata files and a data set.
  */
class Collection(val metadataBase: File, datasetBase: File) extends Dataset(datasetBase)
  with MetadataJson {
  def volumeMetadata(htid: Htid): Throwable \/ VolumeMetadata = for {
    metadataFile <- isFile(new File(metadataBase, s"${ htid.toFileName }.json"))
    metadataJson <- contents(metadataFile)
    metadata <- parseVolumeMetadata(htid)(metadataJson)
  } yield metadata

  def volume(htid: Htid): Throwable \/ Volume = for {
    metadata <- volumeMetadata(htid)
    pages <- pages(htid)
  } yield Volume(metadata, pages)
}

Allow metadata retrieval without unzipping pages.


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.11"

crossScalaVersions := Seq("2.11.11")

version := "0.4.10"

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.11"

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")
  }
}

autocommit: Update configuration to record version 0.4.11


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")
  }
}

import com.github.retronym.SbtOneJar._
import sbt.Credentials

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.6"

version := "0.1.98"

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")
  }
}

autocommit: Update configuration to record version 0.1.98


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.5"

version := "0.1.72"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.6.9",
      "com.ning" % "async-http-client" % "1.9.40",
      "org.scalatest" %% "scalatest" % "3.0.5" % 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.12.5"

version := "0.1.73"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.6.9",
      "com.ning" % "async-http-client" % "1.9.40",
      "org.scalatest" %% "scalatest" % "3.0.5" % 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")
  }
}

autocommit: Update configuration to record version 0.1.73


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.7"

crossScalaVersions := Seq("2.11.7")

version := "0.0.50"

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.51"

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")
  }
}

autocommit: Update configuration to record version 0.0.51


val scala3Version = "3.0.0"

lazy val root = project
  .in(file("."))
  .settings(
    name := "sectery",
    version := "0.1.0",
    scalaVersion := scala3Version,
    libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
  )

val scala3Version = "3.0.0"

lazy val root = project
  .in(file("."))
  .settings(
    name := "sectery",
    scalaVersion := scala3Version,
    libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
  )

Drop the project version from the sbt config


shavenMavenTask

organization := "com.raymanoz"

name := "typesafeconfig-reloaded"

scalaVersion := "2.11.4"

scalaBinaryVersion := "2.11"

version := {
  import System.getProperty
  Option(getProperty("version")).getOrElse("dev.build")
}

publishTo := Some(Resolver.file("file", new File("target")))

pomExtra := <dependencies>
  <dependency>
    <groupId>com.unsprung.careless</groupId>
    <artifactId>careless</artifactId>
    <version>27</version>
  </dependency>
  <dependency>
    <groupId>com.typesafe</groupId>
    <artifactId>config</artifactId>
    <version>1.2.1</version>
  </dependency>
</dependencies>

shavenMavenTask

organization := "com.raymanoz"

name := "typesafeconfig-reloaded"

scalaVersion := "2.11.4"

scalaBinaryVersion := "2.11"

version := {
  import System.getProperty
  Option(getProperty("BUILD_NUMBER")).getOrElse("dev.build")
}

publishTo := Some(Resolver.file("file", new File("target")))

pomExtra := <dependencies>
  <dependency>
    <groupId>com.unsprung.careless</groupId>
    <artifactId>careless</artifactId>
    <version>27</version>
  </dependency>
  <dependency>
    <groupId>com.typesafe</groupId>
    <artifactId>config</artifactId>
    <version>1.2.1</version>
  </dependency>
</dependencies>

Make version BUILD_NUMBER property being set by travis


package util

import org.scalatest.FunSpec
import org.scalatest.Matchers
import org.apache.commons.codec.binary.Base64

class BasicAuthorizationSpec extends FunSpec with Matchers {

  def encode(v: String):String = {
    new String(Base64.encodeBase64(v.getBytes))
  }

  it("parses a valid token") {
    BasicAuthorization.get("Basic " + encode("abc")) should be(Some(BasicAuthorization.Token("abc")))
  }

  it("parses a valid optional token") {
    BasicAuthorization.get(Some("Basic " + encode("abc"))) should be(Some(BasicAuthorization.Token("abc")))
  }

  it("parses a valid token with a colon") {
    BasicAuthorization.get("Basic " + encode("abc:")) should be(Some(BasicAuthorization.Token("abc")))
  }

  it("parses username and password") {
    BasicAuthorization.get("Basic " + encode("user:pass")) should be(Some(BasicAuthorization.User("user", "pass")))
  }

  it("Ignores non basic auth") {
    BasicAuthorization.get("Other " + encode("user:pass")) should be(None)
  }

  it("Ignores empty string") {
    BasicAuthorization.get("Basic " + encode("")) should be(None)
  }

}

package util

import org.scalatest.FunSpec
import org.scalatest.Matchers
import org.apache.commons.codec.binary.Base64

class BasicAuthorizationSpec extends FunSpec with Matchers {

  def encode(v: String):String = {
    new String(Base64.encodeBase64(v.getBytes))
  }

  it("parses a valid token") {
    BasicAuthorization.get("Basic " + encode("abc")) should be(Some(BasicAuthorization.Token("abc")))
  }

  it("parses a valid optional token") {
    BasicAuthorization.get(Some("Basic " + encode("abc"))) should be(Some(BasicAuthorization.Token("abc")))
  }

  it("parses a valid token with a colon") {
    BasicAuthorization.get("Basic " + encode("abc:")) should be(Some(BasicAuthorization.Token("abc")))
  }

  it("parses username and password") {
    BasicAuthorization.get("Basic " + encode("user:pass")) should be(Some(BasicAuthorization.User("user", "pass")))
  }

  it("Ignores non basic auth") {
    BasicAuthorization.get("Other " + encode("user:pass")) should be(None)
  }

  it("Ignores invalid auth") {
    BasicAuthorization.get("Basic " + encode("user:pass:other")) should be(None)
  }

  it("Ignores empty string") {
    BasicAuthorization.get("Basic " + encode("")) should be(None)
  }

}

Add a test case for basic auth

Add a test case for basic auth


package controllers

import javax.inject._

import play.api.data.Form
import play.api.data.Forms._
import play.api.mvc._

@Singleton
class Application @Inject() extends Controller {

  case class DomainFormModel(domain: String)
  case class UrlFormModel(url: String)

  val domainForm = Form(
    mapping(
      "domain" -> nonEmptyText
    )(DomainFormModel.apply)(DomainFormModel.unapply)
  )

  val urlForm = Form(
    mapping(
      "url" -> nonEmptyText
    )(UrlFormModel.apply)(UrlFormModel.unapply)
  )

  def index = Action { implicit request =>
    val d = domainForm.bindFromRequest()
    val u = urlForm.bindFromRequest()
    (d.hasErrors, u.hasErrors) match {
      case (false, _) =>
        Ok(views.html.withDomain(d.value.get.domain))
      case (_, false) =>
        Ok(views.html.withUrl(u.value.get.url))
      case _ =>
        Ok(views.html.default())
    }
  }

}

package controllers

import javax.inject._

import play.api.data.Form
import play.api.data.Forms._
import play.api.mvc._

@Singleton
class Application @Inject() extends Controller {

  case class DomainFormModel(domain: String)
  case class UrlFormModel(url: String)

  val domainForm = Form(
    mapping(
      "domain" -> nonEmptyText
    )(DomainFormModel.apply)(DomainFormModel.unapply)
  )

  val urlForm = Form(
    mapping(
      "url" -> nonEmptyText
    )(UrlFormModel.apply)(UrlFormModel.unapply)
  )

  def index = Action { implicit request =>
    val d = domainForm.bindFromRequest()
    val u = urlForm.bindFromRequest()
    (d.hasErrors, u.hasErrors) match {
      case (false, _) =>
        UnavailableForLegalReasons(views.html.withDomain(d.value.get.domain))
      case (_, false) =>
        UnavailableForLegalReasons(views.html.withUrl(u.value.get.url))
      case _ =>
        UnavailableForLegalReasons(views.html.default())
    }
  }

  private val UnavailableForLegalReasons = new Status(451)

}

Use HTTP status 451 instead of 200

Use HTTP status 451 instead of 200


import java.util.jar._

crossScalaVersions in ThisBuild := Seq("2.9.1")

// doing "in ThisBuild" makes this default setting for all projects in this build
version in ThisBuild := "5.7-SNAPSHOT"

organization in ThisBuild := "com.gu"

publishArtifact := false

packageOptions in ThisBuild <+= (version, name) map { (v, n) =>
  Package.ManifestAttributes(
    Attributes.Name.IMPLEMENTATION_VERSION -> v,
    Attributes.Name.IMPLEMENTATION_TITLE -> n,
    Attributes.Name.IMPLEMENTATION_VENDOR -> "guardian.co.uk"
  )
}

publishTo in ThisBuild <<= (version) { version: String =>
    val publishType = if (version.endsWith("SNAPSHOT")) "snapshots" else "releases"
    Some(
        Resolver.file(
            "guardian github " + publishType,
            file(System.getProperty("user.home") + "/guardian.github.com/maven/repo-" + publishType)
        )
    )
}

scalacOptions in ThisBuild += "-deprecation"

import java.util.jar._

crossScalaVersions in ThisBuild := Seq("2.9.1")

// doing "in ThisBuild" makes this default setting for all projects in this build
version in ThisBuild := "5.8-SNAPSHOT"

organization in ThisBuild := "com.gu"

publishArtifact := false

packageOptions in ThisBuild <+= (version, name) map { (v, n) =>
  Package.ManifestAttributes(
    Attributes.Name.IMPLEMENTATION_VERSION -> v,
    Attributes.Name.IMPLEMENTATION_TITLE -> n,
    Attributes.Name.IMPLEMENTATION_VENDOR -> "guardian.co.uk"
  )
}

publishTo in ThisBuild <<= (version) { version: String =>
    val publishType = if (version.endsWith("SNAPSHOT")) "snapshots" else "releases"
    Some(
        Resolver.file(
            "guardian github " + publishType,
            file(System.getProperty("user.home") + "/guardian.github.com/maven/repo-" + publishType)
        )
    )
}

scalacOptions in ThisBuild += "-deprecation"

Update for 5.8-SNAPSHOT development cycle.


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-lint"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.37"

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.38"

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")
  }
}

autocommit: Update configuration to record version 0.0.38


name := "play-mockws"

scalaVersion := "2.12.8"

crossScalaVersions := Seq("2.11.12", "2.12.8")

scalacOptions ++= Seq("-deprecation", "-feature")

organization := "de.leanovate.play-mockws"

val playVersion = "2.7.2"

fork := true

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play"                             % playVersion % "provided",
  "com.typesafe.play" %% "play-ahc-ws"                      % playVersion % "provided",
  "com.typesafe.play" %% "play-test"                        % playVersion % "provided"
)

libraryDependencies ++= Seq(
  "org.scalatest"  %% "scalatest"    % "3.0.7",
  "org.scalacheck" %% "scalacheck"   % "1.14.0",
  "org.mockito"    %  "mockito-core" % "2.27.0"
) map (_ % Test)

Release.settings

name := "play-mockws"

scalaVersion := "2.12.8"

crossScalaVersions := Seq("2.11.12", "2.12.8")

scalacOptions ++= Seq("-deprecation", "-feature")

organization := "de.leanovate.play-mockws"

val playVersion = "2.7.3"

fork := true

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play"                             % playVersion % "provided",
  "com.typesafe.play" %% "play-ahc-ws"                      % playVersion % "provided",
  "com.typesafe.play" %% "play-test"                        % playVersion % "provided"
)

libraryDependencies ++= Seq(
  "org.scalatest"  %% "scalatest"    % "3.0.7",
  "org.scalacheck" %% "scalacheck"   % "1.14.0",
  "org.mockito"    %  "mockito-core" % "2.27.0"
) map (_ % Test)

Release.settings

Update play, play-ahc-ws, play-test to 2.7.3


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.1.4"

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.1.5"

autocommit: Update configuration to record version 0.1.5


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.7"

crossScalaVersions := Seq("2.11.7")

version := "0.0.14"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      "org.scalatest" %% "scalatest" % "2.2.5" % "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.15"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      "org.scalatest" %% "scalatest" % "2.2.5" % "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")
  }
}

Increment version from 0.0.14 => 0.0.15

Increment version from 0.0.14 => 0.0.15


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.13.0",
  "org.http4s" %% "http4s-blaze-client" % "0.21.9",
  "org.http4s" %% "http4s-circe" % "0.21.9",
)

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.13.0",
  "org.http4s" %% "http4s-blaze-client" % "0.21.11",
  "org.http4s" %% "http4s-circe" % "0.21.11",
)

Update http4s-blaze-client, ... to 0.21.11


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 =>
    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 _)
      )
  }

}

Add type annotations on provider values

Add type annotations on provider values


package protocbridge

object gens {
  // Prevent the organization name from getting shaded...
  // See https://github.com/scalapb/ScalaPB/issues/150
  private val JavaProtobufArtifact: String =
    "com+google+protobuf".replace('+', '.')

  val cpp = BuiltinGenerator("cpp")
  val csharp = BuiltinGenerator("csharp")
  val java: BuiltinGenerator = java("3.11.4")

  def java(runtimeVersion: String): BuiltinGenerator =
    BuiltinGenerator(
      "java",
      suggestedDependencies =
        Seq(Artifact(JavaProtobufArtifact, "protobuf-java", runtimeVersion))
    )

  def plugin(name: String): PluginGenerator = PluginGenerator(name, Nil, None)

  def plugin(name: String, path: String): PluginGenerator =
    PluginGenerator(name, Nil, Some(path))

  val javanano = BuiltinGenerator("javanano")
  val js = BuiltinGenerator("js")
  val objc = BuiltinGenerator("objc")
  val python = BuiltinGenerator("python")
  val ruby = BuiltinGenerator("ruby")
  val go = BuiltinGenerator("go")
  val swagger = BuiltinGenerator("swagger")
  val gateway = BuiltinGenerator("grpc-gateway")
  val descriptorSet = DescriptorSetGenerator()
}

package protocbridge

object gens {
  // Prevent the organization name from getting shaded...
  // See https://github.com/scalapb/ScalaPB/issues/150
  private val JavaProtobufArtifact: String =
    "com+google+protobuf".replace('+', '.')

  val cpp = BuiltinGenerator("cpp")
  val csharp = BuiltinGenerator("csharp")
  val java: BuiltinGenerator = java("3.11.4")

  def java(runtimeVersion: String): BuiltinGenerator =
    BuiltinGenerator(
      "java",
      suggestedDependencies =
        Seq(Artifact(JavaProtobufArtifact, "protobuf-java", runtimeVersion))
    )

  def plugin(name: String): PluginGenerator = PluginGenerator(name, Nil, None)

  def plugin(name: String, path: String): PluginGenerator =
    PluginGenerator(name, Nil, Some(path))

  val javanano = BuiltinGenerator("javanano")
  val kotlin: BuiltinGenerator = kotlin("3.17.2")
  def kotlin(runtimeVersion: String): BuiltinGenerator =
    BuiltinGenerator(
      "kotlin",
      suggestedDependencies =
        Seq(Artifact(JavaProtobufArtifact, "protobuf-kotlin", runtimeVersion))
    )

  val js = BuiltinGenerator("js")
  val objc = BuiltinGenerator("objc")
  val python = BuiltinGenerator("python")
  val ruby = BuiltinGenerator("ruby")
  val go = BuiltinGenerator("go")
  val swagger = BuiltinGenerator("swagger")
  val gateway = BuiltinGenerator("grpc-gateway")
  val descriptorSet = DescriptorSetGenerator()
}

Add kotlin to built in generator.

Add kotlin to built in generator.

Kotlin support was added in protoc v3.17.0.


package net.ruippeixotog.scalascraper.util

object ProxyUtils {

  private val HTTP_PROXY_HOST: String = "http.proxyHost"
  private val HTTP_PROXY_PORT: String = "http.proxyPort"
  private val HTTPS_PROXY_PORT: String = "https.proxyPort"
  private val HTTPS_PROXY_HOST: String = "https.proxyHost"

  /**
   * Set HTTP and HTTPS proxy JVM-wide
   */
  def setProxy(host: String, port: Int): Unit = {
    System.setProperty(HTTP_PROXY_HOST, host)
    System.setProperty(HTTP_PROXY_PORT, String.valueOf(port))
    System.setProperty(HTTPS_PROXY_HOST, host)
    System.setProperty(HTTPS_PROXY_PORT, String.valueOf(port))
  }

  /**
   * Remove HTTP and HTTPS proxy configuration JVM-wide
   */
  def removeProxy(): Unit = {
    System.clearProperty(HTTP_PROXY_HOST)
    System.clearProperty(HTTP_PROXY_PORT)
    System.clearProperty(HTTPS_PROXY_HOST)
    System.clearProperty(HTTPS_PROXY_PORT)
  }

}

package net.ruippeixotog.scalascraper.util

object ProxyUtils {

  private[this] val HTTP_PROXY_HOST: String = "http.proxyHost"
  private[this] val HTTP_PROXY_PORT: String = "http.proxyPort"
  private[this] val HTTPS_PROXY_PORT: String = "https.proxyPort"
  private[this] val HTTPS_PROXY_HOST: String = "https.proxyHost"

  /**
   * Set HTTP and HTTPS proxy JVM-wide
   */
  def setProxy(host: String, port: Int): Unit = {
    System.setProperty(HTTP_PROXY_HOST, host)
    System.setProperty(HTTP_PROXY_PORT, String.valueOf(port))
    System.setProperty(HTTPS_PROXY_HOST, host)
    System.setProperty(HTTPS_PROXY_PORT, String.valueOf(port))
  }

  /**
   * Remove HTTP and HTTPS proxy configuration JVM-wide
   */
  def removeProxy(): Unit = {
    System.clearProperty(HTTP_PROXY_HOST)
    System.clearProperty(HTTP_PROXY_PORT)
    System.clearProperty(HTTPS_PROXY_HOST)
    System.clearProperty(HTTPS_PROXY_PORT)
  }

}

Reduce scope of constants to private[this]


package spire

import spire.syntax._

package object syntax {
  object cfor extends CforSyntax
  object literals extends LiteralsSyntax

  object eq extends EqSyntax
  object order extends OrderSyntax
  object signed extends SignedSyntax
  object isReal extends IsRealSyntax
  object convertableFrom extends ConvertableFromSyntax

  object semigroup extends SemigroupSyntax
  object monoid extends MonoidSyntax
  object group extends GroupSyntax

  object additiveSemigroup extends AdditiveSemigroupSyntax
  object additiveMonoid extends AdditiveMonoidSyntax
  object additiveGroup extends AdditiveGroupSyntax

  object multiplicativeSemigroup extends MultiplicativeSemigroupSyntax
  object multiplicativeMonoid extends MultiplicativeMonoidSyntax
  object multiplicativeGroup extends MultiplicativeGroupSyntax

  object semiring extends SemiringSyntax
  object rig extends RigSyntax
  object rng extends RngSyntax
  object ring extends RingSyntax
  object euclideanRing extends EuclideanRingSyntax
  object field extends FieldSyntax
  object nroot extends NRootSyntax
  object trig extends TrigSyntax

  object module extends ModuleSyntax
  object vectorSpace extends VectorSpaceSyntax
  object metricSpace extends MetricSpaceSyntax
  object normedVectorSpace extends NormedVectorSpaceSyntax
  object innerProductSpace extends InnerProductSpaceSyntax
  object coordinateSpace extends CoordinateSpaceSyntax

  object booleanAlgebra extends BooleanAlgebraSyntax

  object bitString extends BitStringSyntax

  object additiveGroupAction extends AdditiveGroupActionSyntax
  object multiplicativeGroupAction extends MultiplicativeGroupActionSyntax

  object integral extends IntegralSyntax
  object fractional extends FractionalSyntax
  object numeric extends NumericSyntax

  object all extends AllSyntax
}

package spire

import spire.syntax._

package object syntax {
  object cfor extends CforSyntax
  object literals extends LiteralsSyntax

  object eq extends EqSyntax
  object order extends OrderSyntax
  object signed extends SignedSyntax
  object isReal extends IsRealSyntax
  object convertableFrom extends ConvertableFromSyntax

  object semigroup extends SemigroupSyntax
  object monoid extends MonoidSyntax
  object group extends GroupSyntax

  object additiveSemigroup extends AdditiveSemigroupSyntax
  object additiveMonoid extends AdditiveMonoidSyntax
  object additiveGroup extends AdditiveGroupSyntax

  object multiplicativeSemigroup extends MultiplicativeSemigroupSyntax
  object multiplicativeMonoid extends MultiplicativeMonoidSyntax
  object multiplicativeGroup extends MultiplicativeGroupSyntax

  object semiring extends SemiringSyntax
  object rig extends RigSyntax
  object rng extends RngSyntax
  object ring extends RingSyntax
  object euclideanRing extends EuclideanRingSyntax
  object field extends FieldSyntax
  object nroot extends NRootSyntax
  object trig extends TrigSyntax

  object module extends ModuleSyntax
  object vectorSpace extends VectorSpaceSyntax
  object metricSpace extends MetricSpaceSyntax
  object normedVectorSpace extends NormedVectorSpaceSyntax
  object innerProductSpace extends InnerProductSpaceSyntax
  object coordinateSpace extends CoordinateSpaceSyntax

  object booleanAlgebra extends BooleanAlgebraSyntax

  object bitString extends BitStringSyntax

  object additiveGroupAction extends AdditiveGroupActionSyntax
  object multiplicativeGroupAction extends MultiplicativeGroupActionSyntax

  object additiveTorsor extends AdditiveTorsorSyntax
  object multiplicativeTorsor extends MultiplicativeTorsorSyntax

  object integral extends IntegralSyntax
  object fractional extends FractionalSyntax
  object numeric extends NumericSyntax

  object all extends AllSyntax
}

Add torsor-specific syntax import objects.


import $file.repl.src.test.resources.scriptLevelCaching.fileToBeImported

@

println("Hope It works!!")

@
println(fileToBeImported.listScalaFiles)
println("Yup!! It worked :) ")

import $file.ammonite.src.test.resources.scriptLevelCaching.fileToBeImported

@

println("Hope It works!!")

@
println(fileToBeImported.listScalaFiles)
println("Yup!! It worked :) ")

Fix file import test script

Fix file import test script


// Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>

// Comment to get more information during initialization
logLevel := Level.Warn

lazy val plugins = (project in file(".")).dependsOn(playDocsPlugin)

lazy val playDocsPlugin = ProjectRef(Path.fileProperty("user.dir").getParentFile, "Play-Docs-Sbt-Plugin")

// Required for Production.md
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")

// Required for PlayEnhancer.md
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.2.2")

// Add headers to example sources
addSbtPlugin("de.heikoseeberger" % "sbt-header"         % "5.2.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.4.4")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt"       % "2.0.1")

// Required for Tutorial
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.5.0-M3")

// Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>

// Comment to get more information during initialization
logLevel := Level.Warn

lazy val plugins = (project in file(".")).dependsOn(playDocsPlugin)

lazy val playDocsPlugin = ProjectRef(Path.fileProperty("user.dir").getParentFile, "Play-Docs-Sbt-Plugin")

// Required for Production.md
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")

// Required for PlayEnhancer.md
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.2.2")

// Add headers to example sources
addSbtPlugin("de.heikoseeberger" % "sbt-header"         % "5.2.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.4.4")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt"       % "2.0.1")

// Required for Tutorial
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.5.0-M4")

Update twirl version on documentation

Update twirl version on documentation


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.94"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.9",
      "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.95"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.9",
      "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")
  }
}

autocommit: Update configuration to record version 0.0.95


name := "plotly"

version := "0.2.0"

organization := "co.theasi"

scalaVersion := "2.11.8"

crossScalaVersions := Seq("2.11.8", "2.10.6")

libraryDependencies ++= Seq(
  "org.scalaj" %% "scalaj-http" % "2.2.1",
  "org.json4s" %% "json4s-native" % "3.3.0",
  "org.scalatest" %% "scalatest" % "2.2.4" % "test"
)

initialCommands := """
  |import co.theasi.plotly._
""".stripMargin

publishMavenStyle := true

// Publishing
publishTo <<= version { (v: String) =>
  val nexus = "https://oss.sonatype.org/"
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/snapshots")
  else
    Some("releases"  at nexus + "service/local/staging/deploy/maven2")
}

// Testing
parallelExecution in Test := false

logBuffered in Test := false

// Documentation
enablePlugins(SiteScaladocPlugin)

ghpages.settings

git.remoteRepo := "git@github.com:ASIDataScience/scala-plotly-client.git"

name := "plotly"

version := "0.2.0"

organization := "co.theasi"

scalaVersion := "2.11.8"

crossScalaVersions := Seq("2.11.8", "2.10.6")

libraryDependencies ++= Seq(
  "org.scalaj" %% "scalaj-http" % "2.2.1",
  "org.json4s" %% "json4s-native" % "3.4.1",
  "org.scalatest" %% "scalatest" % "3.0.0" % "test"
)

initialCommands := """
  |import co.theasi.plotly._
""".stripMargin

publishMavenStyle := true

// Publishing
publishTo <<= version { (v: String) =>
  val nexus = "https://oss.sonatype.org/"
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/snapshots")
  else
    Some("releases"  at nexus + "service/local/staging/deploy/maven2")
}

// Testing
parallelExecution in Test := false

logBuffered in Test := false

// Documentation
enablePlugins(SiteScaladocPlugin)

ghpages.settings

git.remoteRepo := "git@github.com:ASIDataScience/scala-plotly-client.git"

Update dependencies to latest stable releases


package com.michalrus.helper

import android.view.View
import android.widget.Button
import android.view.View.OnClickListener
import android.util.Log

trait ViewHelper {

  def log(s: String) = Log.d("com.michalrus.helper", s)

  implicit def scalaizeView(v: View) = new ScalaView(v)
  class ScalaView(val v: View) {
    def find[T](id: Int) = v.findViewById(id).asInstanceOf[T]
  }

  implicit def scalaizeButton(b: Button) = new ScalaButton(b)
  class ScalaButton(val b: Button) {
    def onClick[A](f: => A) {
      b.setOnClickListener(new OnClickListener {
        def onClick(v: View) = f
      })
    }
  }

}

package com.michalrus.helper

import android.view.View
import android.widget.Button
import android.view.View.OnClickListener
import android.util.Log

trait ViewHelper {

  def log(s: String) = Log.d("com.michalrus.helper", s)

  implicit def scalaizeView(v: View) = new ScalaView(v)
  class ScalaView(val v: View) {
    def find[T](id: Int) = v.findViewById(id).asInstanceOf[T]
  }

  implicit def scalaizeButton(b: Button) = new ScalaButton(b)
  class ScalaButton(val b: Button) {
    def onClick[A](f: => A) {
      b.setOnClickListener(new OnClickListener {
        def onClick(v: View) = f
      })
    }
  }

  implicit def blockToRunnable(f: => Unit) = new Runnable {
    def run() = f
  }

}

Create a Runnable from a { block } implicitly


package repository

import play.api.Play
import play.api.Play.current
import play.modules.reactivemongo.ReactiveMongoPlugin
import reactivemongo.api.DB
import scala.concurrent.ExecutionContext.Implicits.global

trait SecureSocialDatabase {
  lazy val secureSocialDatabase = Play.current.configuration.getString("secureSocialDatabaseName")

  lazy val db: DB = {
    val rootDB = ReactiveMongoPlugin.db
    secureSocialDatabase.map(rootDB.sibling(_)).getOrElse(rootDB)
  }
}

package repository

import play.api.Play
import play.api.Play.current
import play.modules.reactivemongo.ReactiveMongoPlugin
import reactivemongo.api.DB
import scala.concurrent.ExecutionContext.Implicits.global

trait SecureSocialDatabase {
//  lazy val secureSocialDatabase = Play.current.configuration.getString("secureSocialDatabaseName")

  lazy val db: DB = ReactiveMongoPlugin.db

//  lazy val db: DB = {
//    val rootDB = ReactiveMongoPlugin.db
//    secureSocialDatabase.map(rootDB.sibling(_)).getOrElse(rootDB)
//  }
}

Disable custom database for SecureSocial.


package org.refptr.iscala

import org.zeromq.ZMQ

class Sockets(profile: Profile) {
    val ctx = ZMQ.context(1)

    val publish = ctx.socket(ZMQ.PUB)
    val raw_input = ctx.socket(ZMQ.ROUTER)
    val requests = ctx.socket(ZMQ.ROUTER)
    val control = ctx.socket(ZMQ.ROUTER)
    val heartbeat = ctx.socket(ZMQ.REP)

    private def toURI(port: Int) =
        s"${profile.transport}://${profile.ip}:$port"

    publish.bind(toURI(profile.iopub_port))
    requests.bind(toURI(profile.shell_port))
    control.bind(toURI(profile.control_port))
    raw_input.bind(toURI(profile.stdin_port))
    heartbeat.bind(toURI(profile.hb_port))

    def terminate() {
        publish.close()
        raw_input.close()
        requests.close()
        control.close()
        heartbeat.close()

        ctx.term()
    }
}

package org.refptr.iscala

import org.zeromq.ZMQ

class Sockets(profile: Profile) {
    val ctx = ZMQ.context(1)

    val publish = ctx.socket(ZMQ.PUB)
    val requests = ctx.socket(ZMQ.ROUTER)
    val control = ctx.socket(ZMQ.ROUTER)
    val stdin = ctx.socket(ZMQ.ROUTER)
    val heartbeat = ctx.socket(ZMQ.REP)

    private def toURI(port: Int) =
        s"${profile.transport}://${profile.ip}:$port"

    publish.bind(toURI(profile.iopub_port))
    requests.bind(toURI(profile.shell_port))
    control.bind(toURI(profile.control_port))
    stdin.bind(toURI(profile.stdin_port))
    heartbeat.bind(toURI(profile.hb_port))

    def terminate() {
        publish.close()
        requests.close()
        control.close()
        stdin.close()
        heartbeat.close()

        ctx.term()
    }
}

Rename raw_input socket to stdin

Rename raw_input socket to stdin


package views.vrm_retention

import helpers.UiSpec
import helpers.tags.UiTag
import helpers.vrm_retention.CookieFactoryForUISpecs
import helpers.webbrowser.TestHarness
import org.openqa.selenium.WebDriver
import pages.vrm_retention.BeforeYouStartPage.startNow
import pages.vrm_retention.{BeforeYouStartPage, BeforeYouStartPart2Page}

final class BeforeYouStartIntegrationSpec extends UiSpec with TestHarness {

  "go to page" should {

    "display the page" taggedAs UiTag in new WebBrowser {
      go to BeforeYouStartPage

      page.url should equal(BeforeYouStartPage.url)
    }

    "remove redundant cookies (needed for when a user exits the service and comes back)" taggedAs UiTag in new WebBrowser {
      def cacheSetup()(implicit webDriver: WebDriver) =
        CookieFactoryForUISpecs.setupBusinessDetails().
          businessChooseYourAddress().
          enterAddressManually().
          businessDetails().
          vehicleAndKeeperDetailsModel()

      go to BeforeYouStartPage
      cacheSetup()
      go to BeforeYouStartPage

      // Verify the cookies identified by the full set of cache keys have been removed
      RelatedCacheKeys.RetainSet.foreach(cacheKey => webDriver.manage().getCookieNamed(cacheKey) should equal(null))
    }
  }

  "startNow button" should {

    "go to next page" taggedAs UiTag in new WebBrowser {
      go to BeforeYouStartPage

      click on startNow

      page.url should equal(BeforeYouStartPart2Page.url)
    }
  }
}

package views.vrm_retention

import helpers.UiSpec
import helpers.tags.UiTag
import helpers.vrm_retention.CookieFactoryForUISpecs
import helpers.webbrowser.TestHarness
import org.openqa.selenium.WebDriver
import pages.vrm_retention.BeforeYouStartPage.startNow
import pages.vrm_retention.{VehicleLookupPage, BeforeYouStartPage, BeforeYouStartPart2Page}

final class BeforeYouStartIntegrationSpec extends UiSpec with TestHarness {

  "go to page" should {

    "display the page" taggedAs UiTag in new WebBrowser {
      go to BeforeYouStartPage

      page.url should equal(BeforeYouStartPage.url)
    }

    "remove redundant cookies (needed for when a user exits the service and comes back)" taggedAs UiTag in new WebBrowser {
      def cacheSetup()(implicit webDriver: WebDriver) =
        CookieFactoryForUISpecs.setupBusinessDetails().
          businessChooseYourAddress().
          enterAddressManually().
          businessDetails().
          vehicleAndKeeperDetailsModel()

      go to BeforeYouStartPage
      cacheSetup()
      go to BeforeYouStartPage

      // Verify the cookies identified by the full set of cache keys have been removed
      RelatedCacheKeys.RetainSet.foreach(cacheKey => webDriver.manage().getCookieNamed(cacheKey) should equal(null))
    }
  }

  "startNow button" should {

    "go to next page" taggedAs UiTag in new WebBrowser {
      go to BeforeYouStartPage

      click on startNow

      page.url should equal(VehicleLookupPage.url)
    }
  }
}

Fix broken test now beforeYouStart2 isn't linked to


package ignition.core.cache

import akka.actor.ActorSystem
import ignition.core.cache.ExpiringMultiLevelCache.TimestampedValue
import org.scalatest.{FlatSpec, Matchers}
import spray.caching.ExpiringLruLocalCache

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}

class ExpiringMultipleLevelCacheSpec extends FlatSpec with Matchers {
  case class Data(s: String)
  implicit val scheduler = ActorSystem().scheduler

  "ExpiringMultipleLevelCache" should "calculate a value on cache miss and return it" in {
    val local = new ExpiringLruLocalCache[TimestampedValue[Data]](100)
    val cache = ExpiringMultiLevelCache[Data](1.minute, Option(local))
    Await.result(cache("key", () => Future.successful(Data("success"))), 1.minute) shouldBe Data("success")
  }

  it should "calculate a value on cache miss and return a failed future of the calculation" in {
    val local = new ExpiringLruLocalCache[TimestampedValue[Data]](100)
    val cache = ExpiringMultiLevelCache[Data](1.minute, Option(local))

    class MyException(s: String) extends Exception(s)

    intercept[MyException ] {
      Await.result(cache("key", () => Future.failed(new MyException("some failure"))), 1.minute)
    }
  }
}

package ignition.core.cache

import akka.actor.ActorSystem
import ignition.core.cache.ExpiringMultiLevelCache.TimestampedValue
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{FlatSpec, Matchers}
import spray.caching.ExpiringLruLocalCache

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}

class ExpiringMultipleLevelCacheSpec extends FlatSpec with Matchers with ScalaFutures {
  case class Data(s: String)
  implicit val scheduler = ActorSystem().scheduler

  "ExpiringMultipleLevelCache" should "calculate a value on cache miss and return it" in {
    val local = new ExpiringLruLocalCache[TimestampedValue[Data]](100)
    val cache = ExpiringMultiLevelCache[Data](1.minute, Option(local))
    Await.result(cache("key", () => Future.successful(Data("success"))), 1.minute) shouldBe Data("success")
  }

  it should "calculate a value on cache miss and return a failed future of the calculation" in {
    val local = new ExpiringLruLocalCache[TimestampedValue[Data]](100)
    val cache = ExpiringMultiLevelCache[Data](1.minute, Option(local))

    class MyException(s: String) extends Exception(s)

    val eventualCache = cache("key", () => Future.failed(new MyException("some failure")))
    whenReady(eventualCache.failed) { failure =>
      failure shouldBe a [MyException]
    }
  }
}

Fix weird await on test

Fix weird await on test


/*
 * Copyright 2009-2010 LinkedIn, Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.linkedin.norbert.network.netty

import com.google.protobuf.Message
import java.util.UUID

case class Request(message: Message, responseCallback: (Either[Throwable, Message]) => Unit) {
  val id = UUID.randomUUID
  val timestamp = System.currentTimeMillis
}

/*
 * Copyright 2009-2010 LinkedIn, Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.linkedin.norbert.network.netty

import com.google.protobuf.Message
import java.util.UUID

object Request {
  def apply(message: Message, responseCallback: (Either[Throwable, Message]) => Unit): Request = {
    Request(UUID.randomUUID, message, System.currentTimeMillis, responseCallback)
  }
}

case class Request(id: UUID, message: Message, timestamp: Long, responseCallback: (Either[Throwable, Message]) => Unit)

Refactor so toString is more informative


package cpup.mc.lib.module

import cpup.mc.lib.ModLifecycleHandler
import cpw.mods.fml.common.event.{FMLServerStartingEvent, FMLPostInitializationEvent, FMLInitializationEvent, FMLPreInitializationEvent}
import cpup.lib.module.Module

trait ModModule[I <: ModLifecycleHandler] extends Module[I] with ModLifecycleHandler {
	override def preInit(e: FMLPreInitializationEvent) { get.preInit(e) }
	override def init(e: FMLInitializationEvent) { get.init(e) }
	override def postInit(e: FMLPostInitializationEvent) { get.postInit(e) }

	override def serverStarting(e: FMLServerStartingEvent) { get.serverStarting(e) }
}

Remove a newline at the end of a file

Remove a newline at the end of a file


package lib

import java.io.FileOutputStream
import java.util.zip.{ZipEntry, ZipOutputStream}
import com.bryzek.apidoc.generator.v0.models.File

object Zipfile {

  private[this] val UTF8 = "UTF-8"

  def create(dirName: String, files: Seq[File]): java.io.File = {
    val path = java.io.File.createTempFile(dirName, ".zip")
    createForFile(path, files, prefix = dirName + "/")
    path
  }

  private def createForFile(
    zip: java.io.File,
    files: Seq[File],
    prefix: String = ""
  ) {
    val zipOutputStream = new ZipOutputStream(new FileOutputStream(zip))
    files.foreach { f =>
      zipOutputStream.putNextEntry(new ZipEntry(s"$prefix${f.name}"))
      zipOutputStream.write(f.contents.getBytes(UTF8))
      zipOutputStream.closeEntry
    }
    zipOutputStream.close()
  }

}

package lib

import java.io.FileOutputStream
import java.util.zip.{ZipEntry, ZipOutputStream}
import com.bryzek.apidoc.generator.v0.models.File

object Zipfile {

  private[this] val UTF8 = "UTF-8"

  def create(dirName: String, files: Seq[File]): java.io.File = {
    val path = java.io.File.createTempFile(dirName, ".zip")
    createForFile(path, files, prefix = dirName + "/")
    path
  }

  private def createForFile(
    zip: java.io.File,
    files: Seq[File],
    prefix: String = ""
  ) {
    val zipOutputStream = new ZipOutputStream(new FileOutputStream(zip))
    files.foreach { f =>
      val path = prefix + f.dir.fold("")(_ + "/")
      zipOutputStream.putNextEntry(new ZipEntry(s"$path${f.name}"))
      zipOutputStream.write(f.contents.getBytes(UTF8))
      zipOutputStream.closeEntry
    }
    zipOutputStream.close()
  }

}

Add file directory into zip

Add file directory into zip


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

crossScalaVersions := Seq("2.11.8")

version := "0.1.3"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.1",
      "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.8"

crossScalaVersions := Seq("2.11.8")

version := "0.1.4"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.1",
      "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")
  }
}

autocommit: Update configuration to record version 0.1.4


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

crossScalaVersions := Seq("2.11.8")

version := "0.2.15"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      filters,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.5",
      "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.8"

crossScalaVersions := Seq("2.11.8")

version := "0.2.16"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      filters,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.5",
      "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")
  }
}

autocommit: Update configuration to record version 0.2.16


name := "lib-reference-scala"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.6"

crossScalaVersions := Seq("2.12.6", "2.11.12", "2.10.6")

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.0.5" % 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.81"

name := "lib-reference-scala"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.6"

crossScalaVersions := Seq("2.12.6", "2.11.12", "2.10.6")

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.0.5" % 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.82"

autocommit: Update configuration to record version 0.1.82


name := "hadoop-aws"

organization := "io.grhodes"

version := "git describe --tags --dirty --always".!!.stripPrefix("v").trim

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
  "com.amazonaws" % "aws-java-sdk-s3" % "1.10.68",
  "com.fasterxml.jackson.core" % "jackson-databind" % "2.2.3",
  "com.fasterxml.jackson.core" % "jackson-annotations" % "2.2.3",
  "org.apache.hadoop" % "hadoop-common" % "2.7.2" % Configurations.Provided
)

name := "hadoop-aws"

organization := "io.grhodes"

version := "git describe --tags --dirty --always".!!.stripPrefix("v").trim

scalaVersion := "2.11.8"

licenses += ("Apache-2.0", url("http://opensource.org/licenses/apache-2.0"))

libraryDependencies ++= Seq(
  "com.amazonaws" % "aws-java-sdk-s3" % "1.10.68",
  "com.fasterxml.jackson.core" % "jackson-databind" % "2.2.3",
  "com.fasterxml.jackson.core" % "jackson-annotations" % "2.2.3",
  "org.apache.hadoop" % "hadoop-common" % "2.7.2" % Configurations.Provided
)

Add correct licence for bintray

Add correct licence for bintray


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-lint"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.49"

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.50"

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")
  }
}

autocommit: Update configuration to record version 0.0.50


package dbrary

import play.api.{Application,Plugin,Configuration}
import com.github.mauricio.async.db

class PostgresAsyncPlugin(app : Application) extends Plugin {
  lazy val pool = {
    val config = app.configuration.getConfig("db.default").getOrElse(Configuration.empty)
    new db.pool.ConnectionPool(Connection.factory(config),
      db.pool.PoolConfiguration(
        config.getInt("max").getOrElse(16),
        config.getMilliseconds("idle").getOrElse(600000),
        config.getInt("queue").getOrElse(8)
      ))
  }

  override def onStop() {
    pool.close
  }
}

package dbrary

import play.api.{Application,Plugin,Configuration}
import com.github.mauricio.async.db

class PostgresAsyncPlugin(app : Application) extends Plugin {
  lazy val pool = {
    val config = app.configuration.getConfig("db.default").getOrElse(Configuration.empty)
    new db.pool.ConnectionPool(Connection.factory(config),
      db.pool.PoolConfiguration(
        config.getInt("max").getOrElse(16),
        config.getMilliseconds("idle").getOrElse(600000),
        config.getInt("queue").getOrElse(16)
      ))
  }

  override def onStop() {
    pool.close
  }
}

Increase default DB queue size

Increase default DB queue size

See #2237