Skip to content

Commit

Permalink
Merge pull request #12 from fluencelabs/update-deps-0.0.4
Browse files Browse the repository at this point in the history
Updating dependencies
  • Loading branch information
alari authored Jan 23, 2019
2 parents 6efaac1 + b8b07d2 commit e0d046b
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: required

language: scala
scala:
- 2.12.5
- 2.12.8
jdk:
- oraclejdk8

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/fluencelabs/codec.svg?branch=master)](https://travis-ci.org/fluencelabs/codec) [![Gitter](https://badges.gitter.im/fluencelabs/codec.svg)](https://gitter.im/fluencelabs/codec?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Build Status](https://travis-ci.org/fluencelabs/codec.svg?branch=master)](https://travis-ci.org/fluencelabs/codec)

# Codec

Expand Down Expand Up @@ -64,7 +64,7 @@ In case of complex algorithms, it's worthy to share codebase between platforms.
// Bintray repo is used so far. Migration to Maven Central is planned
resolvers += Resolver.bintrayRepo("fluencelabs", "releases")

val codecV = "0.0.1"
val codecV = "0.0.4"

libraryDependencies ++= Seq(
"one.fluence" %%% "codec-core" % codecV, // basic types
Expand Down
23 changes: 12 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import de.heikoseeberger.sbtheader.License
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbtcrossproject.crossProject
import sbtcrossproject.CrossPlugin.autoImport.crossProject

name := "codec"

Expand All @@ -10,11 +10,11 @@ javaOptions in Test ++= Seq("-ea")

skip in publish := true // Skip root project

val scalaV = scalaVersion := "2.12.5"
val scalaV = scalaVersion := "2.12.8"

val commons = Seq(
scalaV,
version := "0.0.3",
version := "0.0.4",
fork in Test := true,
parallelExecution in Test := false,
organization := "one.fluence",
Expand All @@ -30,17 +30,19 @@ val commons = Seq(

commons

val kindProjector = addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.6")
val kindProjector = addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.9")

val Cats1V = "1.1.0"
val ScodecBitsV = "1.1.5"
val CirceV = "0.9.3"
val Cats1V = "1.5.0"
val ScodecBitsV = "1.1.9"
val CirceV = "0.11.1"
val ShapelessV = "2.3.+"

val chill = "com.twitter" %% "chill" % "0.9.2"
val chill = "com.twitter" %% "chill" % "0.9.3"

val ScalatestV = "3.0.+"
val ScalacheckV = "1.13.4"
val ScalatestV = "3.0.5"

// Note that cats-laws 1.5 are compiled against scalacheck 1.13, and scalacheck-shapeless should also not introduce the upgrade
val ScalacheckV = "1.13.5"

val protobuf = Seq(
PB.targets in Compile := Seq(
Expand All @@ -62,7 +64,6 @@ lazy val `codec-core` = crossProject(JVMPlatform, JSPlatform)
kindProjector,
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % Cats1V,
"org.typelevel" %%% "cats-laws" % Cats1V % Test,
"org.typelevel" %%% "cats-testkit" % Cats1V % Test,
"com.github.alexarchambault" %%% "scalacheck-shapeless_1.13" % "1.1.8" % Test,
"org.scalacheck" %%% "scalacheck" % ScalacheckV % Test,
Expand Down
97 changes: 0 additions & 97 deletions core/src/main/scala/fluence/codec/Codec.scala

This file was deleted.

7 changes: 0 additions & 7 deletions core/src/main/scala/fluence/codec/MonadicalEitherArrow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ abstract class MonadicalEitherArrow[E <: Throwable] {
*/
lazy val swap: Bijection[B, A] = Bijection(inverse, direct)

@deprecated(
"You should keep codec Pure until running direct or inverse on it: there's no reason to bind effect into Codec",
"6.4.2018"
)
def toCodec[F[_]](implicit F: MonadError[F, Throwable]): Codec[F, A, B] =
Codec(direct.runF[F], inverse.runF[F])

/**
* Splits the input and puts it to either bijection, then merges output.
* It could have been achieved with `Strong` typeclass in case it doesn't extend `Profunctor`; but it does.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

package fluence.codec

import cats.{Eq, Invariant}
import cats.{Applicative, Eq, Invariant}
import cats.data.EitherT
import cats.syntax.functor._
import cats.laws.discipline.{MonadErrorTests, SemigroupalTests}
import cats.tests.CatsSuite
import fluence.codec
import org.scalacheck.Arbitrary
import org.scalacheck.ScalacheckShapeless._

class PureCodecPointLawsSpec extends CatsSuite {
Expand All @@ -43,6 +45,7 @@ class PureCodecPointLawsSpec extends CatsSuite {

checkAll(
"PureCodec.Point.MonadErrorLaws",
MonadErrorTests[PureCodec.Point, CodecError].monadError[Int, String, Double]
MonadErrorTests[PureCodec.Point, CodecError]
.monadError[Int, String, Double]
)
}
19 changes: 6 additions & 13 deletions kryo/src/main/scala/fluence/codec/kryo/KryoCodecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,29 @@

package fluence.codec.kryo

import cats.MonadError
import com.twitter.chill.KryoPool
import fluence.codec.{Codec, CodecError, PureCodec}
import fluence.codec.{CodecError, PureCodec}
import shapeless._

import scala.language.higherKinds
import scala.reflect.ClassTag
import scala.util.Try
import scala.util.control.NonFatal

/**
* Wrapper for a KryoPool with a list of registered classes
*
* @param pool Pre-configured KryoPool
* @param F Applicative error
* @tparam L List of classes registered with kryo
* @tparam F Effect
*/
class KryoCodecs[F[_], L <: HList] private (pool: KryoPool)(implicit F: MonadError[F, Throwable]) {
class KryoCodecs[L <: HList] private (pool: KryoPool) {

/**
* Returns a codec for any registered type
*
* @param sel Shows the presence of type T within list L
* @tparam T Object type
* @return Freshly created Codec with Kryo inside
* @return Freshly created PureCodec with Kryo inside
*/
implicit def codec[T](implicit sel: ops.hlist.Selector[L, T]): Codec[F, T, Array[Byte]] =
pureCodec[T].toCodec[F]

implicit def pureCodec[T](implicit sel: ops.hlist.Selector[L, T]): PureCodec[T, Array[Byte]] =
PureCodec.Bijection(
PureCodec.liftFuncEither { input
Expand Down Expand Up @@ -112,10 +105,10 @@ object KryoCodecs {
* @tparam F Effect type
* @return Configured instance of KryoCodecs
*/
def build[F[_]](
def build(
poolSize: Int = Runtime.getRuntime.availableProcessors
)(implicit F: MonadError[F, Throwable]): KryoCodecs[F, L] =
new KryoCodecs[F, L](
): KryoCodecs[L] =
new KryoCodecs[L](
KryoPool.withByteArrayOutputStream(
poolSize,
KryoFactory(klasses, registrationRequired = true) // registrationRequired should never be needed, as codec derivation is typesafe
Expand Down
16 changes: 8 additions & 8 deletions kryo/src/test/scala/fluence/codec/kryo/KryoCodecsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package fluence.codec.kryo

import cats.instances.try_._
import cats.syntax.profunctor._
import org.scalatest.{Matchers, WordSpec}

import scala.util.Try
Expand All @@ -31,24 +32,24 @@ class KryoCodecsSpec extends WordSpec with Matchers {
KryoCodecs()
.add[Array[Array[Byte]]]
.addCase(classOf[TestClass])
.build[Try]()
.build()

"encode and decode" should {
"be inverse functions" when {
"object defined" in {

val codec = testCodecs.codec[TestClass]
val codec = testCodecs.pureCodec[TestClass]

val result = codec.encode(testClass).flatMap(codec.decode).get
val result = codec.inverse.unsafe(codec.direct.unsafe(testClass))

result.str shouldBe "one"
result.num shouldBe 2
result.blob should contain theSameElementsAs testBlob
}

"object is null" in {
val codec = testCodecs.codec[TestClass]
val result = codec.encode(null).flatMap(codec.decode)
val codec = testCodecs.pureCodec[TestClass]
val result = codec.direct.runF[Try](null).flatMap(codec.inverse.runF[Try])
result.isFailure shouldBe true
}
}
Expand All @@ -57,9 +58,8 @@ class KryoCodecsSpec extends WordSpec with Matchers {
"encode" should {
"not write full class name to binary representation" when {
"class registered" in {
//val codec = KryoCodec[TestClass](Seq(classOf[TestClass], classOf[Array[Byte]], classOf[Array[Array[Byte]]]), registerRequired = true)
val codec = testCodecs.codec[TestClass]
val encoded = codec.encode(testClass).map(new String(_)).get
val codec = testCodecs.pureCodec[TestClass]
val encoded = codec.direct.rmap(new String(_)).unsafe(testClass)
val reasonableMaxSize = 20 // bytes
encoded should not contain "TestClass"
encoded.length should be < reasonableMaxSize
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.1.4
sbt.version = 1.2.8
24 changes: 12 additions & 12 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.4.0")
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.15")

addSbtPlugin("de.heikoseeberger" % "sbt-header" % "4.1.0")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.0.0")

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.18")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.19")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22")
addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "0.3.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.3.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.26")
addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "0.6.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")

addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.10.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.13.1")

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

addSbtPlugin("com.lihaoyi" % "workbench" % "0.4.0")
addSbtPlugin("com.lihaoyi" % "workbench" % "0.4.1")

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.7.1"
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.8.4"

addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")

0 comments on commit e0d046b

Please sign in to comment.