/*
 * Copyright 2022 Typelevel
 *
 * 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 org.typelevel.sbt

import sbt._
import scalafix.sbt.ScalafixPlugin

import Keys._
import ScalafixPlugin.autoImport._

object TypelevelScalafixPlugin extends AutoPlugin {

  override def requires = ScalafixPlugin

  override def trigger = allRequirements

  override def buildSettings = Seq[Setting[_]](
    semanticdbEnabled := true,
    semanticdbVersion := scalafixSemanticdb.revision,
    SettingKey[Boolean]("tlCiScalafixCheck") := true
  )
}

/*
 * Copyright 2022 Typelevel
 *
 * 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 org.typelevel.sbt

import sbt._
import scalafix.sbt.ScalafixPlugin

import Keys._
import ScalafixPlugin.autoImport._

object TypelevelScalafixPlugin extends AutoPlugin {

  override def requires = ScalafixPlugin

  override def trigger = allRequirements

  object autoImport {
    val tlTypelevelScalafixVersion = settingKey[String](
      "The version of typelevel-scalafix to add to the scalafix dependency classpath."
    )
  }

  import autoImport._

  override def buildSettings = Seq[Setting[_]](
    semanticdbEnabled := true,
    semanticdbVersion := scalafixSemanticdb.revision,
    SettingKey[Boolean]("tlCiScalafixCheck") := true,
    tlTypelevelScalafixVersion := "0.1.1",
    scalafixDependencies ++= Seq(
      "org.typelevel" %% "typelevel-scalafix" % tlTypelevelScalafixVersion.value
    )
  )
}

Add typelevel-scalafix to the sbt-typelevel-scalafix dependencies


package com.earldouglas.xwp

import sbt._, Keys._

object WarPlugin extends AutoPlugin {
  import Keys.{`package` => pkg}

  override def requires = WebappPlugin

  override def trigger = allRequirements

  override lazy val projectSettings =
    Defaults.packageTaskSettings(pkg, WebappPlugin.autoImport.webappPrepare) ++
      Seq(artifact in pkg := Artifact(moduleName.value, "war", "war"))
}

package com.earldouglas.xwp

import sbt._, Keys._

object WarPlugin extends AutoPlugin {
  import Keys.{`package` => pkg}

  override def requires = WebappPlugin

  override def trigger = allRequirements

  override lazy val projectSettings =
    Defaults.packageTaskSettings(pkg, WebappPlugin.autoImport.webappPrepare) ++
      Seq(artifact in pkg := Artifact(moduleName.value, "war", "war")) ++
      addArtifact(artifact in (Compile, pkg), pkg in Compile)

}

Add the .war file to what gets published

Fixes #270


package hmda.api.http

import akka.event.{LoggingAdapter, NoLogging}
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.{MustMatchers, WordSpec}

import scala.concurrent.ExecutionContext

class BaseHttpApiSpec
    extends WordSpec
    with MustMatchers
    with ScalatestRouteTest
    with BaseHttpApi {
  override val log: LoggingAdapter = NoLogging
  val ec: ExecutionContext = system.dispatcher

  "Http API Service" must {
    "return OK for GET requests to the root path" in {
      Get() ~> routes("hmda-public-api") ~> check {
        response.status mustBe StatusCodes.OK
      }
    }
  }
}

package hmda.api.http

import akka.event.{LoggingAdapter, NoLogging}
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.{HttpEncodings, `Accept-Encoding`}
import akka.http.scaladsl.model.headers.HttpEncodings._
import akka.http.scaladsl.testkit.ScalatestRouteTest
import hmda.api.http.model.common.HmdaServiceStatus
import org.scalatest.{MustMatchers, WordSpec}
import io.circe.generic.auto._
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport._

import scala.concurrent.ExecutionContext

class BaseHttpApiSpec
    extends WordSpec
    with MustMatchers
    with ScalatestRouteTest
    with BaseHttpApi {
  override val log: LoggingAdapter = NoLogging
  val ec: ExecutionContext = system.dispatcher

  "Http API Service" must {
    "return OK for GET requests to the root path" in {
      Get() ~> routes("hmda-public-api") ~> check {
        response.status mustBe StatusCodes.OK
        val serviceStatus = responseAs[HmdaServiceStatus]
        serviceStatus.service mustBe "hmda-public-api"
        serviceStatus.status mustBe "OK"
      }
    }

    "use requested encoding for root path" in {
      Get().addHeader(`Accept-Encoding`(gzip)) ~> routes("hmda-public-api") ~> check {
        response.encoding mustBe HttpEncodings.gzip
      }
    }
  }
}

Complete test for root path

Complete test for root path


package uk.ac.wellcome.platform.transformer.sierra.transformers.sierra.subjects

import uk.ac.wellcome.models.work.internal.{MaybeDisplayable, Organisation, Subject}
import uk.ac.wellcome.platform.transformer.sierra.source.{SierraBibData, VarField}
import uk.ac.wellcome.platform.transformer.sierra.transformers.sierra.MarcUtils

trait SierraOrganisationSubjects extends MarcUtils {

  // Populate wwork:subject
  //
  // Use MARC field "610".
  //
  // *  Populate the platform "label" with the concatenated values of
  //    subfields a, b, c, d and e.
  //
  def getSubjectsWithOrganisation(bibData: SierraBibData): List[Subject[MaybeDisplayable[Organisation]]] =
    getMatchingVarFields(bibData, marcTag = "610").map { varField =>
      val label = createLabel(varField)

      Subject(
        label = label,
        concepts = List()
      )
    }

  private def createLabel(varField: VarField): String =
    varField
      .subfields
      .filter { vf =>
        vf.tag == "a" || vf.tag == "b" || vf.tag == "c" || vf.tag == "d" || vf.tag == "e"
      }
      .map { _.content }
      .mkString(" ")
}

package uk.ac.wellcome.platform.transformer.sierra.transformers.sierra.subjects

import uk.ac.wellcome.models.work.internal.{MaybeDisplayable, Organisation, Subject, Unidentifiable}
import uk.ac.wellcome.platform.transformer.sierra.source.{SierraBibData, VarField}
import uk.ac.wellcome.platform.transformer.sierra.transformers.sierra.MarcUtils

trait SierraOrganisationSubjects extends MarcUtils {

  // Populate wwork:subject
  //
  // Use MARC field "610".
  //
  // *  Populate the platform "label" with the concatenated values of
  //    subfields a, b, c, d and e.
  //
  def getSubjectsWithOrganisation(bibData: SierraBibData): List[Subject[MaybeDisplayable[Organisation]]] =
    getMatchingVarFields(bibData, marcTag = "610").map { varField =>
      val label = createLabel(varField, subfieldTags = List("a", "b", "c", "d", "e"))

      val organisation = createOrganisation(varField)

      Subject(
        label = label,
        concepts = List(organisation)
      )
    }

  private def createOrganisation(varField: VarField): MaybeDisplayable[Organisation] =
    Unidentifiable(
      Organisation(label = "ACME Corp")
    )

  /** Given a varField and a list of subfield tags, create a label by
    * concatenating the contents of every subfield with one of the given tags.
    *
    * The order is the same as that in the original MARC.
    *
    */
  private def createLabel(varField: VarField, subfieldTags: List[String]): String =
    varField
      .subfields
      .filter { vf => subfieldTags.contains(vf.tag) }
      .map { _.content }
      .mkString(" ")
}

Create the first Organisation concept with a placeholder label


organization := "io.reactivex"

name := "rxscala"

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

lazy val examples = project in file("examples") dependsOn root

scalacOptions := Seq("-feature", "-unchecked", "-deprecation", "-encoding", "utf8")

scalaVersion := "2.11.2"

crossScalaVersions := Seq("2.10.4", "2.11.2")

libraryDependencies ++= Seq(
  "io.reactivex" % "rxjava" % "1.0.0-rc.3",
  "org.mockito" % "mockito-core" % "1.9.5" % "test",
  "junit" % "junit" % "4.11" % "test",
  "org.scalatest" %% "scalatest" % "2.2.2" % "test")

organization := "io.reactivex"

name := "rxscala"

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

lazy val examples = project in file("examples") dependsOn (root % "test->test;compile->compile")

scalacOptions in ThisBuild := Seq("-feature", "-unchecked", "-deprecation", "-encoding", "utf8")

scalaVersion in ThisBuild := "2.11.2"

crossScalaVersions in ThisBuild := Seq("2.10.4", "2.11.2")

libraryDependencies ++= Seq(
  "io.reactivex" % "rxjava" % "1.0.0-rc.3",
  "org.mockito" % "mockito-core" % "1.9.5" % "test",
  "junit" % "junit" % "4.11" % "test",
  "org.scalatest" %% "scalatest" % "2.2.2" % "test")

Fix basic examples project setup.

Fix basic examples project setup.


import sbt._
import Keys._

import sbtassembly.Plugin.AssemblyKeys._
import sbtassembly.Plugin.MergeStrategy
import sbtassembly.AssemblyUtils._
import com.socrata.cloudbeessbt.SocrataCloudbeesSbt.SocrataSbtKeys._

object SodaFountainJetty {
  lazy val settings: Seq[Setting[_]] = BuildSettings.projectSettings(assembly = true) ++ Seq(
    libraryDependencies ++= Seq(
      "com.socrata" %% "socrata-http-jetty" % "2.3.0",
      "com.socrata" %% "socrata-http-curator-broker" % "2.3.0",
      "io.dropwizard.metrics" % "metrics-jetty9"   % "3.1.0",
      "io.dropwizard.metrics" % "metrics-graphite"   % "3.1.0"
    ),
    dependenciesSnippet :=
      <xml.group>
        <exclude org="commons-logging" module="commons-logging"/>
        <exclude org="commons-logging" module="commons-logging-api"/>
      </xml.group>
    ,
    mainClass := Some("com.socrata.soda.server.SodaFountainJetty"),
    mergeStrategy in assembly <<= (mergeStrategy in assembly) { old =>
      {
        case "about.html" => MergeStrategy.rename
        case s if s.startsWith("scala/reflect/api/") =>
          MergeStrategy.first // I hope this works...
        case x => old(x)
      }
    }
  )
}

import sbt._
import Keys._

import sbtassembly.Plugin.AssemblyKeys._
import sbtassembly.Plugin.MergeStrategy
import sbtassembly.AssemblyUtils._
import com.socrata.cloudbeessbt.SocrataCloudbeesSbt.SocrataSbtKeys._

object SodaFountainJetty {
  lazy val settings: Seq[Setting[_]] = BuildSettings.projectSettings(assembly = true) ++ Seq(
    libraryDependencies ++= Seq(
      "com.socrata" %% "socrata-http-jetty" % "[2.0.0,3.0.0)",
      "com.socrata" %% "socrata-http-curator-broker" % "[2.0.0,3.0.0)",
      "io.dropwizard.metrics" % "metrics-jetty9"   % "3.1.0",
      "io.dropwizard.metrics" % "metrics-graphite"   % "3.1.0"
    ),
    dependenciesSnippet :=
      <xml.group>
        <exclude org="commons-logging" module="commons-logging"/>
        <exclude org="commons-logging" module="commons-logging-api"/>
      </xml.group>
    ,
    mainClass := Some("com.socrata.soda.server.SodaFountainJetty"),
    mergeStrategy in assembly <<= (mergeStrategy in assembly) { old =>
      {
        case "about.html" => MergeStrategy.rename
        case s if s.startsWith("scala/reflect/api/") =>
          MergeStrategy.first // I hope this works...
        case x => old(x)
      }
    }
  )
}

Revert "Don't use snapshot versions"

Revert "Don't use snapshot versions"

This reverts commit fc131d13dd59821426e63e8f6796fdc767f88493.
(For now, for some weird reason the upgrade causes missing Scala.Symbol test failures)


package models.core

/**
 * The Class WithId.
 *
 * @author Nguyen Duc Dung
 * @since 2/20/14 1:12 AM
 *
 */
trait WithId[Id] {

  val id: Option[Id]

}

package models.core

import scalaz._
import Scalaz._

/**
 * The Class WithId.
 *
 * @author Nguyen Duc Dung
 * @since 2/20/14 1:12 AM
 *
 */
trait WithId[Id] {

  val id: Option[Id]

  def getId = id err "The id can't not be empty, something might wrong!"
}

Add convenient method to get model id.

Add convenient method to get model id.


// scalac: -Xfatal-warnings -release 8
// javaVersion: 9+

class C {
  def f = new java.time.Instant
}
object Test extends App {
  println(new C().f)
}

// scalac: -Xfatal-warnings -release:8
// javaVersion: 9+

class C {
  def f = new java.time.Instant
}
object Test extends App {
  println(new C().f)
}

Fix compiler flag syntax in test file

Fix compiler flag syntax in test file


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

import ch.usi.inf.l3.sana
import sana.tiny
import sana.ooj
import sana.calcj

import tiny.types.Type
import ooj.types.NullType
import calcj.ast.Constant

case object NullConstant extends Constant {
  type Value = Null

  val value: Null = ???

  val tpe: Type = NullType
}

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

import ch.usi.inf.l3.sana
import sana.tiny
import sana.ooj
import sana.calcj

import tiny.types.Type
import ooj.types.NullType
import calcj.ast.Constant

case object NullConstant extends Constant {
  type Value = Null

  def value: Null = ???

  val tpe: Type = NullType
}

Change value field to def

Change value field to def


package io.continuum.bokeh

trait FillProps { self: HasFields =>
    object fill_color extends Vectorized[Color](Color.Gray)
    object fill_alpha extends Field[Percent](100%%)
}

trait LineProps { self: HasFields =>
    object line_color extends Vectorized[Color](Color.Black)
    object line_width extends Field[Double](1.0) with NonNegative
    object line_alpha extends Field[Percent](100%%)
    object line_join extends Field[LineJoin]
    object line_cap extends Field[LineCap]
    object line_dash extends Field[LineDash]
    object line_dash_offset extends Field[Int](0)
}

trait TextProps { self: HasFields =>
    object text_font extends Field[String]
    object text_font_size extends Field[String]("10pt")
    object text_font_style extends Field[FontStyle]
    object text_color extends Field[Color](Color.Black)
    object text_alpha extends Field[Percent](100%%)
    object text_align extends Field[TextAlign]
    object text_baseline extends Field[TextBaseline]
}

package io.continuum.bokeh

trait FillProps { self: HasFields =>
    object fill_color extends Vectorized[Color](Color.Gray)
    object fill_alpha extends Field[Percent]
}

trait LineProps { self: HasFields =>
    object line_color extends Vectorized[Color](Color.Black)
    object line_width extends Field[Double](1.0)
    object line_alpha extends Field[Percent]
    object line_join extends Field[LineJoin]
    object line_cap extends Field[LineCap]
    object line_dash extends Field[LineDash]
    object line_dash_offset extends Field[Int]
}

trait TextProps { self: HasFields =>
    object text_font extends Field[String]
    object text_font_size extends Field[String]("10pt")
    object text_font_style extends Field[FontStyle]
    object text_color extends Field[Color](Color.Black)
    object text_alpha extends Field[Percent]
    object text_align extends Field[TextAlign]
    object text_baseline extends Field[TextBaseline]
}

Remove unneeded defaults from mixins

Remove unneeded defaults from mixins


package com.gu.scanamo.update

import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Arbitrary._
import com.gu.scanamo.syntax._

class UpdateExpressionTest extends org.scalatest.FunSpec
  with org.scalatest.Matchers
  with org.scalatest.prop.Checkers {

  implicit lazy val arbSymbol: Arbitrary[Symbol] = Arbitrary(Gen.alphaNumStr.map(Symbol(_)))

  def leaf: Gen[UpdateExpression] =
    for {
      s <- arbitrary[Symbol]
      i <- arbitrary[Int]
      u <- Gen.oneOf(List(set(s -> i), add(s -> i), remove(s)))
    } yield u

  def genNode(level: Int): Gen[UpdateExpression] = for {
    left <- genTree(level)
    right <- genTree(level)
  } yield left and right

  def genTree(level: Int): Gen[UpdateExpression] =
    if (level >= 100) leaf else {
      Gen.oneOf(leaf, genNode(level + 1))
    }
  implicit lazy val update: Arbitrary[UpdateExpression] = Arbitrary(genTree(0))

  it("should have all attribute keys in the expression") {
    check {
      (ue: UpdateExpression) =>
        ue.attributeValues.keys.forall(s => {
          ue.expression.contains(s)
        })
    }
  }

}

package com.gu.scanamo.update

import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Arbitrary._
import com.gu.scanamo.syntax._

class UpdateExpressionTest extends org.scalatest.FunSpec
  with org.scalatest.Matchers
  with org.scalatest.prop.Checkers {

  implicit lazy val arbSymbol: Arbitrary[Symbol] = Arbitrary(Gen.alphaNumStr.map(Symbol(_)))

  def leaf: Gen[UpdateExpression] =
    for {
      s <- arbitrary[Symbol]
      i <- arbitrary[Int]
      si <- arbitrary[Set[Int]]
      l <- arbitrary[List[String]]
      u <- Gen.oneOf(List(set(s -> i), add(s -> i), remove(s), delete(s -> si), append(s -> l), prepend(s -> l)))
    } yield u

  def genNode(level: Int): Gen[UpdateExpression] = for {
    left <- genTree(level)
    right <- genTree(level)
  } yield left and right

  def genTree(level: Int): Gen[UpdateExpression] =
    if (level >= 100) leaf else {
      Gen.oneOf(leaf, genNode(level + 1))
    }
  implicit lazy val update: Arbitrary[UpdateExpression] = Arbitrary(genTree(0))

  it("should have all value placeholders in the expression") {
    check {
      (ue: UpdateExpression) =>
        ue.attributeValues.keys.forall(s => {
          ue.expression.contains(s)
        })
    }
  }

  it("should have all name placeholders in the expression") {
    check {
      (ue: UpdateExpression) =>
        ue.attributeNames.keys.forall(s => {
          ue.expression.contains(s)
        })
    }
  }

}

Improve tests of update expression construction


/*
 * Copyright (C) 2012 Romain Reuillon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.ui.console

import java.io.File
import org.openmole.core.model.task.PluginSet
import org.openmole.core.model.mole.ExecutionContext
import org.openmole.core.model.data.Context

class Implicits(
    implicit val plugins: PluginSet) {
  implicit def stringToFile(path: String) = new File(path)
  implicit lazy val executionContext = ExecutionContext.local
  implicit lazy val implicits = Context.empty
}

/*
 * Copyright (C) 2012 Romain Reuillon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.ui.console

import java.io.File
import org.openmole.core.model.task.PluginSet
import org.openmole.core.model.mole.ExecutionContext
import org.openmole.core.model.data.Context

class Implicits(
    implicit val plugins: PluginSet) {
  implicit def stringToFile(path: String) = new File(path)
  implicit lazy val executionContext = ExecutionContext.local
  implicit lazy val implicits = Context.empty
  implicit def doubleToString(d: Double) = d.toString
  implicit def intToString(i: Int) = i.toString
  implicit def longToString(l: Long) = l.toString
}

Add implicit conversion to string for numeric types.


organization := "com.pulptunes"

name := "pulptunes-relay"

version := "2.0.0-SNAPSHOT"

scalaVersion := "2.12.1"

libraryDependencies ++= Seq(
  evolutions,
  ws,
  "com.typesafe.play" %% "play-slick" % "2.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
  "mysql" % "mysql-connector-java" % "5.1.36",
  "org.typelevel" %% "cats" % "0.4.1"
)

sources in (Compile, doc) := Seq.empty

publishArtifact in (Compile, packageDoc) := false

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

organization := "com.pulptunes"

name := "pulptunes-relay"

version := "2.0.0-SNAPSHOT"

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
  evolutions,
  ws,
  "com.typesafe.play" %% "play-slick" % "2.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
  "mysql" % "mysql-connector-java" % "5.1.36",
  "org.typelevel" %% "cats" % "0.4.1"
)

sources in (Compile, doc) := Seq.empty

publishArtifact in (Compile, packageDoc) := false

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

Revert "upgraded scala to v2.12.1"

Revert "upgraded scala to v2.12.1"

This reverts commit defcd34a0300dcfdb66305f5b3b181c1e585388c.


package com.codahale.jerkson.tests

import com.codahale.jerkson.Json._
import collection.mutable.ArrayBuffer
import java.io.ByteArrayInputStream
import com.codahale.simplespec.Spec

class StreamingSpec extends Spec {
  class `Parsing a stream of objects` {
    private val json = """[
      {"id":1, "name": "Coda"},
      {"id":2, "name": "Niki"},
      {"id":3, "name": "Biscuit"},
      {"id":4, "name": "Louie"}
    ]"""

    def `fires a callback for each stream element` = {
      val input = new ByteArrayInputStream(json.getBytes)

      val people = new ArrayBuffer[CaseClass]
      parseStreamOf[CaseClass](input) { p =>
        people += p
      }

      people.toSeq must beEqualTo(Seq(CaseClass(1, "Coda"),
                                      CaseClass(2, "Niki"),
                                      CaseClass(3, "Biscuit"),
                                      CaseClass(4, "Louie")))
    }

    def `returns an iterator of stream elements` = {
      val input = new ByteArrayInputStream(json.getBytes)

      val people = new ArrayBuffer[CaseClass]
      stream[CaseClass](input).toList must beEqualTo(List(CaseClass(1, "Coda"),
                                                       CaseClass(2, "Niki"),
                                                       CaseClass(3, "Biscuit"),
                                                       CaseClass(4, "Louie")))
    }
  }
}

package com.codahale.jerkson.tests

import com.codahale.jerkson.Json._
import collection.mutable.ArrayBuffer
import java.io.ByteArrayInputStream
import com.codahale.simplespec.Spec

class StreamingSpec extends Spec {
  class `Parsing a stream of objects` {
    private val json = """[
      {"id":1, "name": "Coda"},
      {"id":2, "name": "Niki"},
      {"id":3, "name": "Biscuit"},
      {"id":4, "name": "Louie"}
    ]"""

    def `fires a callback for each stream element` = {
      val input = new ByteArrayInputStream(json.getBytes)

      val people = new ArrayBuffer[CaseClass]
      parseStreamOf[CaseClass](input) { p =>
        people += p
      }

      people.toSeq must beEqualTo(Seq(CaseClass(1, "Coda"),
                                      CaseClass(2, "Niki"),
                                      CaseClass(3, "Biscuit"),
                                      CaseClass(4, "Louie")))
    }

    def `returns an iterator of stream elements` = {
      stream[CaseClass](new ByteArrayInputStream(json.getBytes)).toList must
        beEqualTo(CaseClass(1, "Coda") :: CaseClass(2, "Niki") ::
                  CaseClass(3, "Biscuit") :: CaseClass(4, "Louie") :: Nil)
    }
  }
}

Clean up test guts a bit.

Clean up test guts a bit.


package ch.usi.inf.l3.sana.tiny

import ch.usi.inf.l3.sana.tiny.core.{LanguageModule, CompilerInterface}
import source.{SourceReader, SourceFile}
import parsers.Parser
import ast.Tree
import debug.logger
import util._
import settings.SanaConfig
import types.Type
import errors._

trait CompilerApi[Input, Output] {

  def langName: String
  def langVersion: String
  type ConfigType <: SanaConfig
  def config: ConfigType
  def parser: Parser

  ErrorReporting.isTest = config.isTest

  def sourceReader: SourceReader

  def compile: Input => Output

  trait Language extends LanguageModule[Input, Output] {
    def init(): Unit
    def compiler: CompilerInterface
    def compile: Input => Output
  }

  protected def parse(file: String): Tree = {
    val source: SourceFile = sourceReader.readSource(file)
    parser.parse(source)
  }

  // def attach(units: List[global.CompilationUnit]):
  //     (Vector[Report], List[global.CompilationUnit]) = {
  //   compile(units)
  // }

  def start: Output
    // compile(parse(config.files.toList))
  // }
}

package ch.usi.inf.l3.sana.tiny

import ch.usi.inf.l3.sana.tiny.core.{LanguageModule, CompilerInterface}
import source.{SourceReader, SourceFile}
import parsers.Parser
import ast.Tree
import debug.logger
import util._
import settings.SanaConfig
import types.Type
import errors._

trait CompilerApi[Input, Output] {

  def langName: String
  def langVersion: String
  type ConfigType <: SanaConfig
  def config: ConfigType
  def parser: Parser

  ErrorReporting.isTest = config.isTest

  def sourceReader: SourceReader

  def compile: Input => Output

  trait Language extends LanguageModule[Input, Output] {
    def init(): Unit
    def codegen(tree: Tree): Unit = ()
    def compiler: CompilerInterface
    def compile: Input => Output
  }

  protected def parse(file: String): Tree = {
    val source: SourceFile = sourceReader.readSource(file)
    parser.parse(source)
  }

  // def attach(units: List[global.CompilationUnit]):
  //     (Vector[Report], List[global.CompilationUnit]) = {
  //   compile(units)
  // }

  def start: Output
    // compile(parse(config.files.toList))
  // }
}

Add a method for codege

Add a method for codege


package com.github.dkanellis.skyspark.scala.api.helpers

import com.github.dkanellis.skyspark.scala.api.algorithms.Point
import org.apache.spark.SparkContext

object TextFileToPointRdd {

  def convert(sparkContext: SparkContext, filePath: String, delimiter: String) = {
    sparkContext.textFile(filePath)
      .map(pointFromTextLine(_, delimiter))
  }

  private def pointFromTextLine(textLine: String, delimiter: String) = {
    new Point(
      textLine.trim
        .split(delimiter)
        .map(_.toDouble): _*)
  }
}

package com.github.dkanellis.skyspark.scala.api.helpers

import com.github.dkanellis.skyspark.scala.api.algorithms.Point
import org.apache.spark.SparkContext

object TextFileToPointRdd {

  def convert(sparkContext: SparkContext, filePath: String, delimiter: String) = {
    sparkContext.textFile(filePath)
      .map(pointFromTextLine(_, delimiter))
  }

  private def pointFromTextLine(textLine: String, delimiter: String) = {
    val numberArray = textLine
      .trim
      .split(delimiter)
      .map(_.toDouble)
    new Point(numberArray: _*)
  }
}

Add numbers to separate variable

Add numbers to separate variable


name := """Thunderbit"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.6"

resolvers += "ylemoigne-maven" at "https://dl.bintray.com/ylemoigne/maven/"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  "org.mongodb" % "mongodb-driver-async" % "3.2.0",
  "fr.javatic.mongo" % "mongo-jackson-codec" % "3.2.0__0.3",
  "junit" % "junit" % "4.11",
  "com.amazonaws" % "aws-java-sdk-s3" % "1.10.44",
  "org.webjars" %% "webjars-play" % "2.4.0-2",
  "org.webjars" % "requirejs" % "2.1.22",
  "org.webjars" % "jquery" % "1.11.1",
  "org.webjars" % "bootstrap" % "3.3.6",
  "be.objectify" %% "deadbolt-java" % "2.4.4"
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

name := """Thunderbit"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.6"

resolvers += "ylemoigne-maven" at "https://dl.bintray.com/ylemoigne/maven/"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  "org.mongodb" % "mongodb-driver-async" % "3.2.0",
  "fr.javatic.mongo" % "mongo-jackson-codec" % "3.2.0__0.3",
  "com.amazonaws" % "aws-java-sdk-s3" % "1.10.44",
  "org.webjars" %% "webjars-play" % "2.4.0-2",
  "org.webjars" % "requirejs" % "2.1.22",
  "org.webjars" % "jquery" % "1.11.1",
  "org.webjars" % "bootstrap" % "3.3.6",
  "be.objectify" %% "deadbolt-java" % "2.4.4"
)

libraryDependencies += "junit" % "junit" % "4.11" % Test

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

Set junit dependency to be only for Test configuration


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.5"

version := "0.1.67"

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

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.68


package spatutorial.client.components

import japgolly.scalajs.react.extra.router.RouterCtl
import japgolly.scalajs.react.vdom.prefix_<^._
import org.scalajs.dom.html
import spatutorial.client.SPAMain.Loc
import spatutorial.client.services.JSDateConversions.SDate
import spatutorial.client.services.SPACircuit

object Navbar {
  def apply(ctl: RouterCtl[Loc], page: Loc): ReactTagOf[html.Element] = {
    val airportConfigRCP = SPACircuit.connect(m => m.airportConfig)

    <.nav(^.className := "navbar navbar-inverse navbar-fixed-top",
      airportConfigRCP(airportConfigPotMP => {
        <.div(^.className := "container",
          airportConfigPotMP().renderReady(airportConfig =>
            <.span(^.className := "navbar-brand", s"DRT ${airportConfig.portCode} Live Spike"))
          ,
          <.div(^.className := "collapse navbar-collapse", MainMenu(ctl, page),
            <.ul(^.className := "nav navbar-nav navbar-right",
              <.li(StaffMovementsPopover("IS81", "IS81", SDate.now(), SDate.now().addHours(1), "bottom")()))))
      })
    )
  }
}

package spatutorial.client.components

import japgolly.scalajs.react.extra.router.RouterCtl
import japgolly.scalajs.react.vdom.prefix_<^._
import org.scalajs.dom.html
import spatutorial.client.SPAMain.Loc
import spatutorial.client.services.JSDateConversions.SDate
import spatutorial.client.services.SPACircuit

object Navbar {
  def apply(ctl: RouterCtl[Loc], page: Loc): ReactTagOf[html.Element] = {
    val airportConfigRCP = SPACircuit.connect(m => m.airportConfig)

    <.nav(^.className := "navbar navbar-inverse navbar-fixed-top",
      airportConfigRCP(airportConfigPotMP => {
        <.div(^.className := "container",
          airportConfigPotMP().renderReady(airportConfig =>
            <.span(^.className := "navbar-brand", s"DRT ${airportConfig.portCode} Live"))
          ,
          <.div(^.className := "collapse navbar-collapse", MainMenu(ctl, page),
            <.ul(^.className := "nav navbar-nav navbar-right",
              <.li(StaffMovementsPopover("IS81", "IS81", SDate.now(), SDate.now().addHours(1), "bottom")()))))
      })
    )
  }
}

Remove word spike from nav bar

Remove word spike from nav bar


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

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

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")

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

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.3")

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

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

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")

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

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.3")

Use https for fetching dependencies

Use https for fetching dependencies

See http://blog.ontoillogical.com/blog/2014/07/28/how-to-take-over-any-java-developer/


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

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

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.2")

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

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

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.3")

Update play version to 2.1.3

Update play version to 2.1.3


/*
Copyright (c) 2017 KAPSARC

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 org.economicsl.auctions.quotes

/** Base trait for all quote requests.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
sealed trait QuoteRequest

/** Base trait for all price quote requests.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
sealed trait PriceQuoteRequest extends QuoteRequest

/** Used by auction participants to request the current ask price quote.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
class AskPriceQuoteRequest extends PriceQuoteRequest

/** Used by auction participants to request the current bid price quote.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
class BidPriceQuoteRequest extends PriceQuoteRequest

/** Used by auction participants to request the current spread quote.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
class SpreadQuoteRequest extends PriceQuoteRequest

/*
Copyright (c) 2017 KAPSARC

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 org.economicsl.auctions.quotes

/** Base trait for all quote requests.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
sealed trait QuoteRequest

/** Base trait for all price quote requests.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
sealed trait PriceQuoteRequest extends QuoteRequest

/** Used by auction participants to request the current ask price quote.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
case object AskPriceQuoteRequest extends PriceQuoteRequest

/** Used by auction participants to request the current bid price quote.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
case object BidPriceQuoteRequest extends PriceQuoteRequest

/** Used by auction participants to request the current spread quote.
  *
  * @author davidrpugh
  * @since 0.1.0
  */
case object SpreadQuoteRequest extends PriceQuoteRequest

Use case objects to make requests serializable for use in remoting...


package hyperion

import akka.actor.Terminated
import akka.testkit.{EventFilter, TestProbe}
import hyperion.MessageDistributor.RegisterReceiver

class MessageDistributorSpec extends BaseAkkaSpec {
  "The MessageDistributor Actor" should {
    "forward messages it receives to all recipients" in {
      // Arrange
      val receiver = system.actorOf(MessageDistributor.props(), "forward-messages")
      val msg = "msg"
      val probe = TestProbe()

      // Act
      probe.send(receiver, RegisterReceiver)
      receiver ! msg

      // Assert
      probe.expectMsgAllOf(msg)
    }

    "stop forwarding messages once a recipient is stopped" in {
      // Arrange
      val receiver = system.actorOf(MessageDistributor.props(), "stop-forwarding")
      val msg = "msg"
      val probe = TestProbe()

      // Act
      probe.send(receiver, RegisterReceiver)
      system.stop(probe.ref)
      Thread.sleep(100)
      receiver ! msg

      // Assert
      probe.expectNoMsg()
    }
  }
}

package hyperion

import akka.testkit.TestProbe
import hyperion.MessageDistributor.RegisterReceiver
import scala.concurrent.duration.DurationInt

class MessageDistributorSpec extends BaseAkkaSpec {
  "The MessageDistributor Actor" should {
    "forward messages it receives to all recipients" in {
      // Arrange
      val receiver = system.actorOf(MessageDistributor.props(), "forward-messages")
      val msg = "msg"
      val probe = TestProbe()

      // Act
      probe.send(receiver, RegisterReceiver)
      receiver ! msg

      // Assert
      probe.expectMsgAllOf(msg)
    }

    "stop forwarding messages once a recipient is stopped" in {
      // Arrange
      val receiver = system.actorOf(MessageDistributor.props(), "stop-forwarding")
      val msg = "msg"
      val probe = TestProbe()

      // Act
      probe.send(receiver, RegisterReceiver)
      system.stop(probe.ref)
      Thread.sleep(100)
      receiver ! msg

      // Assert
      probe.expectNoMsg(250 millis)
    }
  }
}

Make this test run a bit faster

Make this test run a bit faster


package mesosphere.marathon
package api

import javax.servlet.http.HttpServletRequest

import mesosphere.marathon.plugin.http.HttpRequest
import mesosphere.marathon.stream.Implicits._

class RequestFacade(request: HttpServletRequest, path: String) extends HttpRequest {
  def this(request: HttpServletRequest) = this(request, request.getRequestURI)
  // Jersey will not allow calls to the request object from another thread
  // To circumvent that, we have to copy all data during creation
  val headers: Map[String, Seq[String]] = request.getHeaderNames.seq.map(header =>
    header.toLowerCase -> request.getHeaders(header).seq)(collection.breakOut)
  val cookies = request.getCookies
  val params = request.getParameterMap
  val remoteAddr = request.getRemoteAddr
  val remotePort = request.getRemotePort
  val localAddr = request.getLocalAddr
  val localPort = request.getLocalPort
  override def header(name: String): Seq[String] = headers.getOrElse(name.toLowerCase, Seq.empty)
  override def requestPath: String = path
  override def cookie(name: String): Option[String] = cookies.find(_.getName == name).map(_.getValue)
  override def queryParam(name: String): Seq[String] = Option(params.get(name)).map(_.to[Seq]).getOrElse(Seq.empty)
  override def method: String = request.getMethod
}

package mesosphere.marathon
package api

import javax.servlet.http.HttpServletRequest

import mesosphere.marathon.plugin.http.HttpRequest
import mesosphere.marathon.stream.Implicits._

class RequestFacade(request: HttpServletRequest, path: String) extends HttpRequest {
  def this(request: HttpServletRequest) = this(request, request.getRequestURI)
  // Jersey will not allow calls to the request object from another thread
  // To circumvent that, we have to copy all data during creation
  val headers: Map[String, Seq[String]] = request.getHeaderNames.seq.map(header =>
    header.toLowerCase -> request.getHeaders(header).seq)(collection.breakOut)
  val cookies = request.getCookies
  val params = request.getParameterMap
  val remoteAddr = request.getRemoteAddr
  val remotePort = request.getRemotePort
  val localAddr = request.getLocalAddr
  val localPort = request.getLocalPort
  override def header(name: String): Seq[String] = headers.getOrElse(name.toLowerCase, Seq.empty)
  override def requestPath: String = path
  override def cookie(name: String): Option[String] = cookies.find(_.getName == name).map(_.getValue)
  override def queryParam(name: String): Seq[String] = Option(params.get(name)).map(_.to[Seq]).getOrElse(Seq.empty)
  val method: String = request.getMethod
}

Make method a val instead of a def, since jersey rejects access outside of the calling thread

Test Plan: sbt test

Reviewers: jeschkies, zen-dog, jenkins, jasongilanfarr

Reviewed By: jeschkies, jenkins, jasongilanfarr

Subscribers: jasongilanfarr, marathon-dev

JIRA Issues: MARATHON-7252

Differential Revision: https://phabricator.mesosphere.com/D727


package ccf.session

import ccf.transport.{Request, Response}

case object Shutdown

trait Message {
  def send(s: Session): (Session, Option[Response])
  protected def send(s: Session, request: Request, channels: Set[ChannelId]) = {
    val nextSession = s.next(channels)
    val response = s.connection.send(request)
    (nextSession, response)
  }
}

case class Join(channelId: ChannelId) extends Message {
  def send(s: Session): (Session, Option[Response]) =
    if (!s.channels(channelId)) send(s, JoinRequest(s, channelId), s.channels + channelId) else (s, None)
}
case class Part(channelId: ChannelId) extends Message {
  def send(s: Session): (Session, Option[Response]) =
    if (s.channels(channelId)) send(s, PartRequest(s, channelId), s.channels - channelId) else (s, None)
}
case class InChannelMessage(requestType: String, channelId: ChannelId, content: Option[Any]) extends Message {
  def send(s: Session): (Session, Option[Response]) =
    if (s.channels(channelId)) send(s, InChannelRequest(s, requestType, channelId, content), s.channels) else (s, None)
}

package ccf.session

import ccf.transport.{Request, Response}

case object Shutdown

trait Message {
  def send(s: Session): (Session, Option[Response])
  protected def send(s: Session, request: Request, channels: Set[ChannelId]): (Session, Option[Response]) = {
    val nextSession = s.next(channels)
    val response = s.connection.send(request)
    (nextSession, response)
  }
}

case class Join(channelId: ChannelId) extends Message {
  def send(s: Session): (Session, Option[Response]) =
    if (!s.channels(channelId)) send(s, JoinRequest(s, channelId), s.channels + channelId) else (s, None)
}
case class Part(channelId: ChannelId) extends Message {
  def send(s: Session): (Session, Option[Response]) =
    if (s.channels(channelId)) send(s, PartRequest(s, channelId), s.channels - channelId) else (s, None)
}
case class InChannelMessage(requestType: String, channelId: ChannelId, content: Option[Any]) extends Message {
  def send(s: Session): (Session, Option[Response]) =
    if (s.channels(channelId)) send(s, InChannelRequest(s, requestType, channelId, content), s.channels) else (s, None)
}

Add explicit return type for clarity

session: Add explicit return type for clarity

Signed-off-by: Aki Saarinen <2c8035bb80cf98a391872dcbe797b269d759f6d9@reaktor.fi>


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.1",
  "org.http4s" %% "http4s-circe" % "0.21.1",
)

// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.3.7"

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.3",
  "org.http4s" %% "http4s-circe" % "0.21.3",
)

// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.3.7"

Update http4s-blaze-client, http4s-circe to 0.21.3


package com.example.http4s
package jetty

import org.http4s.server.jetty.JettyBuilder

/// code_ref: jetty_example
object JettyExample extends App {
  JettyBuilder
    .bindHttp(8080)
    .mountService(ExampleService.service, "/http4s")
    .run
    .awaitShutdown()
}
/// code_ref

package com.example.http4s
package jetty

import org.http4s.server.jetty.JettyBuilder

/// code_ref: jetty_example
object JettyExample extends App {
  JettyBuilder
    .bindHttp(8080)
    .mountService(ExampleService.service, "/http4s")
    .run
    .awaitShutdown()
}
/// end_code_ref

Fix code_ref tag in Jetty example.

Fix code_ref tag in Jetty example.


package org.http4s
package headers

import scala.concurrent.duration.FiniteDuration
import org.http4s.parser.HttpHeaderParser
import org.http4s.util.Writer

/**
 * Defined by http://tools.ietf.org/html/rfc6797
 */
object `Strict-Transport-Security` extends HeaderKey.Internal[`Strict-Transport-Security`] with HeaderKey.Singleton {
  def parse(s: String): ParseResult[`Strict-Transport-Security`] =
    HttpHeaderParser.STRICT_TRANSPORT_SECURITY(s)
}

case class `Strict-Transport-Security`(maxAge: FiniteDuration, includeSubDomains: Boolean = true, preload: Boolean = false) extends Header.Parsed {
  override def key: `Strict-Transport-Security`.type = `Strict-Transport-Security`
  override def renderValue(writer: Writer): writer.type = {
    writer << "max-age=" << maxAge.toSeconds
    if (includeSubDomains) writer << "; includeSubDomains"
    if (preload) writer << "; preload"
    writer
  }
}

package org.http4s
package headers

import scala.concurrent.duration.FiniteDuration
import org.http4s.parser.HttpHeaderParser
import org.http4s.util.Writer

/**
 * Defined by http://tools.ietf.org/html/rfc6797
 */
object `Strict-Transport-Security` extends HeaderKey.Internal[`Strict-Transport-Security`] with HeaderKey.Singleton {
  private class StrictTransportSecurityImpl(maxAge: Long, includeSubDomains: Boolean, preload: Boolean)

  def fromLong(maxAge: Long, includeSubDomains: Boolean = true, preload: Boolean = false): ParseResult[`Strict-Transport-Security`] =
    if (maxAge >= 0) {
      ParseResult.success(new StrictTransportSecurityImpl(maxAge, includeSubDomains, preload))
    } else {
      ParseResult.fail("Invalid maxAge value", s"Strict-Transport-Security param $maxAge must be more or equal to 0 seconds")
    }

  def unsafeFromDuration(maxAge: FiniteDuration, includeSubDomains: Boolean = true, preload: Boolean = false): `Strict-Transport-Security` =
    fromLong(maxAge.toSeconds).fold(throw _, identity)

  def unsafeFromLong(maxAge: Long, includeSubDomains: Boolean = true, preload: Boolean = false): `Strict-Transport-Security` =
    fromLong(maxAge).fold(throw _, identity)

  def parse(s: String): ParseResult[`Strict-Transport-Security`] =
    HttpHeaderParser.STRICT_TRANSPORT_SECURITY(s)
}

sealed abstract case class `Strict-Transport-Security`(maxAge: Long, includeSubDomains: Boolean = true, preload: Boolean = false) extends Header.Parsed {
  override def key: `Strict-Transport-Security`.type = `Strict-Transport-Security`
  override def renderValue(writer: Writer): writer.type = {
    writer << "max-age=" << maxAge
    if (includeSubDomains) writer << "; includeSubDomains"
    if (preload) writer << "; preload"
    writer
  }
}

Use long for maxAge rather than duration


import sbt._

object plugins extends Build {
  lazy val plugins = Project("plugins", file("."))
    .dependsOn(
      uri("git://github.com/bseibel/sbt-simple-junit-xml-reporter-plugin.git"))
}

import sbt._

object plugins extends Build {
  lazy val plugins = Project("plugins", file("."))
    .dependsOn(
      uri("https://github.com/bseibel/sbt-simple-junit-xml-reporter-plugin.git"))
}

Use HTTPS protocol instead of GIT for proxies


name := """frontend"""

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"

libraryDependencies ++= Seq(
  "org.postgresql" % "postgresql" % "9.4-1204-jdbc42"
)

Add postgres as deployment DB driver

Add postgres as deployment DB driver


package quasar.project

object Versions {
  val algebraVersion      = "1.0.0"
  val argonautVersion     = "6.2.2"
  val catsEffectVersion   = "1.1.0"
  val disciplineVersion   = "0.7.2"
  val jawnVersion         = "0.14.1"
  val jawnfs2Version      = "0.14.1"
  val matryoshkaVersion   = "0.18.3"
  val monocleVersion      = "1.4.0"
  val pathyVersion        = "0.2.11"
  val refinedVersion      = "0.8.3"
  val scodecBitsVersion   = "1.1.2"
  val scalacheckVersion   = "1.14.0"
  val scalazVersion       = "7.2.26"
  val scalazStreamVersion = "0.8.6a"
  val scoptVersion        = "3.5.0"
  val shapelessVersion    = "2.3.3"
  val simulacrumVersion   = "0.10.0"
  val specsVersion        = "4.3.3"
  val spireVersion        = "0.16.0"
  val akkaVersion         = "2.5.1"
  val fs2Version          = "1.0.2"
  val slf4sVersion        = "1.7.25"
}

package quasar.project

object Versions {
  val algebraVersion      = "1.0.0"
  val argonautVersion     = "6.2.2"
  val catsEffectVersion   = "1.1.0"
  val disciplineVersion   = "0.7.2"
  val jawnVersion         = "0.14.1"
  val jawnfs2Version      = "0.14.1"
  val matryoshkaVersion   = "0.18.3"
  val monocleVersion      = "1.4.0"
  val pathyVersion        = "0.2.11"
  val refinedVersion      = "0.8.3"
  val scodecBitsVersion   = "1.1.2"
  val scalacheckVersion   = "1.14.0"
  val scalazVersion       = "7.2.26"
  val scalazStreamVersion = "0.8.6a"
  val scoptVersion        = "3.5.0"
  val shapelessVersion    = "2.3.3"
  val simulacrumVersion   = "0.10.0"
  val specsVersion        = "4.3.3"
  val spireVersion        = "0.16.1"
  val akkaVersion         = "2.5.1"
  val fs2Version          = "1.0.2"
  val slf4sVersion        = "1.7.25"
}

Update spire, spire-laws to 0.16.1

Update spire, spire-laws to 0.16.1


addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt" % "2.4.2")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.8")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt" % "2.4.2")

Update play-ahc-ws, play-akka-http-server, ... to 2.8.8


addSbtPlugin("org.scoverage"             % "sbt-scoverage"            % "1.5.1")
addSbtPlugin("com.47deg"                 % "sbt-microsites"           % "0.9.1")
addSbtPlugin("com.github.gseitz"         % "sbt-release"              % "1.0.11")
addSbtPlugin("org.scala-js"              % "sbt-scalajs"              % "0.6.22")
addSbtPlugin("org.portable-scala"        % "sbt-crossproject"         % "0.6.0")
addSbtPlugin("org.portable-scala"        % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("com.lucidchart"            % "sbt-scalafmt"             % "1.16")
addSbtPlugin("org.tpolecat"              % "tut-plugin"               % "0.6.12")
addSbtPlugin("io.get-coursier"           % "sbt-coursier"             % "1.0.3")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat"             % "0.1.6")
addSbtPlugin("ch.epfl.scala"             % "sbt-scalajs-bundler"      % "0.12.0")
addSbtPlugin("com.geirsson"              % "sbt-ci-release"           % "1.2.6")

addSbtPlugin("org.scoverage"             % "sbt-scoverage"            % "1.5.1")
addSbtPlugin("com.47deg"                 % "sbt-microsites"           % "0.9.1")
addSbtPlugin("com.github.gseitz"         % "sbt-release"              % "1.0.11")
addSbtPlugin("org.scala-js"              % "sbt-scalajs"              % "0.6.22")
addSbtPlugin("org.portable-scala"        % "sbt-crossproject"         % "0.6.1")
addSbtPlugin("org.portable-scala"        % "sbt-scalajs-crossproject" % "0.6.1")
addSbtPlugin("com.lucidchart"            % "sbt-scalafmt"             % "1.16")
addSbtPlugin("org.tpolecat"              % "tut-plugin"               % "0.6.12")
addSbtPlugin("io.get-coursier"           % "sbt-coursier"             % "1.0.3")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat"             % "0.1.6")
addSbtPlugin("ch.epfl.scala"             % "sbt-scalajs-bundler"      % "0.12.0")
addSbtPlugin("com.geirsson"              % "sbt-ci-release"           % "1.2.6")

Update sbt-crossproject, ... to 0.6.1

Update sbt-crossproject, ... to 0.6.1


package com.softwaremill.react.kafka

/**
 * Used as a parameter to [[ReactiveKafkaConsumer]] when consuming from
 * a specified offset on a designated partition of a Kafka topic.
 *
 * @param topic
 * @param partition
 * @param offset
 */
case class TopicPartitionOffset(topic: String, partition: Int, offset: Long)

object TopicPartitionOffset {
  val NoPartitionSpecified: Int = -1
  val NoOffsetSpecified: Long = -1
}

Remove unused object and constants

Remove unused object and constants


package qrygraph.client.ui

import qrygraph.shared.data.Edge
import qrygraph.shared.pig.ResultType

/**
  * Created by info on 31.08.2016.
  */
object UIHelper {

  /** based on the state of the resultTypes of the source and the target this function returns a color index for an edge */
  def getColorCodeForEdge(e: Edge,resultTypes: Map[String, ResultType]): Int = {
    // in case of an join/cross we have a neighbour node that can be invalid
    val neighbourInputNodeOption = e.to.parent.inputs.find(_.id != e.to.id).map(_.parent.name)
    val neighbourHasNoTyping = neighbourInputNodeOption.exists(!resultTypes.contains(_))
    (resultTypes.get(e.from.parent.name), resultTypes.get(e.to.parent.name), neighbourHasNoTyping) match {
      case (Some(_), Some(_), _) => 5 // valid node -> green
      case (None, None, _)       => 3 // both sides not working -> yellow
      case (Some(_), None, true) => 3 // the to node is not valid but other neighbour also not -> yellow
      case (_, None, _)          => 1 // the to node is not valid -> red
      case (_, _, _)             => 0 // ERROR CASE should not happen -> grey
    }
  }
}

package qrygraph.client.ui

import qrygraph.shared.data.Edge
import qrygraph.shared.nodes.ComponentNode
import qrygraph.shared.pig.ResultType

/**
  * Created by info on 31.08.2016.
  */
object UIHelper {

  /** based on the state of the resultTypes of the source and the target this function returns a color index for an edge */
  def getColorCodeForEdge(e: Edge, resultTypes: Map[String, ResultType]): Int = {
    // in case of an join/cross we have a neighbour node that can be invalid
    val neighbourInputNodeOption = e.to.parent.inputs.find(_.id != e.to.id).map(_.parent.name)
    val neighbourHasNoTyping = neighbourInputNodeOption.exists(!resultTypes.contains(_))
    (resultTypes.get(e.from.parent.name).isDefined || e.from.parent.isInstanceOf[ComponentNode],
      resultTypes.get(e.to.parent.name).isDefined || e.to.parent.isInstanceOf[ComponentNode],
      neighbourHasNoTyping) match {
      case (true, true, _)     => 5 // valid node -> green
      case (false, false, _)   => 3 // both sides not working -> yellow
      case (true, false, true) => 3 // the to node is not valid but other neighbour also not -> yellow
      case (_, false, _)       => 1 // the to node is not valid -> red
      case (_, true, _)        => 4 // ERROR CASE
      case (_, _, _)           => 0 // ERROR CASE should not happen -> grey
    }
  }
}

Fix color for component following nodes

Fix color for component following nodes


/*
 * Copyright 2017 HM Revenue & Customs
 *
 * 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 utils

import play.api.http.{Status, DefaultHttpErrorHandler}
import play.api.mvc._

case class FeatureToggle(feature: Boolean) {
  def apply(action: Action[AnyContent]): Action[AnyContent] =
    if (feature) action else FeatureToggle.notFound
}

object FeatureToggle {
  val notFound = Action.async {
    request =>
      DefaultHttpErrorHandler.onClientError(request, Status.NOT_FOUND, "")
  }
}

/*
 * Copyright 2017 HM Revenue & Customs
 *
 * 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 utils

import play.api.mvc._

import scala.concurrent.Future

case class FeatureToggle(feature: Boolean) {
  def apply(action: Action[AnyContent]): Action[AnyContent] =
    if (feature) action else FeatureToggle.notFound
}

object FeatureToggle {
  val notFound = Action.async {
    implicit request =>
      Future.successful(Results.NotFound(ControllerHelper.notFoundView(request)))
  }
}

Replace functionality in featre toggle for action


name := "PredictionIO-Process-ItemRec-Algorithms-Scala-Mahout-Commons"

libraryDependencies ++= Seq(
  "io.prediction" %% "predictionio-commons" % "0.4-SNAPSHOT"
)

// Mahout's dependencies
libraryDependencies ++= Seq(
  "com.google.guava" % "guava" % "13.0.1",
  "org.codehaus.jackson" % "jackson-core-asl" % "1.9.11",
  "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.11",
  "org.slf4j" % "slf4j-api" % "1.7.2",
  "commons-lang" % "commons-lang" % "2.6",
  "commons-io" % "commons-io" % "2.4",
  "com.thoughtworks.xstream" % "xstream" % "1.4.4",
  "org.apache.lucene" % "lucene-core" % "4.2.0",
  "org.apache.lucene" % "lucene-analyzers-common" % "4.2.0",
  "org.apache.mahout.commons" % "commons-cli" % "2.0-mahout",
  "org.apache.commons" % "commons-math3" % "3.1.1"
)

name := "PredictionIO-Process-ItemRec-Algorithms-Scala-Mahout-Commons"

libraryDependencies ++= Seq(
  "io.prediction" %% "predictionio-commons" % "0.4-SNAPSHOT"
)

// Mahout's dependencies
libraryDependencies ++= Seq(
  "com.google.guava" % "guava" % "13.0.1",
  "org.codehaus.jackson" % "jackson-core-asl" % "1.9.11",
  "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.11",
  "org.slf4j" % "slf4j-api" % "1.7.2",
  "commons-lang" % "commons-lang" % "2.6",
  "commons-io" % "commons-io" % "2.4",
  "com.thoughtworks.xstream" % "xstream" % "1.4.4",
  "org.apache.lucene" % "lucene-core" % "4.2.0",
  "org.apache.lucene" % "lucene-analyzers-common" % "4.2.0",
  "org.apache.mahout.commons" % "commons-cli" % "2.0-mahout",
  "org.apache.commons" % "commons-math3" % "3.2"
)

Fix Mahout 0.8 Build 1993 dependency

Fix Mahout 0.8 Build 1993 dependency


package com.softwaremill.react.kafka

import akka.stream.scaladsl.{PublisherSink, Source}
import org.reactivestreams.{Publisher, Subscriber}
import org.reactivestreams.tck.{SubscriberBlackboxVerification, TestEnvironment}
import org.scalatest.testng.TestNGSuiteLike

import scala.concurrent.duration.{FiniteDuration, _}
import scala.language.postfixOps

class ReactiveKafkaSubscriberBlackboxSpec(defaultTimeout: FiniteDuration)
  extends SubscriberBlackboxVerification[String](new TestEnvironment(defaultTimeout.toMillis))
  with TestNGSuiteLike with ReactiveStreamsTckVerificationBase {

  def this() = this(300 millis)

  override def createSubscriber(): Subscriber[String] = {
    kafka.publish(getClass.getName, "group")
  }

  def createHelperSource(elements: Long): Source[String] = elements match {
    case 0 => Source.empty()
    case Long.MaxValue => Source(() => List(message).iterator)
    case n if n <= Int.MaxValue => Source(List.fill(n.toInt)(message))
    case n => sys.error("n > Int.MaxValue")
  }

  def createHelperPublisher(elements: Long): Publisher[String] = {
    createHelperSource(elements).runWith(PublisherSink())
  }

}

package com.softwaremill.react.kafka

import java.util.UUID

import akka.stream.scaladsl.{PublisherSink, Source}
import org.reactivestreams.{Publisher, Subscriber}
import org.reactivestreams.tck.{SubscriberBlackboxVerification, TestEnvironment}
import org.scalatest.testng.TestNGSuiteLike

import scala.concurrent.duration.{FiniteDuration, _}
import scala.language.postfixOps

class ReactiveKafkaSubscriberBlackboxSpec(defaultTimeout: FiniteDuration)
  extends SubscriberBlackboxVerification[String](new TestEnvironment(defaultTimeout.toMillis))
  with TestNGSuiteLike with ReactiveStreamsTckVerificationBase {

  def this() = this(300 millis)

  override def createSubscriber(): Subscriber[String] = {
    val topic = UUID.randomUUID().toString
    kafka.publish(topic, "group")
  }

  def createHelperSource(elements: Long): Source[String] = elements match {
    case 0 => Source.empty()
    case Long.MaxValue => Source(() => List(message).iterator)
    case n if n <= Int.MaxValue => Source(List.fill(n.toInt)(message))
    case n => sys.error("n > Int.MaxValue")
  }

  def createHelperPublisher(elements: Long): Publisher[String] = {
    createHelperSource(elements).runWith(PublisherSink())
  }

}

Use random topic name for each subscriber test


package com.equalinformation.fpps.week4

/**
 * Created by bpupadhyaya on 9/30/15.
 */
trait ListVariance[+T] { // Co-variant
  def isEmpty: Boolean
  def head: T
  def tail: ListVariance[T]
}

class Cons[T](val head: T, val tail: ListVariance[T]) extends ListVariance[T] {
  def isEmpty = false
}

object Nil extends ListVariance[Nothing] {
  def isEmpty = true
  def head: Nothing = throw new NoSuchElementException("Nil.head")
  def tail: Nothing = throw new NoSuchElementException("Nil.tail")
}

object test {
  val x: ListVariance[String] = Nil
}

package com.equalinformation.fpps.week4

/**
 * Created by bpupadhyaya on 9/30/15.
 */
trait ListVariance[+T] { // Co-variant
  def isEmpty: Boolean
  def head: T
  def tail: ListVariance[T]
  def prepend[U >: T] (elem: U): ListVariance[U] = new Cons(elem, this)
}

class Cons[T](val head: T, val tail: ListVariance[T]) extends ListVariance[T] {
  def isEmpty = false
}

object Nil extends ListVariance[Nothing] {
  def isEmpty = true
  def head: Nothing = throw new NoSuchElementException("Nil.head")
  def tail: Nothing = throw new NoSuchElementException("Nil.tail")
}

object test {
  val x: ListVariance[String] = Nil
  // def f(xs: ListVariance[NonEmpty], x: Empty) = xs prepend x
}

Implement prepend in a list.

Implement prepend in a list.


/**
 * Copyright (c) 2016 Bernard Leach
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.github.leachbj.newrelic.akka.http.scaladsl

import akka.http.scaladsl.model.HttpResponse
import com.newrelic.api.agent.{HeaderType, InboundHeaders}

case class InboundHttpHeaders(originalResponse: HttpResponse) extends InboundHeaders {
  def getHeader(name: String): String = originalResponse.headers.find(h => h != null && h.name == name).map(_.value).orNull

  def getHeaderType: HeaderType = HeaderType.HTTP
}

/**
 * Copyright (c) 2016 Bernard Leach
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.github.leachbj.newrelic.akka.http.scaladsl

import akka.http.scaladsl.model.HttpResponse
import com.newrelic.api.agent.{HeaderType, InboundHeaders}

case class InboundHttpHeaders(originalResponse: HttpResponse) extends InboundHeaders {
  def getHeader(name: String): String = originalResponse.headers.find(_.is(name.toLowerCase)).map(_.value).orNull

  def getHeaderType: HeaderType = HeaderType.HTTP
}

Simplify getHeader and use case insensitive match


enablePlugins(SbtIdeaPlugin)

name := "slinky-core-ijext"

intellijPlugins += "org.intellij.scala".toPlugin

packageMethod := PackagingMethod.Standalone()

patchPluginXml := pluginXmlOptions { xml =>
  xml.version = version.value
  xml.sinceBuild = (intellijBuild in ThisBuild).value
  xml.untilBuild = "999.9999.999"
}

val publishAutoChannel = taskKey[Unit]("publishAutoChannel")
publishAutoChannel := Def.taskDyn {
  val isDev = version.value.contains("+")
  if (isDev) {
    publishPlugin.toTask(" develop")
  } else {
    publishPlugin.toTask(" Stable")
  }
}.value

enablePlugins(SbtIdeaPlugin)

name := "slinky-core-ijext"

intellijPlugins += "org.intellij.scala".toPlugin

intellijPlugins += "com.intellij.java".toPlugin

packageMethod := PackagingMethod.Standalone()

patchPluginXml := pluginXmlOptions { xml =>
  xml.version = version.value
  xml.sinceBuild = (intellijBuild in ThisBuild).value
  xml.untilBuild = "999.9999.999"
}

val publishAutoChannel = taskKey[Unit]("publishAutoChannel")
publishAutoChannel := Def.taskDyn {
  val isDev = version.value.contains("+")
  if (isDev) {
    publishPlugin.toTask(" develop")
  } else {
    publishPlugin.toTask(" Stable")
  }
}.value

Add Java IntelliJ plugin as a dependency for Slinky support


package org.orbeon.oxf.xml

import org.orbeon.saxon.om._

object SaxonUtilsDependsOnXPath extends SaxonUtilsDependsOnXPathTrait {
  val anyToItem: Any => Item = ???
  val anyToItemIfNeeded: Any => Item = ???
}

package org.orbeon.oxf.xml

import org.orbeon.saxon.model.BuiltInAtomicType
import org.orbeon.saxon.om._
import org.orbeon.saxon.trans.XPathException
import org.orbeon.saxon.value._

import java.math.{BigDecimal, BigInteger}

object SaxonUtilsDependsOnXPath extends SaxonUtilsDependsOnXPathTrait {

  val anyToItem: Any => Item = convertToItem

  val anyToItemIfNeeded: Any => Item = {
    case i: Item => i
    case a       => anyToItem(a)
  }

  // Custom conversion for now XXX FIXME: we only care about types we use
  private def convertToItem(value: Any): Item =
    value match {
      case v: Boolean     => BooleanValue.get(v)
      case v: Byte        => new Int64Value(v.toLong, BuiltInAtomicType.BYTE, false)
      case v: Float       => new FloatValue(v)
      case v: Double      => new DoubleValue(v)
      case v: Integer     => new Int64Value(v.toLong, BuiltInAtomicType.INT, false)
      case v: Long        => new Int64Value(v, BuiltInAtomicType.LONG, false)
      case v: Short       => new Int64Value(v.toLong, BuiltInAtomicType.SHORT, false)
      case v: String      => StringValue.makeStringValue(v)
      case v: BigDecimal  => new BigDecimalValue(v)
      case v: BigInteger  => new BigIntegerValue(v)
      case v: Array[Byte] => new HexBinaryValue(v.asInstanceOf[Array[Byte]])
      case _              => throw new XPathException("Java object cannot be converted to an XQuery value")
    }
}

Add custom Java to `Item` conversions

Add custom Java to `Item` conversions


/*
    Contextual, version 2.4.0. Copyright 2016-21 Jon Pretty, Propensive OÜ.

    The primary distribution site is: https://propensive.com/

    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 contextual

import probably.*
import gossamer.*

import unsafeExceptions.canThrowAny

object Tests extends Suite(str"Contextual Tests"):
  def run(using Runner): Unit =
    ()

/*
    Contextual, version 2.4.0. Copyright 2016-21 Jon Pretty, Propensive OÜ.

    The primary distribution site is: https://propensive.com/

    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 contextual

import probably.*
import gossamer.*

import unsafeExceptions.canThrowAny

object Tests extends Suite(t"Contextual Tests"):
  def run(using Runner): Unit =
    ()

Rename `Txt` to `Text` and `str"` to `t"`


name := "tepkin"

libraryDependencies ++= Seq(
  "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.3",
  "com.typesafe.akka" %% "akka-actor" % Dependencies.akkaV,
  "com.typesafe.akka" % "akka-stream-experimental_2.11" % "1.0-M4",
  "org.slf4j" % "slf4j-api" % "1.7.5",
  "ch.qos.logback" % "logback-classic" % "1.0.13" % Test,
  "org.scalatest" %% "scalatest" % Dependencies.scalatestV % Test
)

name := "tepkin"

libraryDependencies ++= Seq(
  "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.3",
  "com.typesafe.akka" %% "akka-actor" % Dependencies.akkaV,
  "com.typesafe.akka" % "akka-stream-experimental_2.11" % "1.0-M5",
  "org.slf4j" % "slf4j-api" % "1.7.5",
  "ch.qos.logback" % "logback-classic" % "1.0.13" % Test,
  "org.scalatest" %% "scalatest" % Dependencies.scalatestV % Test
)

Upgrade to Akka Streams M5

Upgrade to Akka Streams M5


import org.specs2.mutable._
import play.api.libs.json._
import reactivemongo.bson.BSONObjectID

import models.Task
import models.Task._

class TaskSpec extends Specification {

  val task = Task(Some(BSONObjectID.generate), "I'm new")

  "JSON serialization" should {
    "round trip validation and parse of JSON to recreate serialized object" in {
      Json.toJson(task).validate[Task].get must be equalTo task
    }

    "should serialize to JSON" in {
      Json.obj("id" -> task.id.get.stringify, "label" -> task.label) must be_==(Json.toJson(task))
    }
  }
}

import models.Task
import models.Task._
import org.specs2.mutable._
import play.api.libs.json._
import reactivemongo.bson.BSONObjectID

class TaskSpec extends Specification {

  "JSON serialization" should {
    "should serialize to JSON" in {
      val id = Some(BSONObjectID.generate)
      val expectedJson = Json.obj("id" -> id.get.stringify, "label" -> "I'm new")
      Json.toJson(Task(id, "I'm new")) must be equalTo expectedJson
    }

    "round trip validation and parse of JSON to recreate serialized object" in {
      val task = Task(Some(BSONObjectID.generate), "I'm new")
      Json.toJson(task).validate[Task].get must be equalTo task
    }
  }
}

Clean up Task JSON serialization spec.

Clean up Task JSON serialization spec.


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.86"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.8",
      "com.ning" % "async-http-client" % "1.9.39",
      "org.scalatest" %% "scalatest" % "2.2.6" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.87"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.8",
      "com.ning" % "async-http-client" % "1.9.39",
      "org.scalatest" %% "scalatest" % "2.2.6" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.0.87


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

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.34"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.13",
      "org.scalatest" %% "scalatest" % "3.0.1" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

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

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.35"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.13",
      "org.scalatest" %% "scalatest" % "3.0.1" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.0.35


name := "lib-reference-scala"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.4"

crossScalaVersions := Seq("2.12.4", "2.11.11", "2.10.6")

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.0.4" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

version := "0.1.42"

name := "lib-reference-scala"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.4"

crossScalaVersions := Seq("2.12.4", "2.11.11", "2.10.6")

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.0.4" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

version := "0.1.43"

autocommit: Update configuration to record version 0.1.43


package io.github.bamos

object Whitelist {
  val users = Seq(
    "adius",
    "adobe-research",
    "ajn123",
    "bamos",
    "bryangarza",
    "cmusatyalab",
    "darksigma",
    "docker",
    "jebes",
    "HackathonHackers",
    "hamiltont",
    "ObeliskIsHuge",
    "rhema",
    "snowplow",
    "tejasmanohar",
    "themattman",
    "VT-Magnum-Research",
    "WalnutiQ",
    "zmughal",
    "geotrellis",
    "twitter",
    "github",
    "facebook",
    "etsy",
    "square",
    "amplab",
    "fnothaft",
    "bigdatagenomics",
    "homebrew",
    "puppetlabs",
    "rails",
    "google",
    "okfn",
    "humblesoftware",
    "ecomfe",
    "mozilla",
    "spine",
    "jez",
    "haskell",
    "coreos",
    "scotty-web",
    "vishnuravi"
  ).map(_.toLowerCase)
}

package io.github.bamos

object Whitelist {
  val users = Seq(
    "adius",
    "adobe-research",
    "ajn123",
    "bamos",
    "bryangarza",
    "cmusatyalab",
    "darksigma",
    "docker",
    "jebes",
    "HackathonHackers",
    "hamiltont",
    "ObeliskIsHuge",
    "rhema",
    "snowplow",
    "tejasmanohar",
    "themattman",
    "VT-Magnum-Research",
    "WalnutiQ",
    "zmughal",
    "geotrellis",
    "twitter",
    "github",
    "facebook",
    "etsy",
    "square",
    "amplab",
    "fnothaft",
    "bigdatagenomics",
    "homebrew",
    "puppetlabs",
    "rails",
    "google",
    "okfn",
    "humblesoftware",
    "ecomfe",
    "mozilla",
    "spine",
    "jez",
    "haskell",
    "coreos",
    "scotty-web",
    "vishnuravi",
    "cimpress-mcp"
  ).map(_.toLowerCase)
}

Add my the cimpress-mcp organization to whitelist.


package jp.ijufumi.openreports.model.support

case class ParamType(_type: String) {
  val TEXT = ParamType("0")
  val DATE = ParamType("1")
  val LIST = ParamType("2")
  val QUERY = ParamType("3")
}

package jp.ijufumi.openreports.model.support

object ParamType extends Enumeration {
  val TEXT, DATE, LIST, QUERY = Value
}

Change case class to object with enum.

Change case class to object with enum.


import scala.quoted._

enum Exp {
  case Num(n: Int)
  case Plus(e1: Exp, e2: Exp)
  case Var(x: String)
}

object Test {
  import Exp._

  val exp = Plus(Plus(Num(2), Var("x")), Num(4))

  def compile(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match {
    case Num(n) => n
    case Plus(e1, e2) => '(~compile(e1, env) + ~compile(e2, env))
    case Var(x) => env(x)
  }

  val res = (x: Int) => ~compile(exp, Map("x" -> '(x)))

}

import scala.quoted._

enum Exp {
  case Num(n: Int)
  case Plus(e1: Exp, e2: Exp)
  case Var(x: String)
  case Let(x: String, e: Exp, in: Exp)
}

object Test {
  import Exp._

  val keepLets = true

  val exp = Plus(Plus(Num(2), Var("x")), Num(4))

  val letExp = Let("x", Num(3), exp)

  def compile(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match {
    case Num(n) => n
    case Plus(e1, e2) => '(~compile(e1, env) + ~compile(e2, env))
    case Var(x) => env(x)
    case Let(x, e, body) =>
      if (keepLets)
        '{ val y = ~compile(e, env); ~compile(body, env + (x -> '(y))) }
      else
        compile(body, env + (x -> compile(e, env)))
  }

  val res1 = (x: Int) => ~compile(exp, Map("x" -> '(x)))

  val res2 = compile(letExp, Map())
}

Add Let to staged interpreter test

Add Let to staged interpreter test


package controllers

import models.Notification
import play.api.mvc.Controller
import play.api.data.Forms._
import play.api.data._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import javax.inject.Inject

import actions.Actions
import daos.ProductDao

/** Controller for product actions */
class ProductAdmin @Inject() (
  actions:    Actions,
  productDao: ProductDao
) extends Controller {

  import ProductAdmin.productForm

  def addProduct = actions.roleAction("employee") { _ =>
    Future.successful( Ok(views.html.addProduct(productForm)) )
  }

  def addProductHandle = actions.roleAction("employee") { implicit request =>
    productForm.bindFromRequest.fold(
      formWithErrors => Future.successful(BadRequest(views.html.addProduct(formWithErrors))),
      info => {
        // TODO send success to user
        productDao.insert(info).map { p =>
          implicit val nots = Seq(Notification("success", "Product created successfully"))
          Ok(views.html.addProduct(productForm))
        }
      }
    )
  }

}

object ProductAdmin {
  import daos.ProductDao.ProductInfo

  lazy val productForm = Form(
    mapping(
      "name"  -> nonEmptyText,
      "price" -> bigDecimal(17, 2)
    )(ProductInfo.apply)(ProductInfo.unapply)
  )
}

package controllers

import models.Notification
import play.api.mvc.Controller
import play.api.data.Forms._
import play.api.data._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import javax.inject.Inject

import actions.Actions
import daos.ProductDao

/** Controller for product actions */
class ProductAdmin @Inject() (
  actions:    Actions,
  productDao: ProductDao
) extends Controller {

  import ProductAdmin.productForm

  def addProduct = actions.roleAction("employee") { _ =>
    Future.successful( Ok(views.html.addProduct(productForm)) )
  }

  def addProductHandle = actions.roleAction("employee") { implicit request =>
    productForm.bindFromRequest.fold(
      formWithErrors => Future.successful(BadRequest(views.html.addProduct(formWithErrors))),
      info => {
        productDao.insert(info).map { p =>
          implicit val nots = Seq(Notification("success", "Product created successfully"))
          Ok(views.html.addProduct(productForm))
        }
      }
    )
  }

}

object ProductAdmin {
  import daos.ProductDao.ProductInfo

  lazy val productForm = Form(
    mapping(
      "name"  -> nonEmptyText,
      "price" -> bigDecimal(17, 2)
    )(ProductInfo.apply)(ProductInfo.unapply)
  )
}

Remove TODO that was already done

Remove TODO that was already done


name := "SpectralLDA-Tensor"

version := "1.0"

scalaVersion := "2.10.5"
crossScalaVersions := Seq("2.10.5", "2.11.7")

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.1"

libraryDependencies ++= Seq(
  "org.scalanlp" %% "breeze" % "0.11.2",
  "org.scalanlp" %% "breeze-viz" % "0.11.2"
)

libraryDependencies += "org.apache.spark" %% "spark-streaming" % "1.5.1"

libraryDependencies += "org.apache.commons" % "commons-math3" % "3.0"

libraryDependencies += "org.apache.spark" %% "spark-mllib" % "1.5.1"

libraryDependencies += "com.github.scopt" %% "scopt" % "3.3.0"

name := "SpectralLDA-Tensor"

version := "1.0"

scalaVersion := "2.10.5"
crossScalaVersions := Seq("2.10.5", "2.11.7")

scalacOptions :=  Seq(
  "-unchecked",
  "-feature",
  "-Xlint",
  "-Ywarn-dead-code",
  "-Ywarn-adapted-args",
  "-Ywarn-numeric-widen",
  "-Ywarn-value-discard",
  "-target:jvm-1.7",
  "-encoding", "UTF-8",
  "-optimise",
  "-Yclosure-elim",
  "-Yinline"
)

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.1"

libraryDependencies ++= Seq(
  "org.scalanlp" %% "breeze" % "0.11.2",
  "org.scalanlp" %% "breeze-viz" % "0.11.2"
)

libraryDependencies += "org.apache.spark" %% "spark-streaming" % "1.5.1"

libraryDependencies += "org.apache.commons" % "commons-math3" % "3.0"

libraryDependencies += "org.apache.spark" %% "spark-mllib" % "1.5.1"

libraryDependencies += "com.github.scopt" %% "scopt" % "3.3.0"

Adjust scala compiler options towards the benchmark-friendly


resolvers += "spray repo" at "http://repo.spray.io"

libraryDependencies ++= Seq(
  "com.decodified" % "scala-ssh" % "0.6.2",
  "org.bouncycastle" % "bcprov-jdk16" % "1.46",
  "com.jcraft" % "jzlib" % "1.1.1"
)

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.4.1")

addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")

addSbtPlugin("io.spray" % "sbt-boilerplate" % "0.5.1")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.5")

addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.4.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0")

resolvers += "spray repo" at "http://repo.spray.io"

libraryDependencies ++= Seq(
  "javax.media" % "jai_core" % "1.1.3" from "http://download.osgeo.org/webdav/geotools/javax/media/jai_core/1.1.3/jai_core-1.1.3.jar",
  "com.decodified" % "scala-ssh" % "0.6.2",
  "org.bouncycastle" % "bcprov-jdk16" % "1.46",
  "com.jcraft" % "jzlib" % "1.1.1"
)

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.4.1")

addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")

addSbtPlugin("io.spray" % "sbt-boilerplate" % "0.5.1")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.5")

addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.4.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0")

Add explicit dependency on jai_core

Add explicit dependency on jai_core

This is a finicky upstream dependency that SBT always fails
to resolve on the first pass (which breaks CI builds). Adding an
explicit dependency and download URL ensures that SBT will know
where to find the JAR.


package org.http4s
package scalatags

import _root_.scalatags.Text.TypedTag
import cats.Applicative
import org.http4s.headers.`Content-Type`

trait ScalatagsInstances {
  implicit def scalatagsEncoder[F[_]: Applicative](
      implicit charset: Charset = DefaultCharset): EntityEncoder[F, TypedTag[String]] =
    contentEncoder(MediaType.text.html)

  private def contentEncoder[F[_], C <: TypedTag[String]](mediaType: MediaType)(
      implicit charset: Charset): EntityEncoder[F, C] =
    EntityEncoder
      .stringEncoder[F]
      .contramap[C](content => content.render)
      .withContentType(`Content-Type`(mediaType, charset))
}

package org.http4s
package scalatags

import _root_.scalatags.Text.TypedTag
import org.http4s.headers.`Content-Type`

trait ScalatagsInstances {
  implicit def scalatagsEncoder[F[_]](
      implicit charset: Charset = DefaultCharset): EntityEncoder[F, TypedTag[String]] =
    contentEncoder(MediaType.text.html)

  private def contentEncoder[F[_], C <: TypedTag[String]](mediaType: MediaType)(
      implicit charset: Charset): EntityEncoder[F, C] =
    EntityEncoder
      .stringEncoder[F]
      .contramap[C](content => content.render)
      .withContentType(`Content-Type`(mediaType, charset))
}

Remove Applicative constraint on encoders from scala-tags


package net.sansa_stack.rdf.spark.qualityassessment.metrics.interlinking

import org.apache.spark.rdd.RDD
import org.apache.jena.graph.{ Triple, Node }
import net.sansa_stack.rdf.spark.qualityassessment.utils.NodeUtils._
import net.sansa_stack.rdf.spark.utils.StatsPrefixes._
import org.apache.spark.sql.SparkSession

/**
 * @author Gezim Sejdiu
 */
object ExternalSameAsLinks {

  implicit class ExternalSameAsLinksFunctions(dataset: RDD[Triple]) extends Serializable {
    // @transient var spark: SparkSession = _
    @transient var spark: SparkSession = SparkSession.builder.getOrCreate()

    def assessExternalSameAsLinks() = {

      val sameAsTriples = dataset.filter(f => checkLiteral(f.getPredicate).equals(OWL_SAME_AS))

      val triples = dataset.count().toDouble

      val sameAsCount = spark.sparkContext.longAccumulator("sameAsCount")

      sameAsTriples.filter(_.getObject.isURI()).foreach { f =>
        // if <local> owl:sameAs <external> or <external> owl:sameAs <local>
        val subjectIsLocal = isInternal(f.getSubject)
        val objectIsExternal = isExternal(f.getObject)

        if ((subjectIsLocal && objectIsExternal)
          || (!subjectIsLocal && !objectIsExternal)) {
          sameAsCount.add(1)
        }
      }

      val value = if (triples > 0.0)
        sameAsCount.value / triples;
      else 0

      value
    }
  }
}

package net.sansa_stack.rdf.spark.qualityassessment.metrics.interlinking

import net.sansa_stack.rdf.spark.qualityassessment.utils.NodeUtils._
import org.apache.jena.graph.{ Node, Triple }
import org.apache.jena.vocabulary.OWL
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.SparkSession

/**
 * @author Gezim Sejdiu
 */
object ExternalSameAsLinks {

  @transient var spark: SparkSession = SparkSession.builder.getOrCreate()

  def assessExternalSameAsLinks(dataset: RDD[Triple]): Double = {

    val sameAsTriples = dataset.filter(f => checkLiteral(f.getPredicate).equals(OWL.sameAs))

    val triples = dataset.count().toDouble

    val sameAsCount = spark.sparkContext.longAccumulator("sameAsCount")

    sameAsTriples.filter(_.getObject.isURI()).foreach { f =>
      // if <local> owl:sameAs <external> or <external> owl:sameAs <local>
      val subjectIsLocal = isInternal(f.getSubject)
      val objectIsExternal = isExternal(f.getObject)

      if ((subjectIsLocal && objectIsExternal)
        || (!subjectIsLocal && !objectIsExternal)) {
        sameAsCount.add(1)
      }
    }

    val value = if (triples > 0.0) {
      sameAsCount.value / triples
    } else 0

    value
  }
}

Refactor interlinking metrics and make Scala-style compliant


cancelable in Global := true

// target <<= baseDirectory { file("/tmp/sbt/") / _.toString }

cancelable in Global := true

target := baseDirectory { file("/tmp/sbt/") / _.toString }.value

sbt: Use /tmp/sbt as target directory to get around ecryptfs


package latis.metadata

class OperationDescription(val name: String, val className: String, val description: String, val usage: String) { }

object OperationDescription {
  def apply(name: String, className: String, description: String, usage: String): OperationDescription = new OperationDescription(name, className, description, usage)
}

package latis.metadata

class OperationDescription(
    val name: String,
    val className: String,
    val description: String,
    val usage: String) { }

object OperationDescription {
  def apply(
      name: String,
      className: String,
      description: String,
      usage: String): OperationDescription =
        new OperationDescription(name, className, description, usage)
}

Put parameters on multiple lines

Put parameters on multiple lines


package ml.wolfe.util

/**
 * The trait to be implemented of an Optimisation algorithm
 * Created by Ingolf Becker on 05/11/2014.
 */
trait HyperParameterOptimisationAlgorithm {

  /**
   * the best score after optimising
   */
  val bestScore: Double

  /**
   * The best set of parameters found
   */
  val bestParameters: Map[String,Double]

  /**
   * Sequence of intermediate steps, each a tuple of score and parameters at that step
   */
  val iterates: Seq[( Double, Map[String, Double] )]

  /**
   * Optimise the problem, starting at the given starting points
   * @param problem The optimisation problem
   * @param startingPoints A sequence of the starting points
   * @return The set of best parameters
   */
  def optimise(problem : OptimisationProblem, startingPoints: Seq[Map[String, Double]]): Map[String,Double]

  /**
   * To be implemented
   */
  def printConvergenceGraph()

}

/**
 * The trait an optimisation problem needs to expose in order to have its hyper parameters optimised
 */
trait OptimisationProblem {
  /**
   * The list of parameters to be optimised
   */
  val parametersToOptimize: Seq[HyperParameter]

  /**
   * Evaluate the optimisation problem given the set of hyper parameters.
   * @param hyperparameters The map of hyper parameters
   * @return The score of this evaluation, higher is better
   */
  def evaluate(hyperparameters: Map[String, Double]): Double

}

package ml.wolfe.util

/**
 * The trait to be implemented of an Optimisation algorithm
 * Created by Ingolf Becker on 05/11/2014.
 */
trait HyperParameterOptimisationAlgorithm {

  /**
   * the best score after optimising
   */
  val bestScore: Double

  /**
   * The best set of parameters found
   */
  val bestParameters: Map[String, Double]

  /**
   * Sequence of intermediate steps, each a tuple of score and parameters at that step
   */
  val iterates: Seq[(Double, Map[String, Double])]

  /**
   * Optimise the problem, starting at the given starting points
   * @param problem The optimisation problem
   * @param startingPoints A sequence of the starting points
   * @return The set of best parameters
   */
  def optimise(problem: OptimisationProblem, startingPoints: Seq[Map[String, Double]]): Map[String, Double]

  /**
   * To be implemented
   */
  def printConvergenceGraph(): Unit = ???

}

/**
 * The trait an optimisation problem needs to expose in order to have its hyper parameters optimised
 */
trait OptimisationProblem {
  /**
   * The list of parameters to be optimised
   */
  val parametersToOptimize: Seq[HyperParameter]

  /**
   * Evaluate the optimisation problem given the set of hyper parameters.
   * @param hyperparameters The map of hyper parameters
   * @return The score of this evaluation, higher is better
   */
  def evaluate(hyperparameters: Map[String, Double]): Double

}

Fix method that is yet to be implemented


/*
 * Copyright 2014 http4s.org
 *
 * 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 org.http4s.blazecore.util

import org.http4s.blaze.util.Execution

import scala.concurrent.ExecutionContext

private[util] trait ParasiticExecutionContextCompat {
  final def parasitic: ExecutionContext = Execution.trampoline
}

/*
 * Copyright 2014 http4s.org
 *
 * 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 org.http4s.blazecore.util

import scala.concurrent.ExecutionContext

private[util] trait ParasiticExecutionContextCompat {
  final def parasitic: ExecutionContext = ExecutionContext.parasitic
}

Use parasitic EC in the blaze for Scala 2.13