Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
ThisBuild / scalaVersion := "2.13.2"
ThisBuild / crossScalaVersions := Seq("2.12.11", "2.13.2")
ThisBuild / scalaVersion := scala213
ThisBuild / organization := "com.47deg"

addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; mdoc; testCovered")
addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; mdoc; ++test")
addCommandAlias("ci-docs", "github; mdoc; headerCreateAll; publishMicrosite")
addCommandAlias("ci-publish", "github; ci-release")

lazy val scala212 = "2.12.12"
lazy val scala213 = "2.13.5"
lazy val scala3Version = "3.0.0-RC1"
lazy val scala2Versions = Seq(scala212, scala213)
lazy val allScalaVersions = scala2Versions :+ scala3Version

skip in publish := true

lazy val fetch = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.settings(commonCrossDependencies)
.settings(crossScalaVersions := allScalaVersions)

lazy val fetchJVM = fetch.jvm
lazy val fetchJS = fetch.js.disablePlugins(ScoverageSbtPlugin)
lazy val fetchJS = fetch.js
.settings(crossScalaVersions := scala2Versions)

lazy val `fetch-debug` = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.dependsOn(fetch)
.settings(commonCrossDependencies)
.settings(crossScalaVersions := allScalaVersions)

lazy val debugJVM = `fetch-debug`.jvm
lazy val debugJS = `fetch-debug`.js.disablePlugins(ScoverageSbtPlugin)
lazy val debugJS = `fetch-debug`.js
.settings(crossScalaVersions := scala2Versions)

lazy val `fetch-examples` = project
.dependsOn(fetchJVM, debugJVM)
.settings(skip in publish := true)
.settings(examplesSettings: _*)
.settings(crossScalaVersions := scala2Versions)

lazy val microsite = project
.dependsOn(fetchJVM, debugJVM)
.settings(docsSettings: _*)
.settings(skip in publish := true)
.enablePlugins(MicrositesPlugin, MdocPlugin)
.settings(crossScalaVersions := scala2Versions)

lazy val documentation = project
.dependsOn(fetchJVM)
.settings(skip in publish := true)
.settings(mdocOut := file("."))
.enablePlugins(MdocPlugin)
.settings(crossScalaVersions := scala2Versions)
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fetch

[![Join the chat at https://gitter.im/47deg/fetch](https://badges.gitter.im/47deg/fetch.svg)](https://gitter.im/47deg/fetch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![codecov.io](http://codecov.io/github/47deg/fetch/coverage.svg?branch=master)](http://codecov.io/github/47deg/fetch?branch=master) [![Maven Central](https://img.shields.io/badge/maven%20central-1.2.1-green.svg)](https://oss.sonatype.org/#nexus-search;gav~com.47deg~fetch*) [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/47deg/fetch/master/LICENSE) [![Latest version](https://img.shields.io/badge/fetch-1.2.1-green.svg)](https://index.scala-lang.org/47deg/fetch) [![Scala.js](http://scala-js.org/assets/badges/scalajs-0.6.15.svg)](http://scala-js.org) [![GitHub Issues](https://img.shields.io/github/issues/47deg/fetch.svg)](https://github.com/47deg/fetch/issues)
[![Join the chat at https://gitter.im/47deg/fetch](https://badges.gitter.im/47deg/fetch.svg)](https://gitter.im/47deg/fetch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) (http://codecov.io/github/47deg/fetch?branch=master) [![Maven Central](https://img.shields.io/badge/maven%20central-1.2.1-green.svg)](https://oss.sonatype.org/#nexus-search;gav~com.47deg~fetch*) [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/47deg/fetch/master/LICENSE) [![Latest version](https://img.shields.io/badge/fetch-1.2.1-green.svg)](https://index.scala-lang.org/47deg/fetch) [![Scala.js](http://scala-js.org/assets/badges/scalajs-0.6.15.svg)](http://scala-js.org) [![GitHub Issues](https://img.shields.io/github/issues/47deg/fetch.svg)](https://github.com/47deg/fetch/issues)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed half of the codecov badge but left (http://codecov.io/github/47deg/fetch?branch=master) - is that intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wasn't intentional. I'll fix it 👍 .


A library for Simple & Efficient data access in Scala and Scala.js

Expand Down
14 changes: 7 additions & 7 deletions fetch-debug/src/main/scala/debug.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object debug {
} yield lastRequestEnd - firstRequestStart
val durationDoc =
duration.fold(Document.empty: Document)((d: Long) =>
Document.text("Fetch execution") :: showDuration(d)
Document.text("Fetch execution") :-: showDuration(d)
)

durationDoc :/: Document.nest(
Expand All @@ -80,9 +80,9 @@ object debug {
} yield l - f

val round =
Document.text(s"[Round ${n}]") :: roundDuration.fold(Document.text(""))(showDuration(_))
Document.text(s"[Round ${n}]") :-: roundDuration.fold(Document.text(""))(showDuration(_))

round :: Document.nest(
round :-: Document.nest(
2,
pile(r.queries.map(showRequest))
)
Expand All @@ -91,9 +91,9 @@ object debug {
def showRequest(r: Request): Document =
r.request match {
case FetchOne(id, d) =>
Document.text(s"[Fetch one] From `${d.name}` with id ${id}") :: showDuration(r.duration)
Document.text(s"[Fetch one] From `${d.name}` with id ${id}") :-: showDuration(r.duration)
case Batch(ids, d) =>
Document.text(s"[Batch] From `${d.name}` with ids ${ids.toList}") :: showDuration(
Document.text(s"[Batch] From `${d.name}` with ids ${ids.toList}") :-: showDuration(
r.duration
)
}
Expand All @@ -110,14 +110,14 @@ object debug {
Document
.text(
s"[ERROR] Identity with id `${id}` for data source `${q.data.name}` not found"
) :: showRoundCount(
) :-: showRoundCount(
err
)
case UnhandledException(exc, log) =>
Document
.text(
s"[ERROR] Unhandled `${exc.getClass.getName}`: '${exc.getMessage}'"
) :: showRoundCount(
) :-: showRoundCount(
err
)
}
Expand Down
8 changes: 4 additions & 4 deletions fetch-debug/src/main/scala/document.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ case class DocCons(hd: Document, tl: Document) extends Document
* @version 1.0
*/
abstract class Document {
def ::(hd: Document): Document = DocCons(hd, this)
def ::(hd: String): Document = DocCons(DocText(hd), this)
def :/:(hd: Document): Document = hd :: DocBreak :: this
def :/:(hd: String): Document = hd :: DocBreak :: this
def :-:(hd: Document): Document = DocCons(hd, this)
def :-:(hd: String): Document = DocCons(DocText(hd), this)
def :/:(hd: Document): Document = hd :-: DocBreak :-: this
def :/:(hd: String): Document = hd :-: DocBreak :-: this

/**
* Format this document on `writer` and try to set line
Expand Down
13 changes: 7 additions & 6 deletions fetch-examples/src/test/scala/DoobieExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ object DatabaseExample {

def createTransactor[F[_]: Async: ContextShift] =
for {
(conn, trans) <- (connectionPool[F](1), transactionPool[F]).tupled
connAndTrans <- (connectionPool[F](1), transactionPool[F]).tupled
(conn, trans) = connAndTrans
tx <-
H2Transactor
.newH2Transactor[F](
Expand Down Expand Up @@ -138,13 +139,13 @@ class DoobieExample extends AnyWordSpec with Matchers with BeforeAndAfterAll {
createTable(tx) *> authors.traverse(addAuthor(_)(tx))
})
.void
.unsafeRunSync
override def afterAll(): Unit = transactor.use(dropTable(_)).void.unsafeRunSync
.unsafeRunSync()
override def afterAll(): Unit = transactor.use(dropTable(_)).void.unsafeRunSync()

"We can fetch one author from the DB" in {
val io: IO[(Log, Author)] = Fetch.runLog[IO](Authors.fetchAuthor(1))

val (log, result) = io.unsafeRunSync
val (log, result) = io.unsafeRunSync()

result shouldEqual Author(1, "William Shakespeare")
log.rounds.size shouldEqual 1
Expand All @@ -156,7 +157,7 @@ class DoobieExample extends AnyWordSpec with Matchers with BeforeAndAfterAll {

val io: IO[(Log, List[Author])] = Fetch.runLog[IO](fetch)

val (log, result) = io.unsafeRunSync
val (log, result) = io.unsafeRunSync()

result shouldEqual Author(1, "William Shakespeare") :: Author(2, "Charles Dickens") :: Nil
log.rounds.size shouldEqual 1
Expand All @@ -171,7 +172,7 @@ class DoobieExample extends AnyWordSpec with Matchers with BeforeAndAfterAll {

val io: IO[(Log, List[Author])] = Fetch.runLog[IO](fetch)

val (log, result) = io.unsafeRunSync
val (log, result) = io.unsafeRunSync()

result shouldEqual Author(1, "William Shakespeare") :: Author(2, "Charles Dickens") :: Nil
log.rounds.size shouldEqual 2
Expand Down
Loading