Skip to content

Commit

Permalink
Partial fix for #19 (#75)
Browse files Browse the repository at this point in the history
* - migrate cmd

* - add contramap to Show, reformat implicitNotFound msg

* - RESPParamWrite reformat implicitNotFound msg, reorg instances classes

* - LowPriorityShowInstances -> ShowInstances and make sealed an package private

* - ops revert to using traits for init order

* - Read: modify implicitNotFound msg, replaced zip (unused and unneeded) with orElse (a bit more useful), combinators leverage Read constructors

* - echo and ping now accept any A: Show, also require NonNullBulkString ==> A evidence

* - reworded implicitNotFound msg, use widenLeft where appropriate

* more fixes

* - remove unneeded lazy vals in build.sbt for cross build components
- add comment on why we shadow scala.js plugin

* - toShowSyntax -> toShowOps

* - address codacy issues

* fixed compilation issue w/ scalatest 3.0.6

* wip geo

* Ignoring metals+bloom directories

* refactor Read instances names and grouping

* Fixed benchmarks compilation issues

* remove explicit evidence when not needed

* mostly code formatting

* more formatting

* refactor all RESP ADTs

* widen renamed to coerce where appropriate, more use of context bounds

* shuffling things around

* more cleanup, wip 2.11 broken

* more tests

* fixing 2.11 stack overflow in tests

* formatting

* more cleanup

* BaseSpec in core + must => should

* no implicit macro

* adding transation watch/unwatch

* cluster protocol commands

* testing more refined types

* completed tests on laserdisc-defined refined types

* polishing up

* removed manual refinements via refined API

* removed unuseful RESPBuilder and made Arr a wrapper on List[RESP] instead of Vector[RESP]

* no Show syntax, let Bulk handle Show

* renamed Extra to Ext(ended) and added a few tests

* roundtrip not round-trip

* nodes, finally

* bye bye 2.11

* minor README fix

* more ClusterP testing

* add cluster nodes test

* cleaning up tests

* fixed Host's RFC1123 hostname regex for JS

* cluster cleanup

* cluster cleanup - removed unnecessary parenthesis

* more on geo protocol

* completed geo protocol + tests

* wip on hash and key protocols

* removed last bit of 2.11/2.12 dichotomy

* minor cosmetics around geo protocol spec

* more hash tests

* added glob pattern generator + test and completed hash protocol spec

* wip key protocol

* still wip key protocol testing

* key protocol still missing SORT combinations

* added list protocol tests

* bump scalacheck to 1.14.0
  • Loading branch information
sirocchj authored Aug 10, 2019
1 parent 45902bc commit d530ae7
Show file tree
Hide file tree
Showing 87 changed files with 6,450 additions and 3,052 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
**/target/
# Metals + Bloop
.metals/
.bloop/

# Intellij
.idea

# MacOS
*.DS_Store

# Anything else
**/target/
local.*
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
align = true # For pretty alignment.
maxColumn = 120 # For my wide 30" display.
maxColumn = 140 # For my wide 30" display.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ sudo: false
language: scala
scala:
- 2.12.8
- 2.11.11-bin-typelevel-4

jdk:
- openjdk8
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ LaserDisc is a(nother) Scala driver for [Redis](https://redis.io/), written in S
It differentiates itself from the others for having a core layer, which is made up of all the supported Redis commands
and the Redis Serialization Protocol ([RESP](https://redis.io/topics/protocol)), that is strongly typed and which makes
heavy use of [shapeless](https://github.com/milessabin/shapeless) and [refined](https://github.com/fthomas/refined) to
achieve this. It's also worth noting that the core - in order to be built on scala 2.11.x - makes use of
[Typelevel's Scala 2.11](https://typelevel.org/scala) fork, since it requires the enhancements on implicit heuristics. Finally, it also provides an implementation of RESP built using
[scodec](http://scodec.org/).
achieve this. It also provides an implementation of RESP built using [scodec](http://scodec.org/).

On top of this, one or more clients can be implemented. The only one currently available out of the box is built using
[fs2](https://functional-streams-for-scala.github.io/fs2/)/[cats effect](https://typelevel.org/cats-effect/) but
Expand All @@ -48,7 +46,7 @@ Two reasons:

### Getting Started

LaserDisc is currently available for Scala 2.11 and 2.12 on the JVM.
LaserDisc is currently available for Scala 2.12 on the JVM.

Its core (protocol commands and RESP wire format) is also available for [Scala.JS](http://www.scala-js.org/).

Expand All @@ -69,7 +67,7 @@ Support for existing libraries is available via dedicated dependencies.
#### [Circe](https://circe.github.io/circe/)

When an `io.circe.Decoder[A]` and a `io.circe.Encoder[A]` are implicilty available,
instances of `Show[A]` and `Read[NonNullBulkString, A]` can be derived for free,
instances of `Show[A]` and `Read[Bulk, A]` can be derived for free,
just add the following in your `build.sbt`:

```
Expand Down Expand Up @@ -136,10 +134,10 @@ This should produce an output similar to the following one:
[info] Running Main
[info] - [ForkJoinPool-3-worker-2] Starting connection
[info] - [ForkJoinPool-3-worker-2] Server available for publishing: localhost:6379
[debug] - [ForkJoinPool-3-worker-5] sending Array(BulkString(SET),BulkString(a),BulkString(23))
[debug] - [ForkJoinPool-3-worker-0] receiving SimpleString(OK)
[debug] - [ForkJoinPool-3-worker-1] sending Array(BulkString(GET),BulkString(a))
[debug] - [ForkJoinPool-3-worker-5] receiving BulkString(23)
[debug] - [ForkJoinPool-3-worker-5] sending Arr(Bulk(SET),Bulk(a),Bulk(23))
[debug] - [ForkJoinPool-3-worker-0] receiving Str(OK)
[debug] - [ForkJoinPool-3-worker-1] sending Arr(Bulk(GET),Bulk(a))
[debug] - [ForkJoinPool-3-worker-5] receiving Bulk(23)
[info] - [ForkJoinPool-3-worker-2] yay!
[info] - [ForkJoinPool-3-worker-2] Shutting down connection
[info] - [ForkJoinPool-3-worker-0] Connection terminated: Right(())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package laserdisc.protocol
package laserdisc
package protocol

import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
import eu.timepit.refined.auto._
import laserdisc.Maybe
import laserdisc.protocol.RESP._
import shapeless._

@State(Scope.Benchmark)
class ProtocolBench {

private final val protocol = Protocol("CUSTOM", _: Int :: String :: Long :: Double :: HNil).as[SimpleString, OK]
private final val protocol = Protocol("CUSTOM", _: Int :: String :: Long :: Double :: HNil).as[Str, OK]

private final val request = 0 :: "a" :: 1L :: 2.0d :: HNil
private final val response = str("OK")
private final val response = Str("OK")

@Benchmark def encode(): RESP = protocol(request).encode
@Benchmark def decode(): Maybe[OK] = protocol(request).decode(response)
Expand Down
48 changes: 24 additions & 24 deletions benchmarks/core/src/main/scala/laserdisc/protocol/RESPBench.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package laserdisc.protocol
package laserdisc
package protocol

import java.nio.charset.StandardCharsets.UTF_8

import laserdisc.protocol.RESP._
import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
import scodec.bits.BitVector
import scodec.codecs.utf8
Expand All @@ -16,37 +16,37 @@ class RESPBench {
private final val chars = 2000

private final val ok = "OK"
private final val okRedis = s"+$ok\r\n"
private final val okRedis = s"+$ok$CRLF"
private final val rtProblem = "runtime problem"
private final val rtProblemRedis = s"-$rtProblem\r\n"
private final val rtProblemRedis = s"-$rtProblem$CRLF"
private final val fortyTwo = 42L
private final val fortyTwoRedis = s":$fortyTwo\r\n"
private final val fortyTwoRedis = s":$fortyTwo$CRLF"
private final val longString = new String(Array.fill(chars)('a'))
private final val longStringRedis = s"$$$chars\r\n$longString\r\n"
private final val longStringRedis = s"$$$chars$CRLF$longString$CRLF"
private final val longStringI =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

private final val simpleString = str(ok)
private final val simpleStringBits = BitVector(okRedis.getBytes(UTF_8))
private final val error = err(rtProblem)
private final val errorBits = BitVector(rtProblemRedis.getBytes(UTF_8))
private final val integer = int(fortyTwo)
private final val integerBits = BitVector(fortyTwoRedis.getBytes(UTF_8))
private final val bulkString = bulk(longString)
private final val bulkStringBits = BitVector(longStringRedis.getBytes(UTF_8))
private final val longStringBits = BitVector(longString.getBytes(UTF_8))
private final val longStringIBits = BitVector(longStringI.getBytes(UTF_8))
private final val str = Str(ok)
private final val strBits = BitVector(okRedis.getBytes(UTF_8))
private final val err = Err(rtProblem)
private final val errBits = BitVector(rtProblemRedis.getBytes(UTF_8))
private final val num = Num(fortyTwo)
private final val numBits = BitVector(fortyTwoRedis.getBytes(UTF_8))
private final val bulk = Bulk(longString)
private final val bulkBits = BitVector(longStringRedis.getBytes(UTF_8))
private final val longStringBits = BitVector(longString.getBytes(UTF_8))
private final val longStringIBits = BitVector(longStringI.getBytes(UTF_8))

@Benchmark def baseline_utf8_encode: Attempt[BitVector] = utf8.encode(longString)
@Benchmark def baseline_utf8_decode: Attempt[String] = utf8.decodeValue(longStringBits)
@Benchmark def baseline_utf8_encodeI: Attempt[BitVector] = utf8.encode(longStringI)
@Benchmark def baseline_utf8_decodeI: Attempt[String] = utf8.decodeValue(longStringIBits)
@Benchmark def simpleString_encode: Attempt[BitVector] = codec.encode(simpleString)
@Benchmark def simpleString_decode: Attempt[RESP] = codec.decodeValue(simpleStringBits)
@Benchmark def error_encode: Attempt[BitVector] = codec.encode(error)
@Benchmark def error_decode: Attempt[RESP] = codec.decodeValue(errorBits)
@Benchmark def integer_encode: Attempt[BitVector] = codec.encode(integer)
@Benchmark def integer_decode: Attempt[RESP] = codec.decodeValue(integerBits)
@Benchmark def bulkString_encode: Attempt[BitVector] = codec.encode(bulkString)
@Benchmark def bulkString_decode: Attempt[RESP] = codec.decodeValue(bulkStringBits)
@Benchmark def str_encode: Attempt[BitVector] = codec.encode(str)
@Benchmark def str_decode: Attempt[RESP] = codec.decodeValue(strBits)
@Benchmark def err_encode: Attempt[BitVector] = codec.encode(err)
@Benchmark def err_decode: Attempt[RESP] = codec.decodeValue(errBits)
@Benchmark def num_encode: Attempt[BitVector] = codec.encode(num)
@Benchmark def num_decode: Attempt[RESP] = codec.decodeValue(numBits)
@Benchmark def bulk_encode: Attempt[BitVector] = codec.encode(bulk)
@Benchmark def bulk_decode: Attempt[RESP] = codec.decodeValue(bulkBits)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package laserdisc.protocol
package laserdisc
package protocol

import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
import shapeless._
Expand All @@ -10,5 +11,5 @@ class RESPParamWriteBench {

private final val value = 0 :: "a" :: 1L :: 2.0d :: HNil

@Benchmark def write(): Seq[BulkString] = respParamWrite.write(value)
@Benchmark def write(): Seq[GenBulk] = respParamWrite.write(value)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package laserdisc.protocol
package laserdisc
package protocol

import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets.UTF_8
Expand Down
92 changes: 35 additions & 57 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossType
// shadow sbt-scalajs' crossProject and CrossType from Scala.js 0.6.x
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

val `scala 211` = "2.11.11-bin-typelevel-4"
val `scala 212` = "2.12.8"
val `scala 2.12` = "2.12.8"

val V = new {
val circe = "0.11.1"
val fs2 = "1.0.5"
val `kind-projector` = "0.9.10"
val kittens = "1.2.1"
val `log-effect-fs2` = "0.8.0"
val refined = "0.9.9"
val refined211 = "0.8.7"
val scalacheck = "1.13.5"
val scalacheck = "1.14.0"
val scalatest = "3.0.8"
val `scodec-bits` = "1.1.12"
val `scodec-core` = "1.11.4"
val `scodec-stream` = "1.2.1"
val shapeless = "2.3.3"
val `log-effect-fs2` = "0.8.0"
}

val `circe-core` = Def.setting("io.circe" %%% "circe-core" % V.circe)
val `circe-parser` = Def.setting("io.circe" %%% "circe-parser" % V.circe)
val `fs2-core` = Def.setting("co.fs2" %%% "fs2-core" % V.fs2)
val `fs2-io` = Def.setting("co.fs2" %% "fs2-io" % V.fs2)
val kittens = Def.setting("org.typelevel" %%% "kittens" % V.kittens)
val `scodec-bits` = Def.setting("org.scodec" %%% "scodec-bits" % V.`scodec-bits`)
val `scodec-core` = Def.setting("org.scodec" %%% "scodec-core" % V.`scodec-core`)
val `scodec-stream` = Def.setting("org.scodec" %%% "scodec-stream" % V.`scodec-stream`)
val shapeless = Def.setting("com.chuusai" %%% "shapeless" % V.shapeless)
val `log-effect-fs2` = Def.setting("io.laserdisc" %%% "log-effect-fs2" % V.`log-effect-fs2`)
val `circe-generic` = Def.setting("io.circe" %%% "circe-generic" % V.circe % Test)
val scalacheck = Def.setting("org.scalacheck" %%% "scalacheck" % V.scalacheck % Test)
val scalatest = Def.setting("org.scalatest" %%% "scalatest" % V.scalatest % Test)
val refined = Def.setting {
is211.value match {
case true => "eu.timepit" %%% "refined" % V.refined211
case _ => "eu.timepit" %%% "refined" % V.refined
}
}
val `circe-core` = Def.setting("io.circe" %%% "circe-core" % V.circe)
val `circe-parser` = Def.setting("io.circe" %%% "circe-parser" % V.circe)
val `fs2-core` = Def.setting("co.fs2" %%% "fs2-core" % V.fs2)
val `fs2-io` = Def.setting("co.fs2" %% "fs2-io" % V.fs2)
val kittens = Def.setting("org.typelevel" %%% "kittens" % V.kittens)
val `log-effect-fs2` = Def.setting("io.laserdisc" %%% "log-effect-fs2" % V.`log-effect-fs2`)
val refined = Def.setting("eu.timepit" %%% "refined" % V.refined)
val `scodec-bits` = Def.setting("org.scodec" %%% "scodec-bits" % V.`scodec-bits`)
val `scodec-core` = Def.setting("org.scodec" %%% "scodec-core" % V.`scodec-core`)
val `scodec-stream` = Def.setting("org.scodec" %%% "scodec-stream" % V.`scodec-stream`)
val shapeless = Def.setting("com.chuusai" %%% "shapeless" % V.shapeless)

val `circe-generic` = Def.setting("io.circe" %%% "circe-generic" % V.circe % Test)
val `refined-scalacheck` = Def.setting("eu.timepit" %%% "refined-scalacheck" % V.refined % Test)
val scalacheck = Def.setting("org.scalacheck" %%% "scalacheck" % V.scalacheck % Test)
val scalatest = Def.setting("org.scalatest" %%% "scalatest" % V.scalatest % Test)

val `kind-projector-compiler-plugin` = Def.setting {
compilerPlugin("org.spire-math" % "kind-projector" % V.`kind-projector` cross CrossVersion.binary)
Expand All @@ -54,6 +49,7 @@ val coreDeps = Def.Initialize.join {
`scodec-core`,
shapeless,
refined,
`refined-scalacheck`,
scalacheck,
scalatest
)
Expand All @@ -65,8 +61,8 @@ val fs2Deps = Def.Initialize.join {
`fs2-io`,
`kind-projector-compiler-plugin`,
kittens,
`scodec-stream`,
`log-effect-fs2`,
`scodec-stream`,
scalacheck,
scalatest
)
Expand Down Expand Up @@ -113,7 +109,7 @@ val externalApiMappings = Def.task {
}

val versionDependantScalacOptions = Def.setting {
def versionDependent(scalaVersion: String, flags: Seq[String]) =
def versionDependent(scalaVersion: String, flags: Seq[String]) =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, major)) if major >= 12 =>
flags ++ Seq(
Expand All @@ -126,11 +122,9 @@ val versionDependantScalacOptions = Def.setting {
"-Ywarn-unused:privates", // Warn if a private member is unused.
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
)
case _ =>
(flags ++ Seq("-Yinduction-heuristics", "-Yliteral-types"))
.filterNot(_ == "-Xlint:missing-interpolator") //@implicitNotFound uses ${A} syntax w/o need for s interpolator
case _ => flags
}

val flags = Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding",
Expand Down Expand Up @@ -168,7 +162,7 @@ val versionDependantScalacOptions = Def.setting {
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-numeric-widen" // Warn when numerics are widened.
)

versionDependent(scalaVersion.value, flags)
Expand All @@ -177,17 +171,13 @@ val versionDependantScalacOptions = Def.setting {
inThisBuild {
Def.settings(
organization := "io.laserdisc",
scalaVersion := `scala 212`
scalaVersion := `scala 2.12`
)
}

lazy val commonSettings = Seq(
scalaOrganization :=
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => "org.typelevel"
case _ => "org.scala-lang"
}),
crossScalaVersions := Seq(`scala 211`, `scala 212`),
scalaOrganization := "org.scala-lang",
crossScalaVersions := Seq(`scala 2.12`),
scalacOptions ++= versionDependantScalacOptions.value,
Compile / console / scalacOptions --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings"),
Test / console / scalacOptions := (Compile / console / scalacOptions).value
Expand Down Expand Up @@ -237,18 +227,8 @@ lazy val scoverageSettings = Seq(
coverageMinimum := 60,
coverageFailOnMinimum := false,
coverageHighlighting := true,
coverageEnabled := {
if (is211.value) false else coverageEnabled.value
}
)

lazy val is211 = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => true
case _ => false
}
}

lazy val allSettings = commonSettings ++ testSettings ++ scaladocSettings ++ publishSettings ++ scoverageSettings

lazy val scalaJsTLSSettings = Seq(
Expand All @@ -265,7 +245,8 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
.settings(
name := "laserdisc-core",
libraryDependencies ++= coreDeps.value,
Compile / boilerplateSource := baseDirectory.value.getParentFile / "src" / "main" / "boilerplate"
Compile / boilerplateSource := baseDirectory.value.getParentFile / "src" / "main" / "boilerplate",
Test / boilerplateSource := baseDirectory.value.getParentFile / "src" / "test" / "boilerplate"
)
.jvmSettings(
javaOptions += "-Djava.net.preferIPv4Stack=true",
Expand Down Expand Up @@ -311,7 +292,7 @@ lazy val cli = project

lazy val circe = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.crossType(CrossType.Pure)
.in(file("circe"))
.dependsOn(core)
.settings(allSettings)
Expand All @@ -321,13 +302,10 @@ lazy val circe = crossProject(JSPlatform, JVMPlatform)
)
.jsSettings(scalaJsTLSSettings: _*)

lazy val circeJVM = circe.jvm
lazy val circeJS = circe.js

lazy val laserdisc = project
.in(file("."))
.aggregate(coreJVM, coreJS, fs2, cli, circeJVM, circeJS)
.aggregate(coreJVM, coreJS, fs2, cli, circe.jvm, circe.js)
.settings(publishSettings)
.settings(
publishArtifact := false
)
)
5 changes: 2 additions & 3 deletions circe/src/main/scala/laserdisc/interop/circe.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package interop

import io.circe._
import io.circe.syntax._
import laserdisc.protocol.NonNullBulkString

object circe {
implicit final def encoderShow[A: Encoder]: Show[A] = Show.instance(_.asJson.noSpaces)
implicit final def decoderRead[A: Decoder]: Read[NonNullBulkString, A] = Read.instance {
case NonNullBulkString(s) =>
implicit final def decoderRead[A: Decoder]: Bulk ==> A = Read.instance {
case Bulk(s) =>
parser.decode(s) match {
case Right(a) => Some(a)
case _ => None
Expand Down
Loading

0 comments on commit d530ae7

Please sign in to comment.