diff --git a/.github/actions.yml b/.github/actions.yml new file mode 100644 index 00000000..e02f0163 --- /dev/null +++ b/.github/actions.yml @@ -0,0 +1,2 @@ +pre: + docs: 'gem install jekyll -v 4' \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f0e1a4d7..00000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright (C) 2016-2020 47 Degrees. - - 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. \ No newline at end of file diff --git a/README.md b/README.md index f2a53ad6..9df6cce3 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,28 @@ # Fetch -[comment]: # (Start Badges) - [![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) -[comment]: # (End Badges) - A library for Simple & Efficient data access in Scala and Scala.js - [Documentation](https://47degrees.github.io/fetch/docs) +--- + +- [Installation](#installation) +- [Remote data](#remote-data) +- [Define your data sources](#define-your-data-sources) +- [Creating a runtime](#creating-a-runtime) +- [Creating and running a fetch](#creating-and-running-a-fetch) +- [Batching](#batching) +- [Parallelism](#parallelism) +- [Caching](#caching) + ## Installation Add the following dependency to your project's build file. For Scala 2.11.x and 2.12.x: -[comment]: # (Start Replace) - ```scala "com.47deg" %% "fetch" % "1.3.0" ``` @@ -28,9 +33,6 @@ Or, if using Scala.js (0.6.x): "com.47deg" %%% "fetch" % "1.3.0" ``` -[comment]: # (End Replace) - - ## Remote data Fetch is a library for making access to data both simple and efficient. Fetch is especially useful when querying data that diff --git a/build.sbt b/build.sbt index 546ee859..c4ac3bcd 100644 --- a/build.sbt +++ b/build.sbt @@ -1,60 +1,39 @@ -import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} +ThisBuild / scalaVersion := "2.13.2" +ThisBuild / crossScalaVersions := Seq("2.12.11", "2.13.2") +ThisBuild / organization := "com.47deg" -lazy val checkScalafmt = "+scalafmtCheckAll; +scalafmtSbtCheck;" -lazy val checkDocs = "+docs/mdoc;" -lazy val checkJSTests = "+fetchJS/test; +debugJS/test;" -lazy val checkJVMTests = - "+coverage; +fetchJVM/test; +debugJVM/test; +examples/test; +coverageReport; +coverageAggregate;" +addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; mdoc; testCovered") +addCommandAlias("ci-docs", "github; mdoc; headerCreateAll; publishMicrosite") +addCommandAlias("ci-publish", "github; ci-release") -addCommandAlias( - "ci-test", - s"$checkScalafmt $checkDocs $checkJSTests $checkJVMTests" -) -addCommandAlias("ci-docs", "project-docs/mdoc; headerCreateAll") -addCommandAlias("ci-microsite", "docs/publishMicrosite") - -lazy val root = project - .in(file(".")) - .settings(name := "fetch") - .settings(moduleName := "root") - .aggregate(fetchJS, fetchJVM, debugJVM, debugJS) +skip in publish := true lazy val fetch = crossProject(JSPlatform, JVMPlatform) - .in(file(".")) - .settings(name := "fetch") + .crossType(CrossType.Pure) .settings(commonCrossDependencies) - lazy val fetchJVM = fetch.jvm lazy val fetchJS = fetch.js.disablePlugins(ScoverageSbtPlugin) -lazy val debug = crossProject(JSPlatform, JVMPlatform) - .in(file("debug")) - .settings(name := "fetch-debug") +lazy val `fetch-debug` = crossProject(JSPlatform, JVMPlatform) + .crossType(CrossType.Pure) .dependsOn(fetch) .settings(commonCrossDependencies) +lazy val debugJVM = `fetch-debug`.jvm +lazy val debugJS = `fetch-debug`.js.disablePlugins(ScoverageSbtPlugin) -lazy val debugJVM = debug.jvm -lazy val debugJS = debug.js.disablePlugins(ScoverageSbtPlugin) - -lazy val examples = (project in file("examples")) - .settings(name := "fetch-examples") +lazy val `fetch-examples` = project .dependsOn(fetchJVM, debugJVM) .settings(skip in publish := true) .settings(examplesSettings: _*) -lazy val docs = (project in file("docs")) +lazy val microsite = project .dependsOn(fetchJVM, debugJVM) - .settings(name := "fetch-docs") .settings(docsSettings: _*) .settings(skip in publish := true) - .enablePlugins(MicrositesPlugin) - .enablePlugins(MdocPlugin) + .enablePlugins(MicrositesPlugin, MdocPlugin) -lazy val `project-docs` = (project in file(".docs")) - .aggregate(fetchJVM) +lazy val documentation = project .dependsOn(fetchJVM) - .settings(moduleName := "fetch-project-docs") - .settings(mdocIn := file(".docs")) - .settings(mdocOut := file(".")) .settings(skip in publish := true) + .settings(mdocOut := file(".")) .enablePlugins(MdocPlugin) diff --git a/.docs/AUTHORS.md b/docs/AUTHORS.md similarity index 100% rename from .docs/AUTHORS.md rename to docs/AUTHORS.md diff --git a/.docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md similarity index 100% rename from .docs/CODE_OF_CONDUCT.md rename to docs/CODE_OF_CONDUCT.md diff --git a/.docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 100% rename from .docs/CONTRIBUTING.md rename to docs/CONTRIBUTING.md diff --git a/.docs/LICENSE.md b/docs/LICENSE.md similarity index 100% rename from .docs/LICENSE.md rename to docs/LICENSE.md diff --git a/.docs/NOTICE.md b/docs/NOTICE.md similarity index 100% rename from .docs/NOTICE.md rename to docs/NOTICE.md diff --git a/.docs/README.md b/docs/README.md similarity index 98% rename from .docs/README.md rename to docs/README.md index bd5f9aa3..dbf22ab5 100644 --- a/.docs/README.md +++ b/docs/README.md @@ -1,23 +1,20 @@ # Fetch -[comment]: # (Start Badges) - [![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) -[comment]: # (End Badges) - A library for Simple & Efficient data access in Scala and Scala.js - [Documentation](https://47degrees.github.io/fetch/docs) +```scala mdoc:toc +``` + ## Installation Add the following dependency to your project's build file. For Scala 2.11.x and 2.12.x: -[comment]: # (Start Replace) - ```scala "com.47deg" %% "fetch" % "@VERSION@" ``` @@ -28,8 +25,6 @@ Or, if using Scala.js (0.6.x): "com.47deg" %%% "fetch" % "@VERSION@" ``` -[comment]: # (End Replace) - ```scala mdoc:invisible val out = Console.out diff --git a/debug/shared/src/main/scala/debug.scala b/fetch-debug/src/main/scala/debug.scala similarity index 100% rename from debug/shared/src/main/scala/debug.scala rename to fetch-debug/src/main/scala/debug.scala diff --git a/debug/shared/src/main/scala/document.scala b/fetch-debug/src/main/scala/document.scala similarity index 100% rename from debug/shared/src/main/scala/document.scala rename to fetch-debug/src/main/scala/document.scala diff --git a/examples/src/test/scala/DoobieExample.scala b/fetch-examples/src/test/scala/DoobieExample.scala similarity index 92% rename from examples/src/test/scala/DoobieExample.scala rename to fetch-examples/src/test/scala/DoobieExample.scala index 4a783e5f..0a5992fc 100644 --- a/examples/src/test/scala/DoobieExample.scala +++ b/fetch-examples/src/test/scala/DoobieExample.scala @@ -83,14 +83,15 @@ object DatabaseExample { def createTransactor[F[_]: Async: ContextShift] = for { (conn, trans) <- (connectionPool[F](1), transactionPool[F]).tupled - tx <- H2Transactor - .newH2Transactor[F]( - "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", - "sa", - "", - conn, - Blocker.liftExecutionContext(trans) - ) + tx <- + H2Transactor + .newH2Transactor[F]( + "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", + "sa", + "", + conn, + Blocker.liftExecutionContext(trans) + ) } yield tx } @@ -131,9 +132,13 @@ class DoobieExample extends AnyWordSpec with Matchers with BeforeAndAfterAll { implicit val cs: ContextShift[IO] = IO.contextShift(executionContext) implicit val transactor: Resource[IO, Transactor[IO]] = createTransactor[IO] - override def beforeAll(): Unit = (transactor.use { tx => - createTable(tx) *> authors.traverse(addAuthor(_)(tx)) - }).void.unsafeRunSync + override def beforeAll(): Unit = + (transactor + .use { tx => + createTable(tx) *> authors.traverse(addAuthor(_)(tx)) + }) + .void + .unsafeRunSync override def afterAll(): Unit = transactor.use(dropTable(_)).void.unsafeRunSync "We can fetch one author from the DB" in { diff --git a/examples/src/test/scala/GithubExample.scala b/fetch-examples/src/test/scala/GithubExample.scala similarity index 96% rename from examples/src/test/scala/GithubExample.scala rename to fetch-examples/src/test/scala/GithubExample.scala index c866505f..830be406 100644 --- a/examples/src/test/scala/GithubExample.scala +++ b/fetch-examples/src/test/scala/GithubExample.scala @@ -180,7 +180,9 @@ class GithubExample extends AnyWordSpec with Matchers { def fetch(repo: Repo): F[Option[List[Contributor]]] = { client[F].use { (c) => val url = Uri - .unsafeFromString(repo.contributors_url) +? ("access_token", ACCESS_TOKEN) +? ("type", "public") +? ("per_page", 100) + .unsafeFromString( + repo.contributors_url + ) +? ("access_token", ACCESS_TOKEN) +? ("type", "public") +? ("per_page", 100) val req = Request[F](Method.GET, url) fetchCollectionRecursively[F, Contributor](c, req).map(Option(_)) } @@ -226,8 +228,8 @@ class GithubExample extends AnyWordSpec with Matchers { val GITHUB: Uri = Uri.unsafeFromString("https://api.github.com") - private def fetchCollectionRecursively[F[_], A](c: Client[F], req: Request[F])( - implicit CF: MonadError[F, Throwable], + private def fetchCollectionRecursively[F[_], A](c: Client[F], req: Request[F])(implicit + CF: MonadError[F, Throwable], E: EntityDecoder[F, List[A]] ): F[List[A]] = { val REL_NEXT = "rel=\"next\"".r @@ -256,7 +258,7 @@ class GithubExample extends AnyWordSpec with Matchers { for { result <- c.fetch[List[A]](req) { - case Status.Ok(res) => { + case Status.Ok(res) => if (hasNext(res)) { for { repos <- res.as[List[A]] @@ -266,10 +268,8 @@ class GithubExample extends AnyWordSpec with Matchers { } yield repos ++ moreRepos } else res.as[List[A]] - } - case res => { + case res => CF.raiseError(new Exception(s"Couldn't complete request, returned status: ${res.status}")) - } } } yield result } diff --git a/examples/src/test/scala/GraphQLExample.scala b/fetch-examples/src/test/scala/GraphQLExample.scala similarity index 89% rename from examples/src/test/scala/GraphQLExample.scala rename to fetch-examples/src/test/scala/GraphQLExample.scala index 3de325da..0a13c2cc 100644 --- a/examples/src/test/scala/GraphQLExample.scala +++ b/fetch-examples/src/test/scala/GraphQLExample.scala @@ -195,38 +195,40 @@ class GraphQLExample extends AnyWordSpec with Matchers { private def fetchRepos[F[_]: ConcurrentEffect]( org: String, q: RepositoriesQuery - ): Fetch[F, List[Project]] = q match { - case RepositoriesQuery(n, name, Some(_), Some(_)) => - for { - repos <- Repos.fetch(org) - projects <- repos - .take(n) - .traverse(repo => - (Languages.fetch(repo), Collaborators.fetch(repo)).mapN { - case (ls, cs) => Project(name >> Some(repo.name), ls, cs) - } - ) - } yield projects - - case RepositoriesQuery(n, name, None, None) => - Repos.fetch(org).map(_.map(r => Project(name >> Some(r.name), List(), List()))) - - case RepositoriesQuery(n, name, Some(_), None) => - for { - repos <- Repos.fetch(org) - projects <- repos.traverse { r => - Languages.fetch(r).map(ls => Project(name >> Some(r.name), ls, List())) - } - } yield projects - - case RepositoriesQuery(n, name, None, Some(_)) => - for { - repos <- Repos.fetch(org) - projects <- repos.traverse { r => - Collaborators.fetch(r).map(cs => Project(name >> Some(r.name), List(), cs)) - } - } yield projects - } + ): Fetch[F, List[Project]] = + q match { + case RepositoriesQuery(n, name, Some(_), Some(_)) => + for { + repos <- Repos.fetch(org) + projects <- + repos + .take(n) + .traverse(repo => + (Languages.fetch(repo), Collaborators.fetch(repo)).mapN { + case (ls, cs) => Project(name >> Some(repo.name), ls, cs) + } + ) + } yield projects + + case RepositoriesQuery(n, name, None, None) => + Repos.fetch(org).map(_.map(r => Project(name >> Some(r.name), List(), List()))) + + case RepositoriesQuery(n, name, Some(_), None) => + for { + repos <- Repos.fetch(org) + projects <- repos.traverse { r => + Languages.fetch(r).map(ls => Project(name >> Some(r.name), ls, List())) + } + } yield projects + + case RepositoriesQuery(n, name, None, Some(_)) => + for { + repos <- Repos.fetch(org) + projects <- repos.traverse { r => + Collaborators.fetch(r).map(cs => Project(name >> Some(r.name), List(), cs)) + } + } yield projects + } } object Parsers { diff --git a/examples/src/test/scala/Http4sExample.scala b/fetch-examples/src/test/scala/Http4sExample.scala similarity index 100% rename from examples/src/test/scala/Http4sExample.scala rename to fetch-examples/src/test/scala/Http4sExample.scala diff --git a/examples/src/test/scala/JedisExample.scala b/fetch-examples/src/test/scala/JedisExample.scala similarity index 94% rename from examples/src/test/scala/JedisExample.scala rename to fetch-examples/src/test/scala/JedisExample.scala index a8206ca6..bd27622f 100644 --- a/examples/src/test/scala/JedisExample.scala +++ b/fetch-examples/src/test/scala/JedisExample.scala @@ -40,14 +40,15 @@ object DataSources { object Numbers extends Data[Int, Int] { def name = "Numbers" - def source[F[_]: ConcurrentEffect]: DataSource[F, Int, Int] = new DataSource[F, Int, Int] { - def data = Numbers + def source[F[_]: ConcurrentEffect]: DataSource[F, Int, Int] = + new DataSource[F, Int, Int] { + def data = Numbers - override def CF = ConcurrentEffect[F] + override def CF = ConcurrentEffect[F] - override def fetch(id: Int): F[Option[Int]] = - CF.pure(Option(id)) - } + override def fetch(id: Int): F[Option[Int]] = + CF.pure(Option(id)) + } } def fetchNumber[F[_]: ConcurrentEffect](id: Int): Fetch[F, Int] = @@ -90,8 +91,8 @@ object Binary { def fromString(s: String): Array[Byte] = s.getBytes(Charset.forName("UTF-8")) - def serialize[F[_], A](obj: A)( - implicit S: Sync[F] + def serialize[F[_], A](obj: A)(implicit + S: Sync[F] ): F[ByteArray] = { byteOutputStream .mproduct(outputStream(_)) @@ -105,8 +106,8 @@ object Binary { }) } - def deserialize[F[_], A](bin: ByteArray)( - implicit S: Sync[F] + def deserialize[F[_], A](bin: ByteArray)(implicit + S: Sync[F] ): F[Option[A]] = { byteInputStream(bin) .mproduct(inputStream(_)) @@ -156,8 +157,8 @@ case class RedisCache[F[_]: Sync](host: String) extends DataCache[F] { _ <- set(cacheId(i, data), s) } yield this - override def bulkInsert[I, A](vs: List[(I, A)], data: Data[I, A])( - implicit M: Monad[F] + override def bulkInsert[I, A](vs: List[(I, A)], data: Data[I, A])(implicit + M: Monad[F] ): F[DataCache[F]] = for { bin <- vs.traverse({ diff --git a/examples/src/test/scala/MonixExample.scala b/fetch-examples/src/test/scala/MonixExample.scala similarity index 97% rename from examples/src/test/scala/MonixExample.scala rename to fetch-examples/src/test/scala/MonixExample.scala index 30b098e5..762485d6 100644 --- a/examples/src/test/scala/MonixExample.scala +++ b/fetch-examples/src/test/scala/MonixExample.scala @@ -41,10 +41,9 @@ class MonixExample extends AnyWordSpec with Matchers { task .map({ - case (log, result) => { + case (log, result) => result shouldEqual Author(1, "William Shakespeare") log.rounds.size shouldEqual 1 - } }) .runToFuture } diff --git a/shared/src/main/scala/cache.scala b/fetch/src/main/scala/cache.scala similarity index 100% rename from shared/src/main/scala/cache.scala rename to fetch/src/main/scala/cache.scala diff --git a/shared/src/main/scala/datasource.scala b/fetch/src/main/scala/datasource.scala similarity index 100% rename from shared/src/main/scala/datasource.scala rename to fetch/src/main/scala/datasource.scala diff --git a/shared/src/main/scala/execution.scala b/fetch/src/main/scala/execution.scala similarity index 100% rename from shared/src/main/scala/execution.scala rename to fetch/src/main/scala/execution.scala diff --git a/shared/src/main/scala/fetch.scala b/fetch/src/main/scala/fetch.scala similarity index 100% rename from shared/src/main/scala/fetch.scala rename to fetch/src/main/scala/fetch.scala diff --git a/shared/src/main/scala/log.scala b/fetch/src/main/scala/log.scala similarity index 100% rename from shared/src/main/scala/log.scala rename to fetch/src/main/scala/log.scala diff --git a/shared/src/main/scala/syntax.scala b/fetch/src/main/scala/syntax.scala similarity index 100% rename from shared/src/main/scala/syntax.scala rename to fetch/src/main/scala/syntax.scala diff --git a/shared/src/test/scala/FetchAsyncQueryTests.scala b/fetch/src/test/scala/FetchAsyncQueryTests.scala similarity index 100% rename from shared/src/test/scala/FetchAsyncQueryTests.scala rename to fetch/src/test/scala/FetchAsyncQueryTests.scala diff --git a/shared/src/test/scala/FetchBatchingTests.scala b/fetch/src/test/scala/FetchBatchingTests.scala similarity index 100% rename from shared/src/test/scala/FetchBatchingTests.scala rename to fetch/src/test/scala/FetchBatchingTests.scala diff --git a/shared/src/test/scala/FetchReportingTests.scala b/fetch/src/test/scala/FetchReportingTests.scala similarity index 100% rename from shared/src/test/scala/FetchReportingTests.scala rename to fetch/src/test/scala/FetchReportingTests.scala diff --git a/shared/src/test/scala/FetchSpec.scala b/fetch/src/test/scala/FetchSpec.scala similarity index 100% rename from shared/src/test/scala/FetchSpec.scala rename to fetch/src/test/scala/FetchSpec.scala diff --git a/shared/src/test/scala/FetchSyntaxTests.scala b/fetch/src/test/scala/FetchSyntaxTests.scala similarity index 100% rename from shared/src/test/scala/FetchSyntaxTests.scala rename to fetch/src/test/scala/FetchSyntaxTests.scala diff --git a/shared/src/test/scala/FetchTests.scala b/fetch/src/test/scala/FetchTests.scala similarity index 100% rename from shared/src/test/scala/FetchTests.scala rename to fetch/src/test/scala/FetchTests.scala diff --git a/shared/src/test/scala/TestHelper.scala b/fetch/src/test/scala/TestHelper.scala similarity index 100% rename from shared/src/test/scala/TestHelper.scala rename to fetch/src/test/scala/TestHelper.scala diff --git a/docs/docs/docs.md b/microsite/docs/docs.md similarity index 99% rename from docs/docs/docs.md rename to microsite/docs/docs.md index 10547e20..08e5a573 100644 --- a/docs/docs/docs.md +++ b/microsite/docs/docs.md @@ -28,8 +28,6 @@ we read) concerns. To begin, add the following dependency to your SBT build file: -[comment]: # (Start Replace) - ```scala "com.47deg" %% "fetch" % "@VERSION@" ``` @@ -40,8 +38,6 @@ Or, if using Scala.js: "com.47deg" %%% "fetch" % "@VERSION@" ``` -[comment]: # (End Replace) - Now you'll have Fetch available in both Scala and Scala.js. ```scala mdoc:invisible diff --git a/docs/docs/index.md b/microsite/docs/index.md similarity index 100% rename from docs/docs/index.md rename to microsite/docs/index.md diff --git a/docs/src/main/resources/microsite/_data/commons.yml b/microsite/src/main/resources/microsite/_data/commons.yml similarity index 100% rename from docs/src/main/resources/microsite/_data/commons.yml rename to microsite/src/main/resources/microsite/_data/commons.yml diff --git a/docs/src/main/resources/microsite/_data/features.yml b/microsite/src/main/resources/microsite/_data/features.yml similarity index 100% rename from docs/src/main/resources/microsite/_data/features.yml rename to microsite/src/main/resources/microsite/_data/features.yml diff --git a/docs/src/main/resources/microsite/_data/menu.yml b/microsite/src/main/resources/microsite/_data/menu.yml similarity index 100% rename from docs/src/main/resources/microsite/_data/menu.yml rename to microsite/src/main/resources/microsite/_data/menu.yml diff --git a/docs/src/main/resources/microsite/_includes/_fetch-footer.html b/microsite/src/main/resources/microsite/_includes/_fetch-footer.html similarity index 100% rename from docs/src/main/resources/microsite/_includes/_fetch-footer.html rename to microsite/src/main/resources/microsite/_includes/_fetch-footer.html diff --git a/docs/src/main/resources/microsite/_includes/_fetch-head.html b/microsite/src/main/resources/microsite/_includes/_fetch-head.html similarity index 100% rename from docs/src/main/resources/microsite/_includes/_fetch-head.html rename to microsite/src/main/resources/microsite/_includes/_fetch-head.html diff --git a/docs/src/main/resources/microsite/_includes/_fetch-header.html b/microsite/src/main/resources/microsite/_includes/_fetch-header.html similarity index 100% rename from docs/src/main/resources/microsite/_includes/_fetch-header.html rename to microsite/src/main/resources/microsite/_includes/_fetch-header.html diff --git a/docs/src/main/resources/microsite/_includes/_fetch-main.html b/microsite/src/main/resources/microsite/_includes/_fetch-main.html similarity index 100% rename from docs/src/main/resources/microsite/_includes/_fetch-main.html rename to microsite/src/main/resources/microsite/_includes/_fetch-main.html diff --git a/docs/src/main/resources/microsite/_includes/_fetch-navigation.html b/microsite/src/main/resources/microsite/_includes/_fetch-navigation.html similarity index 100% rename from docs/src/main/resources/microsite/_includes/_fetch-navigation.html rename to microsite/src/main/resources/microsite/_includes/_fetch-navigation.html diff --git a/docs/src/main/resources/microsite/_layouts/fetch-home.html b/microsite/src/main/resources/microsite/_layouts/fetch-home.html similarity index 100% rename from docs/src/main/resources/microsite/_layouts/fetch-home.html rename to microsite/src/main/resources/microsite/_layouts/fetch-home.html diff --git a/docs/src/main/resources/microsite/css/custom.scss b/microsite/src/main/resources/microsite/css/custom.scss similarity index 100% rename from docs/src/main/resources/microsite/css/custom.scss rename to microsite/src/main/resources/microsite/css/custom.scss diff --git a/docs/src/main/resources/microsite/custom-config.yml b/microsite/src/main/resources/microsite/custom-config.yml similarity index 100% rename from docs/src/main/resources/microsite/custom-config.yml rename to microsite/src/main/resources/microsite/custom-config.yml diff --git a/docs/src/main/resources/microsite/img/favicon.ico b/microsite/src/main/resources/microsite/img/favicon.ico similarity index 100% rename from docs/src/main/resources/microsite/img/favicon.ico rename to microsite/src/main/resources/microsite/img/favicon.ico diff --git a/docs/src/main/resources/microsite/img/favicon.png b/microsite/src/main/resources/microsite/img/favicon.png similarity index 100% rename from docs/src/main/resources/microsite/img/favicon.png rename to microsite/src/main/resources/microsite/img/favicon.png diff --git a/docs/src/main/resources/microsite/img/icon-feature-first.svg b/microsite/src/main/resources/microsite/img/icon-feature-first.svg similarity index 100% rename from docs/src/main/resources/microsite/img/icon-feature-first.svg rename to microsite/src/main/resources/microsite/img/icon-feature-first.svg diff --git a/docs/src/main/resources/microsite/img/icon-feature-second.svg b/microsite/src/main/resources/microsite/img/icon-feature-second.svg similarity index 100% rename from docs/src/main/resources/microsite/img/icon-feature-second.svg rename to microsite/src/main/resources/microsite/img/icon-feature-second.svg diff --git a/docs/src/main/resources/microsite/img/icon-feature-third.svg b/microsite/src/main/resources/microsite/img/icon-feature-third.svg similarity index 100% rename from docs/src/main/resources/microsite/img/icon-feature-third.svg rename to microsite/src/main/resources/microsite/img/icon-feature-third.svg diff --git a/docs/src/main/resources/microsite/img/nav-icon-close.svg b/microsite/src/main/resources/microsite/img/nav-icon-close.svg similarity index 100% rename from docs/src/main/resources/microsite/img/nav-icon-close.svg rename to microsite/src/main/resources/microsite/img/nav-icon-close.svg diff --git a/docs/src/main/resources/microsite/img/nav-icon-open.svg b/microsite/src/main/resources/microsite/img/nav-icon-open.svg similarity index 100% rename from docs/src/main/resources/microsite/img/nav-icon-open.svg rename to microsite/src/main/resources/microsite/img/nav-icon-open.svg diff --git a/docs/src/main/resources/microsite/img/navbar_brand.png b/microsite/src/main/resources/microsite/img/navbar_brand.png similarity index 100% rename from docs/src/main/resources/microsite/img/navbar_brand.png rename to microsite/src/main/resources/microsite/img/navbar_brand.png diff --git a/docs/src/main/resources/microsite/img/navbar_brand.svg b/microsite/src/main/resources/microsite/img/navbar_brand.svg similarity index 100% rename from docs/src/main/resources/microsite/img/navbar_brand.svg rename to microsite/src/main/resources/microsite/img/navbar_brand.svg diff --git a/docs/src/main/resources/microsite/img/navbar_brand2x.png b/microsite/src/main/resources/microsite/img/navbar_brand2x.png similarity index 100% rename from docs/src/main/resources/microsite/img/navbar_brand2x.png rename to microsite/src/main/resources/microsite/img/navbar_brand2x.png diff --git a/docs/src/main/resources/microsite/img/pattern-background.png b/microsite/src/main/resources/microsite/img/pattern-background.png similarity index 100% rename from docs/src/main/resources/microsite/img/pattern-background.png rename to microsite/src/main/resources/microsite/img/pattern-background.png diff --git a/docs/src/main/resources/microsite/img/pattern-background.svg b/microsite/src/main/resources/microsite/img/pattern-background.svg similarity index 100% rename from docs/src/main/resources/microsite/img/pattern-background.svg rename to microsite/src/main/resources/microsite/img/pattern-background.svg diff --git a/docs/src/main/resources/microsite/img/pattern-background@2x.png b/microsite/src/main/resources/microsite/img/pattern-background@2x.png similarity index 100% rename from docs/src/main/resources/microsite/img/pattern-background@2x.png rename to microsite/src/main/resources/microsite/img/pattern-background@2x.png diff --git a/docs/src/main/resources/microsite/img/poster.png b/microsite/src/main/resources/microsite/img/poster.png similarity index 100% rename from docs/src/main/resources/microsite/img/poster.png rename to microsite/src/main/resources/microsite/img/poster.png diff --git a/docs/src/main/resources/microsite/img/sidebar_brand.png b/microsite/src/main/resources/microsite/img/sidebar_brand.png similarity index 100% rename from docs/src/main/resources/microsite/img/sidebar_brand.png rename to microsite/src/main/resources/microsite/img/sidebar_brand.png diff --git a/docs/src/main/resources/microsite/img/sidebar_brand.svg b/microsite/src/main/resources/microsite/img/sidebar_brand.svg similarity index 100% rename from docs/src/main/resources/microsite/img/sidebar_brand.svg rename to microsite/src/main/resources/microsite/img/sidebar_brand.svg diff --git a/docs/src/main/resources/microsite/img/sidebar_brand2x.png b/microsite/src/main/resources/microsite/img/sidebar_brand2x.png similarity index 100% rename from docs/src/main/resources/microsite/img/sidebar_brand2x.png rename to microsite/src/main/resources/microsite/img/sidebar_brand2x.png diff --git a/docs/src/main/resources/microsite/img/twitter-card.png b/microsite/src/main/resources/microsite/img/twitter-card.png similarity index 100% rename from docs/src/main/resources/microsite/img/twitter-card.png rename to microsite/src/main/resources/microsite/img/twitter-card.png diff --git a/docs/src/main/resources/microsite/js/automenu.js b/microsite/src/main/resources/microsite/js/automenu.js similarity index 100% rename from docs/src/main/resources/microsite/js/automenu.js rename to microsite/src/main/resources/microsite/js/automenu.js diff --git a/docs/src/main/resources/microsite/static/_sass/_breakpoint.scss b/microsite/src/main/resources/microsite/static/_sass/_breakpoint.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_breakpoint.scss rename to microsite/src/main/resources/microsite/static/_sass/_breakpoint.scss diff --git a/docs/src/main/resources/microsite/static/_sass/_components.scss b/microsite/src/main/resources/microsite/static/_sass/_components.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_components.scss rename to microsite/src/main/resources/microsite/static/_sass/_components.scss diff --git a/docs/src/main/resources/microsite/static/_sass/_fetch_docs.scss b/microsite/src/main/resources/microsite/static/_sass/_fetch_docs.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_fetch_docs.scss rename to microsite/src/main/resources/microsite/static/_sass/_fetch_docs.scss diff --git a/docs/src/main/resources/microsite/static/_sass/_footer.scss b/microsite/src/main/resources/microsite/static/_sass/_footer.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_footer.scss rename to microsite/src/main/resources/microsite/static/_sass/_footer.scss diff --git a/docs/src/main/resources/microsite/static/_sass/_header.scss b/microsite/src/main/resources/microsite/static/_sass/_header.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_header.scss rename to microsite/src/main/resources/microsite/static/_sass/_header.scss diff --git a/docs/src/main/resources/microsite/static/_sass/_main.scss b/microsite/src/main/resources/microsite/static/_sass/_main.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_main.scss rename to microsite/src/main/resources/microsite/static/_sass/_main.scss diff --git a/docs/src/main/resources/microsite/static/_sass/_navigation.scss b/microsite/src/main/resources/microsite/static/_sass/_navigation.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_navigation.scss rename to microsite/src/main/resources/microsite/static/_sass/_navigation.scss diff --git a/docs/src/main/resources/microsite/static/_sass/_variables.scss b/microsite/src/main/resources/microsite/static/_sass/_variables.scss similarity index 100% rename from docs/src/main/resources/microsite/static/_sass/_variables.scss rename to microsite/src/main/resources/microsite/static/_sass/_variables.scss diff --git a/docs/src/main/resources/microsite/static/fetch_animation.json b/microsite/src/main/resources/microsite/static/fetch_animation.json similarity index 100% rename from docs/src/main/resources/microsite/static/fetch_animation.json rename to microsite/src/main/resources/microsite/static/fetch_animation.json diff --git a/docs/src/main/resources/microsite/static/home.js b/microsite/src/main/resources/microsite/static/home.js similarity index 100% rename from docs/src/main/resources/microsite/static/home.js rename to microsite/src/main/resources/microsite/static/home.js diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 93fb6675..823b42ff 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -2,16 +2,12 @@ import microsites.MicrositesPlugin.autoImport._ import com.typesafe.sbt.site.SitePlugin.autoImport._ import sbt.Keys._ import sbt._ -import scoverage.ScoverageKeys -import com.alejandrohdezma.sbt.github.SbtGithubPlugin import microsites._ object ProjectPlugin extends AutoPlugin { override def trigger: PluginTrigger = allRequirements - override def requires: Plugins = SbtGithubPlugin - object autoImport { lazy val commonCrossDependencies = @@ -29,8 +25,6 @@ object ProjectPlugin extends AutoPlugin { micrositeDescription := "Simple & Efficient data fetching", micrositeBaseUrl := "fetch", micrositeDocumentationUrl := "/fetch/docs", - micrositeGithubOwner := "47degrees", - micrositeGithubRepo := "fetch", micrositeHighlightTheme := "tomorrow", micrositeExternalLayoutsDirectory := (resourceDirectory in Compile).value / "microsite" / "_layouts", micrositeExternalIncludesDirectory := (resourceDirectory in Compile).value / "microsite" / "_includes", @@ -81,9 +75,6 @@ object ProjectPlugin extends AutoPlugin { override def projectSettings: Seq[Def.Setting[_]] = Seq( - organization := "com.47deg", - crossScalaVersions := Seq("2.12.11", "2.13.1"), - startYear := Option(2016), scalacOptions := { val withStripedLinter = scalacOptions.value filterNot Set("-Xlint", "-Xfuture").contains (CrossVersion.partialVersion(scalaBinaryVersion.value) match { @@ -104,8 +95,7 @@ object ProjectPlugin extends AutoPlugin { ) ++ (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, 13)) => Seq() case _ => Seq("-Ypartial-unification") - }), - ScoverageKeys.coverageFailOnMinimum := false + }) ) } diff --git a/project/plugins.sbt b/project/plugins.sbt index 20162d90..cd2c1fa3 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,11 +2,13 @@ addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") -addSbtPlugin("com.47deg" % "sbt-microsites" % "1.2.0") +addSbtPlugin("com.47deg" % "sbt-microsites" % "1.2.1") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.0") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") -addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.8.0") -addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.8.0") -addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.8.0") +addSbtPlugin("com.alejandrohdezma" %% "sbt-codecov" % "0.2.0") +addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.8.2") +addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.8.2") +addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.8.2") addSbtPlugin("com.alejandrohdezma" % "sbt-mdoc-toc" % "0.2") +addSbtPlugin("com.alejandrohdezma" % "sbt-remove-test-from-pom" % "0.1.0")