Skip to content

Commit

Permalink
Merge pull request #468 from valencik/ce3-jun4
Browse files Browse the repository at this point in the history
Upgrade to CE3, FS2 3, and http4s 0.23
  • Loading branch information
ChristopherDavenport authored Jun 5, 2021
2 parents 1c47363 + 33a9504 commit aeb850a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 37 deletions.
13 changes: 7 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ lazy val cormorant = project.in(file("."))


val catsV = "2.1.1"
val catsEffectV = "2.1.4"
val catsEffectTestV = "0.4.2"
val catsEffectV = "3.1.1"
val catsEffectTestV = "1.1.0"
val fs2V = "3.0.4"
val shapelessV = "2.3.3"
val http4sV = "0.21.18"
val http4sV = "0.23.0-RC1"
val catsScalacheckV = "0.3.0"
val munitV = "0.7.26"
val munitCatsEffectV = "1.0.3"
Expand Down Expand Up @@ -130,8 +131,8 @@ lazy val fs2 = project.in(file("modules/fs2"))
.settings(
name := "cormorant-fs2",
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-core" % "2.4.6",
"co.fs2" %% "fs2-io" % "2.4.6" % Test
"co.fs2" %% "fs2-core" % fs2V,
"co.fs2" %% "fs2-io" % fs2V % Test
)
)

Expand Down Expand Up @@ -198,7 +199,7 @@ lazy val commonSettings = Seq(
"org.typelevel" %% "cats-effect" % catsEffectV,
"org.scalameta" %% "munit" % munitV % Test,
"org.scalameta" %% "munit-scalacheck" % munitV % Test,
"org.typelevel" %% "munit-cats-effect-2" % munitCatsEffectV % Test,
"org.typelevel" %% "munit-cats-effect-3" % munitCatsEffectV % Test,
"org.typelevel" %% "scalacheck-effect-munit" % scalacheckEffectV % Test,
"io.chrisdavenport" %% "cats-scalacheck" % catsScalacheckV % Test,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package fs2
import cats.data.NonEmptyList
import cats.effect._
import munit.CatsEffectSuite
import _root_.fs2.Stream
import io.chrisdavenport.cormorant._
import java.io.ByteArrayInputStream
import java.io.InputStream
Expand All @@ -22,28 +21,22 @@ class StreamingParserSpec extends CatsEffectSuite {
Larry,Bordowitz,larry@example.com
Anonymous,Hippopotamus,hippo@example.com"""
val source = IO.pure(new ByteArrayInputStream(ruinDelims(x).getBytes): InputStream)
Stream.resource(Blocker[IO]).flatMap{blocker =>
_root_.fs2.io.readInputStream(
source,
chunkSize = 4,
blocker
)
_root_.fs2.io.readInputStream(
source,
chunkSize = 4,
)
.through(_root_.fs2.text.utf8Decode)
.through(parseComplete[IO])
.compile
.toVector
.map{ v =>
val header = CSV.Headers(NonEmptyList.of(CSV.Header("First Name"), CSV.Header("Last Name"), CSV.Header("Email")))
val row1 = CSV.Row(NonEmptyList.of(CSV.Field("Larry"), CSV.Field("Bordowitz"), CSV.Field("larry@example.com")))
val row2 = CSV.Row(NonEmptyList.of(CSV.Field("Anonymous"), CSV.Field("Hippopotamus"), CSV.Field("hippo@example.com")))
assertEquals(Vector(
(header, row1),
(header, row2)
), v)
}
.through(_root_.fs2.text.utf8Decode)
.through(parseComplete[IO])
.compile
.toVector
.map{ v =>
val header = CSV.Headers(NonEmptyList.of(CSV.Header("First Name"), CSV.Header("Last Name"), CSV.Header("Email")))
val row1 = CSV.Row(NonEmptyList.of(CSV.Field("Larry"), CSV.Field("Bordowitz"), CSV.Field("larry@example.com")))
val row2 = CSV.Row(NonEmptyList.of(CSV.Field("Anonymous"), CSV.Field("Hippopotamus"), CSV.Field("hippo@example.com")))
assertEquals(Vector(
(header, row1),
(header, row2)
), v)
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ package object http4s {
printer: Printer = Printer.default,
mediaType: MediaType = MediaType.text.csv
): EntityEncoder[F, CSV.Complete] = {
val contentTypeHeader: Header = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(Headers.of(contentTypeHeader))(
val contentTypeHeader = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(contentTypeHeader)(
csvComplete => Entity(Stream(printer.print(csvComplete)).through(text.utf8Encode).covary[F])
)
}
Expand All @@ -24,8 +24,8 @@ package object http4s {
printer: Printer = Printer.default,
mediaType: MediaType = MediaType.text.csv
): EntityEncoder[F, CSV.Rows] = {
val contentTypeHeader: Header = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(Headers.of(contentTypeHeader))(
val contentTypeHeader = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(contentTypeHeader)(
csvRows => Entity(Stream(printer.print(csvRows)).through(text.utf8Encode).covary[F])
)
}
Expand All @@ -35,8 +35,8 @@ package object http4s {
p: Printer = Printer.default,
mediaType: MediaType = MediaType.text.csv
): EntityEncoder[F, Stream[F, CSV.Row]] = {
val contentTypeHeader: Header = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(Headers.of(contentTypeHeader))(
val contentTypeHeader = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(contentTypeHeader)(
s =>
Entity(
s.through(encodeRows(p))
Expand All @@ -57,8 +57,8 @@ package object http4s {
p: Printer = Printer.default,
mediaType: MediaType = MediaType.text.csv
): EntityEncoder[F, Stream[F, A]] = {
val contentTypeHeader: Header = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(Headers.of(contentTypeHeader))(
val contentTypeHeader = headers.`Content-Type`(mediaType)
EntityEncoder.encodeBy(contentTypeHeader)(
s =>
Entity(
s.through(writeLabelled(p))
Expand Down

0 comments on commit aeb850a

Please sign in to comment.